var Brt=Object.defineProperty;var jSe=t=>{throw TypeError(t)};var $rt=(t,s,r)=>s in t?Brt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var _n=(t,s,r)=>$rt(t,typeof s!="symbol"?s+"":s,r),_ue=(t,s,r)=>s.has(t)||jSe("Cannot "+r);var cs=(t,s,r)=>(_ue(t,s,"read from private field"),r?r.call(t):s.get(t)),za=(t,s,r)=>s.has(t)?jSe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),Bn=(t,s,r,n)=>(_ue(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Bi=(t,s,r)=>(_ue(t,s,"access private method"),r);var OO=(t,s,r,n)=>({set _(a){Bn(t,s,a,r)},get _(){return cs(t,s,n)}});function qrt(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 a0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function aDe(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 iDe={exports:{}},jie={},oDe={exports:{}},ro={};/** * @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 $6=Symbol.for("react.element"),Urt=Symbol.for("react.portal"),Vrt=Symbol.for("react.fragment"),Hrt=Symbol.for("react.strict_mode"),Wrt=Symbol.for("react.profiler"),Grt=Symbol.for("react.provider"),Krt=Symbol.for("react.context"),Zrt=Symbol.for("react.forward_ref"),Yrt=Symbol.for("react.suspense"),Xrt=Symbol.for("react.memo"),Qrt=Symbol.for("react.lazy"),kSe=Symbol.iterator;function Jrt(t){return t===null||typeof t!="object"?null:(t=kSe&&t[kSe]||t["@@iterator"],typeof t=="function"?t:null)}var lDe={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},cDe=Object.assign,dDe={};function W3(t,s,r){this.props=t,this.context=s,this.refs=dDe,this.updater=r||lDe}W3.prototype.isReactComponent={};W3.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")};W3.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function uDe(){}uDe.prototype=W3.prototype;function z0e(t,s,r){this.props=t,this.context=s,this.refs=dDe,this.updater=r||lDe}var B0e=z0e.prototype=new uDe;B0e.constructor=z0e;cDe(B0e,W3.prototype);B0e.isPureReactComponent=!0;var NSe=Array.isArray,hDe=Object.prototype.hasOwnProperty,$0e={current:null},mDe={key:!0,ref:!0,__self:!0,__source:!0};function pDe(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)hDe.call(s,n)&&!mDe.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,ve=de[ye];if(0>>1;yea(Ne,be))Aea(Pe,Ne)?(de[ye]=Pe,de[Ae]=be,ye=Ae):(de[ye]=Ne,de[Ge]=be,ye=Ge);else if(Aea(Pe,be))de[ye]=Pe,de[Ae]=be,ye=Ae;else break e}}return xe}function a(de,xe){var be=de.sortIndex-xe.sortIndex;return be!==0?be:de.id-xe.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 d=[],u=[],f=1,g=null,v=3,_=!1,b=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(de){for(var xe=r(u);xe!==null;){if(xe.callback===null)n(u);else if(xe.startTime<=de)n(u),xe.sortIndex=xe.expirationTime,s(d,xe);else break;xe=r(u)}}function I(de){if(w=!1,A(de),!b)if(r(d)!==null)b=!0,oe(L);else{var xe=r(u);xe!==null&&le(I,xe.startTime-de)}}function L(de,xe){b=!1,w&&(w=!1,N(q),q=-1),_=!0;var be=v;try{for(A(xe),g=r(d);g!==null&&(!(g.expirationTime>xe)||de&&!Q());){var ye=g.callback;if(typeof ye=="function"){g.callback=null,v=g.priorityLevel;var ve=ye(g.expirationTime<=xe);xe=t.unstable_now(),typeof ve=="function"?g.callback=ve:g===r(d)&&n(d),A(xe)}else n(d);g=r(d)}if(g!==null)var ke=!0;else{var Ge=r(u);Ge!==null&&le(I,Ge.startTime-xe),ke=!1}return ke}finally{g=null,v=be,_=!1}}var F=!1,$=null,q=-1,H=5,U=-1;function Q(){return!(t.unstable_now()-Ude||125ye?(de.sortIndex=be,s(u,de),r(d)===null&&de===r(u)&&(w?(N(q),q=-1):w=!0,le(I,be-ye))):(de.sortIndex=ve,s(d,de),b||_||(b=!0,oe(L))),de},t.unstable_shouldYield=Q,t.unstable_wrapCallback=function(de){var xe=v;return function(){var be=v;v=xe;try{return de.apply(this,arguments)}finally{v=be}}}})(vDe);yDe.exports=vDe;var dnt=yDe.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 unt=M,_p=dnt;function Wr(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"),Npe=Object.prototype.hasOwnProperty,hnt=/^[: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]*$/,CSe={},MSe={};function mnt(t){return Npe.call(MSe,t)?!0:Npe.call(CSe,t)?!1:hnt.test(t)?MSe[t]=!0:(CSe[t]=!0,!1)}function pnt(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 fnt(t,s,r,n){if(s===null||typeof s>"u"||pnt(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 Wh(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 Iu={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Iu[t]=new Wh(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];Iu[s]=new Wh(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Iu[t]=new Wh(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Iu[t]=new Wh(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){Iu[t]=new Wh(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Iu[t]=new Wh(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Iu[t]=new Wh(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Iu[t]=new Wh(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Iu[t]=new Wh(t,5,!1,t.toLowerCase(),null,!1,!1)});var V0e=/[\-:]([a-z])/g;function H0e(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(V0e,H0e);Iu[s]=new Wh(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(V0e,H0e);Iu[s]=new Wh(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(V0e,H0e);Iu[s]=new Wh(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Iu[t]=new Wh(t,1,!1,t.toLowerCase(),null,!1,!1)});Iu.xlinkHref=new Wh("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Iu[t]=new Wh(t,1,!1,t.toLowerCase(),null,!0,!0)});function W0e(t,s,r,n){var a=Iu.hasOwnProperty(s)?Iu[s]:null;(a!==null?a.type!==0:n||!(2i||a[l]!==o[i]){var d=` `+a[l].replace(" at new "," at ");return t.displayName&&d.includes("")&&(d=d.replace("",t.displayName)),d}while(1<=l&&0<=i);break}}}finally{jue=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?cE(t):""}function gnt(t){switch(t.tag){case 5:return cE(t.type);case 16:return cE("Lazy");case 13:return cE("Suspense");case 19:return cE("SuspenseList");case 0:case 2:case 15:return t=kue(t.type,!1),t;case 11:return t=kue(t.type.render,!1),t;case 1:return t=kue(t.type,!0),t;default:return""}}function Tpe(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 g4:return"Fragment";case f4:return"Portal";case Spe:return"Profiler";case G0e:return"StrictMode";case Cpe:return"Suspense";case Mpe:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case wDe:return(t.displayName||"Context")+".Consumer";case bDe:return(t._context.displayName||"Context")+".Provider";case K0e:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Z0e:return s=t.displayName||null,s!==null?s:Tpe(t.type)||"Memo";case Zv:s=t._payload,t=t._init;try{return Tpe(t(s))}catch{}}return null}function xnt(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 Tpe(s);case 8:return s===G0e?"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 u_(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function kDe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ynt(t){var s=kDe(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 zO(t){t._valueTracker||(t._valueTracker=ynt(t))}function NDe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=kDe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function mre(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 Ape(t,s){var r=s.checked;return Nc({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function ASe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=u_(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 SDe(t,s){s=s.checked,s!=null&&W0e(t,"checked",s,!1)}function Epe(t,s){SDe(t,s);var r=u_(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")?Ppe(t,s.type,r):s.hasOwnProperty("defaultValue")&&Ppe(t,s.type,u_(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function ESe(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 Ppe(t,s,r){(s!=="number"||mre(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var dE=Array.isArray;function z4(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=BO.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function nI(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var NE={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},vnt=["Webkit","ms","Moz","O"];Object.keys(NE).forEach(function(t){vnt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),NE[s]=NE[t]})});function ADe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||NE.hasOwnProperty(t)&&NE[t]?(""+s).trim():s+"px"}function EDe(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=ADe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var _nt=Nc({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 Dpe(t,s){if(s){if(_nt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Wr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Wr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Wr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Wr(62))}}function Ope(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 Rpe=null;function Y0e(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Fpe=null,B4=null,$4=null;function LSe(t){if(t=V6(t)){if(typeof Fpe!="function")throw Error(Wr(280));var s=t.stateNode;s&&(s=Mie(s),Fpe(t.stateNode,t.type,s))}}function PDe(t){B4?$4?$4.push(t):$4=[t]:B4=t}function IDe(){if(B4){var t=B4,s=$4;if($4=B4=null,LSe(t),s)for(t=0;t>>=0,t===0?32:31-(Ent(t)/Pnt|0)|0}var $O=64,qO=4194304;function uE(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 xre(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=uE(i):(o&=l,o!==0&&(n=uE(o)))}else l=r&~a,l!==0?n=uE(l):o!==0&&(n=uE(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 q6(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Ng(s),t[s]=r}function Ont(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=CE),USe=" ",VSe=!1;function JDe(t,s){switch(t){case"keyup":return dat.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function eOe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var x4=!1;function hat(t,s){switch(t){case"compositionend":return eOe(s);case"keypress":return s.which!==32?null:(VSe=!0,USe);case"textInput":return t=s.data,t===USe&&VSe?null:t;default:return null}}function mat(t,s){if(x4)return t==="compositionend"||!nve&&JDe(t,s)?(t=XDe(),_R=tve=k1=null,x4=!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=KSe(r)}}function nOe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?nOe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function aOe(){for(var t=window,s=mre();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=mre(t.document)}return s}function ave(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 wat(t){var s=aOe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&nOe(r.ownerDocument.documentElement,r)){if(n!==null&&ave(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=ZSe(r,o);var l=ZSe(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,y4=null,Vpe=null,TE=null,Hpe=!1;function YSe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Hpe||y4==null||y4!==mre(n)||(n=y4,"selectionStart"in n&&ave(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}),TE&&dI(TE,n)||(TE=n,n=_re(Vpe,"onSelect"),0b4||(t.current=Xpe[b4],Xpe[b4]=null,b4--)}function Cl(t,s){b4++,Xpe[b4]=t.current,t.current=s}var h_={},Qu=N_(h_),wm=N_(!1),pN=h_;function W5(t,s){var r=t.type.contextTypes;if(!r)return h_;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 jm(t){return t=t.childContextTypes,t!=null}function wre(){Wl(wm),Wl(Qu)}function rCe(t,s,r){if(Qu.current!==h_)throw Error(Wr(168));Cl(Qu,s),Cl(wm,r)}function pOe(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(Wr(108,xnt(t)||"Unknown",a));return Nc({},r,n)}function jre(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||h_,pN=Qu.current,Cl(Qu,t),Cl(wm,wm.current),!0}function nCe(t,s,r){var n=t.stateNode;if(!n)throw Error(Wr(169));r?(t=pOe(t,s,pN),n.__reactInternalMemoizedMergedChildContext=t,Wl(wm),Wl(Qu),Cl(Qu,t)):Wl(wm),Cl(wm,r)}var Xy=null,Tie=!1,Fue=!1;function fOe(t){Xy===null?Xy=[t]:Xy.push(t)}function Lat(t){Tie=!0,fOe(t)}function S_(){if(!Fue&&Xy!==null){Fue=!0;var t=0,s=el;try{var r=Xy;for(el=1;t>=l,a-=l,i0=1<<32-Ng(s)+a|r<q?(H=$,$=null):H=$.sibling;var U=v(N,$,A[q],I);if(U===null){$===null&&($=H);break}t&&$&&U.alternate===null&&s(N,$),S=o(U,S,q),F===null?L=U:F.sibling=U,F=U,$=H}if(q===A.length)return r(N,$),cc&&Hb(N,q),L;if($===null){for(;qq?(H=$,$=null):H=$.sibling;var Q=v(N,$,U.value,I);if(Q===null){$===null&&($=H);break}t&&$&&Q.alternate===null&&s(N,$),S=o(Q,S,q),F===null?L=Q:F.sibling=Q,F=Q,$=H}if(U.done)return r(N,$),cc&&Hb(N,q),L;if($===null){for(;!U.done;q++,U=A.next())U=g(N,U.value,I),U!==null&&(S=o(U,S,q),F===null?L=U:F.sibling=U,F=U);return cc&&Hb(N,q),L}for($=n(N,$);!U.done;q++,U=A.next())U=_($,N,q,U.value,I),U!==null&&(t&&U.alternate!==null&&$.delete(U.key===null?q:U.key),S=o(U,S,q),F===null?L=U:F.sibling=U,F=U);return t&&$.forEach(function(se){return s(N,se)}),cc&&Hb(N,q),L}function j(N,S,A,I){if(typeof A=="object"&&A!==null&&A.type===g4&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case FO:e:{for(var L=A.key,F=S;F!==null;){if(F.key===L){if(L=A.type,L===g4){if(F.tag===7){r(N,F.sibling),S=a(F,A.props.children),S.return=N,N=S;break e}}else if(F.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===Zv&&oCe(L)===F.type){r(N,F.sibling),S=a(F,A.props),S.ref=AA(N,F,A),S.return=N,N=S;break e}r(N,F);break}else s(N,F);F=F.sibling}A.type===g4?(S=qk(A.props.children,N.mode,I,A.key),S.return=N,N=S):(I=MR(A.type,A.key,A.props,null,N.mode,I),I.ref=AA(N,S,A),I.return=N,N=I)}return l(N);case f4:e:{for(F=A.key;S!==null;){if(S.key===F)if(S.tag===4&&S.stateNode.containerInfo===A.containerInfo&&S.stateNode.implementation===A.implementation){r(N,S.sibling),S=a(S,A.children||[]),S.return=N,N=S;break e}else{r(N,S);break}else s(N,S);S=S.sibling}S=Wue(A,N.mode,I),S.return=N,N=S}return l(N);case Zv:return F=A._init,j(N,S,F(A._payload),I)}if(dE(A))return b(N,S,A,I);if(NA(A))return w(N,S,A,I);ZO(N,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,S!==null&&S.tag===6?(r(N,S.sibling),S=a(S,A),S.return=N,N=S):(r(N,S),S=Hue(A,N.mode,I),S.return=N,N=S),l(N)):r(N,S)}return j}var K5=vOe(!0),_Oe=vOe(!1),Sre=N_(null),Cre=null,k4=null,cve=null;function dve(){cve=k4=Cre=null}function uve(t){var s=Sre.current;Wl(Sre),t._currentValue=s}function efe(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 U4(t,s){Cre=t,cve=k4=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(gm=!0),t.firstContext=null)}function pf(t){var s=t._currentValue;if(cve!==t)if(t={context:t,memoizedValue:s,next:null},k4===null){if(Cre===null)throw Error(Wr(308));k4=t,Cre.dependencies={lanes:0,firstContext:t}}else k4=k4.next=t;return s}var gk=null;function hve(t){gk===null?gk=[t]:gk.push(t)}function bOe(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,hve(s)):(r.next=a.next,a.next=r),s.interleaved=r,L0(t,n)}function L0(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 Yv=!1;function mve(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wOe(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 m0(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function F1(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,ko&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,L0(t,r)}return a=n.interleaved,a===null?(s.next=s,hve(n)):(s.next=a.next,a.next=s),n.interleaved=s,L0(t,r)}function wR(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,Q0e(t,r)}}function lCe(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 Mre(t,s,r,n){var a=t.updateQueue;Yv=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var d=i,u=d.next;d.next=null,l===null?o=u:l.next=u,l=d;var f=t.alternate;f!==null&&(f=f.updateQueue,i=f.lastBaseUpdate,i!==l&&(i===null?f.firstBaseUpdate=u:i.next=u,f.lastBaseUpdate=d))}if(o!==null){var g=a.baseState;l=0,f=u=d=null,i=o;do{var v=i.lane,_=i.eventTime;if((n&v)===v){f!==null&&(f=f.next={eventTime:_,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var b=t,w=i;switch(v=s,_=r,w.tag){case 1:if(b=w.payload,typeof b=="function"){g=b.call(_,g,v);break e}g=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=w.payload,v=typeof b=="function"?b.call(_,g,v):b,v==null)break e;g=Nc({},g,v);break e;case 2:Yv=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,v=a.effects,v===null?a.effects=[i]:v.push(i))}else _={eventTime:_,lane:v,tag:i.tag,payload:i.payload,callback:i.callback,next:null},f===null?(u=f=_,d=g):f=f.next=_,l|=v;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;v=i,i=v.next,v.next=null,a.lastBaseUpdate=v,a.shared.pending=null}}while(!0);if(f===null&&(d=g),a.baseState=d,a.firstBaseUpdate=u,a.lastBaseUpdate=f,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);xN|=l,t.lanes=l,t.memoizedState=g}}function cCe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Bue.transition;Bue.transition={};try{t(!1),s()}finally{el=r,Bue.transition=n}}function zOe(){return ff().memoizedState}function Fat(t,s,r){var n=B1(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},BOe(t))$Oe(s,r);else if(r=bOe(t,s,r,n),r!==null){var a=Ih();Sg(r,t,n,a),qOe(r,s,n)}}function zat(t,s,r){var n=B1(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(BOe(t))$Oe(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,Og(i,l)){var d=s.interleaved;d===null?(a.next=a,hve(s)):(a.next=d.next,d.next=a),s.interleaved=a;return}}catch{}finally{}r=bOe(t,s,a,n),r!==null&&(a=Ih(),Sg(r,t,n,a),qOe(r,s,n))}}function BOe(t){var s=t.alternate;return t===kc||s!==null&&s===kc}function $Oe(t,s){AE=Are=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function qOe(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,Q0e(t,r)}}var Ere={readContext:pf,useCallback:Bu,useContext:Bu,useEffect:Bu,useImperativeHandle:Bu,useInsertionEffect:Bu,useLayoutEffect:Bu,useMemo:Bu,useReducer:Bu,useRef:Bu,useState:Bu,useDebugValue:Bu,useDeferredValue:Bu,useTransition:Bu,useMutableSource:Bu,useSyncExternalStore:Bu,useId:Bu,unstable_isNewReconciler:!1},Bat={readContext:pf,useCallback:function(t,s){return yx().memoizedState=[t,s===void 0?null:s],t},useContext:pf,useEffect:uCe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,kR(4194308,4,LOe.bind(null,s,t),r)},useLayoutEffect:function(t,s){return kR(4194308,4,t,s)},useInsertionEffect:function(t,s){return kR(4,2,t,s)},useMemo:function(t,s){var r=yx();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=yx();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=Fat.bind(null,kc,t),[n.memoizedState,t]},useRef:function(t){var s=yx();return t={current:t},s.memoizedState=t},useState:dCe,useDebugValue:bve,useDeferredValue:function(t){return yx().memoizedState=t},useTransition:function(){var t=dCe(!1),s=t[0];return t=Rat.bind(null,t[1]),yx().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=kc,a=yx();if(cc){if(r===void 0)throw Error(Wr(407));r=r()}else{if(r=s(),ou===null)throw Error(Wr(349));gN&30||SOe(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,uCe(MOe.bind(null,n,o,t),[t]),n.flags|=2048,yI(9,COe.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=yx(),s=ou.identifierPrefix;if(cc){var r=o0,n=i0;r=(n&~(1<<32-Ng(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=gI++,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[Tx]=s,t[mI]=n,QOe(t,s,!1,!1),s.stateNode=t;e:{switch(l=Ope(r,n),r){case"dialog":$l("cancel",t),$l("close",t),a=n;break;case"iframe":case"object":case"embed":$l("load",t),a=n;break;case"video":case"audio":for(a=0;aX5&&(s.flags|=128,n=!0,EA(o,!1),s.lanes=4194304)}else{if(!n)if(t=Tre(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),EA(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!cc)return $u(s),null}else 2*td()-o.renderingStartTime>X5&&r!==1073741824&&(s.flags|=128,n=!0,EA(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=td(),s.sibling=null,r=_c.current,Cl(_c,n?r&1|2:r&1),s):($u(s),null);case 22:case 23:return Cve(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?Xm&1073741824&&($u(s),s.subtreeFlags&6&&(s.flags|=8192)):$u(s),null;case 24:return null;case 25:return null}throw Error(Wr(156,s.tag))}function Kat(t,s){switch(ove(s),s.tag){case 1:return jm(s.type)&&wre(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return Z5(),Wl(wm),Wl(Qu),gve(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return fve(s),null;case 13:if(Wl(_c),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Wr(340));G5()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return Wl(_c),null;case 4:return Z5(),null;case 10:return uve(s.type._context),null;case 22:case 23:return Cve(),null;case 24:return null;default:return null}}var XO=!1,Hu=!1,Zat=typeof WeakSet=="function"?WeakSet:Set,Zn=null;function N4(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Lc(t,s,n)}else r.current=null}function cfe(t,s,r){try{r()}catch(n){Lc(t,s,n)}}var wCe=!1;function Yat(t,s){if(Wpe=yre,t=aOe(),ave(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,d=-1,u=0,f=0,g=t,v=null;t:for(;;){for(var _;g!==r||a!==0&&g.nodeType!==3||(i=l+a),g!==o||n!==0&&g.nodeType!==3||(d=l+n),g.nodeType===3&&(l+=g.nodeValue.length),(_=g.firstChild)!==null;)v=g,g=_;for(;;){if(g===t)break t;if(v===r&&++u===a&&(i=l),v===o&&++f===n&&(d=l),(_=g.nextSibling)!==null)break;g=v,v=g.parentNode}g=_}r=i===-1||d===-1?null:{start:i,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(Gpe={focusedElem:t,selectionRange:r},yre=!1,Zn=s;Zn!==null;)if(s=Zn,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Zn=t;else for(;Zn!==null;){s=Zn;try{var b=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var w=b.memoizedProps,j=b.memoizedState,N=s.stateNode,S=N.getSnapshotBeforeUpdate(s.elementType===s.type?w:lg(s.type,w),j);N.__reactInternalSnapshotBeforeUpdate=S}break;case 3:var A=s.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Wr(163))}}catch(I){Lc(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,Zn=t;break}Zn=s.return}return b=wCe,wCe=!1,b}function EE(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&&cfe(s,r,o)}a=a.next}while(a!==n)}}function Pie(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 dfe(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 t8e(t){var s=t.alternate;s!==null&&(t.alternate=null,t8e(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Tx],delete s[mI],delete s[Ype],delete s[Pat],delete s[Iat])),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 s8e(t){return t.tag===5||t.tag===3||t.tag===4}function jCe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||s8e(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 ufe(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=bre));else if(n!==4&&(t=t.child,t!==null))for(ufe(t,s,r),t=t.sibling;t!==null;)ufe(t,s,r),t=t.sibling}function hfe(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(hfe(t,s,r),t=t.sibling;t!==null;)hfe(t,s,r),t=t.sibling}var ju=null,hg=!1;function Ov(t,s,r){for(r=r.child;r!==null;)r8e(t,s,r),r=r.sibling}function r8e(t,s,r){if(Ox&&typeof Ox.onCommitFiberUnmount=="function")try{Ox.onCommitFiberUnmount(kie,r)}catch{}switch(r.tag){case 5:Hu||N4(r,s);case 6:var n=ju,a=hg;ju=null,Ov(t,s,r),ju=n,hg=a,ju!==null&&(hg?(t=ju,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):ju.removeChild(r.stateNode));break;case 18:ju!==null&&(hg?(t=ju,r=r.stateNode,t.nodeType===8?Rue(t.parentNode,r):t.nodeType===1&&Rue(t,r),lI(t)):Rue(ju,r.stateNode));break;case 4:n=ju,a=hg,ju=r.stateNode.containerInfo,hg=!0,Ov(t,s,r),ju=n,hg=a;break;case 0:case 11:case 14:case 15:if(!Hu&&(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)&&cfe(r,s,l),a=a.next}while(a!==n)}Ov(t,s,r);break;case 1:if(!Hu&&(N4(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){Lc(r,s,i)}Ov(t,s,r);break;case 21:Ov(t,s,r);break;case 22:r.mode&1?(Hu=(n=Hu)||r.memoizedState!==null,Ov(t,s,r),Hu=n):Ov(t,s,r);break;default:Ov(t,s,r)}}function kCe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Zat),s.forEach(function(n){var a=ait.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function Jf(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=td()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Qat(n/1960))-n,10t?16:t,N1===null)var n=!1;else{if(t=N1,N1=null,Lre=0,ko&6)throw Error(Wr(331));var a=ko;for(ko|=4,Zn=t.current;Zn!==null;){var o=Zn,l=o.child;if(Zn.flags&16){var i=o.deletions;if(i!==null){for(var d=0;dtd()-Nve?$k(t,0):kve|=r),km(t,s)}function u8e(t,s){s===0&&(t.mode&1?(s=qO,qO<<=1,!(qO&130023424)&&(qO=4194304)):s=1);var r=Ih();t=L0(t,s),t!==null&&(q6(t,s,r),km(t,r))}function nit(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),u8e(t,r)}function ait(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(Wr(314))}n!==null&&n.delete(s),u8e(t,r)}var h8e;h8e=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||wm.current)gm=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return gm=!1,Wat(t,s,r);gm=!!(t.flags&131072)}else gm=!1,cc&&s.flags&1048576&&gOe(s,Nre,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;NR(t,s),t=s.pendingProps;var a=W5(s,Qu.current);U4(s,r),a=yve(null,s,n,t,a,r);var o=vve();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,jm(n)?(o=!0,jre(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,mve(s),a.updater=Eie,s.stateNode=a,a._reactInternals=s,sfe(s,n,t,r),s=afe(null,s,n,!0,o,r)):(s.tag=0,cc&&o&&ive(s),_h(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(NR(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=oit(n),t=lg(n,t),a){case 0:s=nfe(null,s,n,t,r);break e;case 1:s=vCe(null,s,n,t,r);break e;case 11:s=xCe(null,s,n,t,r);break e;case 14:s=yCe(null,s,n,lg(n.type,t),r);break e}throw Error(Wr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:lg(n,a),nfe(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:lg(n,a),vCe(t,s,n,a,r);case 3:e:{if(ZOe(s),t===null)throw Error(Wr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,wOe(t,s),Mre(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=Y5(Error(Wr(423)),s),s=_Ce(t,s,n,r,a);break e}else if(n!==a){a=Y5(Error(Wr(424)),s),s=_Ce(t,s,n,r,a);break e}else for(ip=R1(s.stateNode.containerInfo.firstChild),lp=s,cc=!0,gg=null,r=_Oe(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(G5(),n===a){s=D0(t,s,r);break e}_h(t,s,n,r)}s=s.child}return s;case 5:return jOe(s),t===null&&Jpe(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,Kpe(n,a)?l=null:o!==null&&Kpe(n,o)&&(s.flags|=32),KOe(t,s),_h(t,s,l,r),s.child;case 6:return t===null&&Jpe(s),null;case 13:return YOe(t,s,r);case 4:return pve(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=K5(s,null,n,r):_h(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:lg(n,a),xCe(t,s,n,a,r);case 7:return _h(t,s,s.pendingProps,r),s.child;case 8:return _h(t,s,s.pendingProps.children,r),s.child;case 12:return _h(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,Cl(Sre,n._currentValue),n._currentValue=l,o!==null)if(Og(o.value,l)){if(o.children===a.children&&!wm.current){s=D0(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 d=i.firstContext;d!==null;){if(d.context===n){if(o.tag===1){d=m0(-1,r&-r),d.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var f=u.pending;f===null?d.next=d:(d.next=f.next,f.next=d),u.pending=d}}o.lanes|=r,d=o.alternate,d!==null&&(d.lanes|=r),efe(o.return,r,s),i.lanes|=r;break}d=d.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(Wr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),efe(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}_h(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,U4(s,r),a=pf(a),n=n(a),s.flags|=1,_h(t,s,n,r),s.child;case 14:return n=s.type,a=lg(n,s.pendingProps),a=lg(n.type,a),yCe(t,s,n,a,r);case 15:return WOe(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:lg(n,a),NR(t,s),s.tag=1,jm(n)?(t=!0,jre(s)):t=!1,U4(s,r),UOe(s,n,a),sfe(s,n,a,r),afe(null,s,n,!0,t,r);case 19:return XOe(t,s,r);case 22:return GOe(t,s,r)}throw Error(Wr(156,s.tag))};function m8e(t,s){return BDe(t,s)}function iit(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 tf(t,s,r,n){return new iit(t,s,r,n)}function Tve(t){return t=t.prototype,!(!t||!t.isReactComponent)}function oit(t){if(typeof t=="function")return Tve(t)?1:0;if(t!=null){if(t=t.$$typeof,t===K0e)return 11;if(t===Z0e)return 14}return 2}function $1(t,s){var r=t.alternate;return r===null?(r=tf(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 MR(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")Tve(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case g4:return qk(r.children,a,o,s);case G0e:l=8,a|=8;break;case Spe:return t=tf(12,r,s,a|2),t.elementType=Spe,t.lanes=o,t;case Cpe:return t=tf(13,r,s,a),t.elementType=Cpe,t.lanes=o,t;case Mpe:return t=tf(19,r,s,a),t.elementType=Mpe,t.lanes=o,t;case jDe:return Lie(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case bDe:l=10;break e;case wDe:l=9;break e;case K0e:l=11;break e;case Z0e:l=14;break e;case Zv:l=16,n=null;break e}throw Error(Wr(130,t==null?t:typeof t,""))}return s=tf(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function qk(t,s,r,n){return t=tf(7,t,n,s),t.lanes=r,t}function Lie(t,s,r,n){return t=tf(22,t,n,s),t.elementType=jDe,t.lanes=r,t.stateNode={isHidden:!1},t}function Hue(t,s,r){return t=tf(6,t,null,s),t.lanes=r,t}function Wue(t,s,r){return s=tf(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function lit(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=Sue(0),this.expirationTimes=Sue(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Sue(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Ave(t,s,r,n,a,o,l,i,d){return t=new lit(t,s,r,i,d),s===1?(s=1,o===!0&&(s|=8)):s=0,o=tf(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},mve(o),t}function cit(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(x8e)}catch(t){console.error(t)}}x8e(),xDe.exports=wp;var xm=xDe.exports;const Lve=vo(xm);var y8e,PCe=xm;y8e=PCe.createRoot,PCe.hydrateRoot;const pit="modulepreload",fit=function(t){return"/"+t},ICe={},H0=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(d=>{if(d=fit(d),d in ICe)return;ICe[d]=!0;const u=d.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${f}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":pit,u||(g.as="script"),g.crossOrigin="",g.href=d,i&&g.setAttribute("nonce",i),document.head.appendChild(g),u)return new Promise((v,_)=>{g.addEventListener("load",v),g.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}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)})},git=1,xit=1e6;let Gue=0;function yit(){return Gue=(Gue+1)%Number.MAX_SAFE_INTEGER,Gue.toString()}const Kue=new Map,LCe=t=>{if(Kue.has(t))return;const s=setTimeout(()=>{Kue.delete(t),LE({type:"REMOVE_TOAST",toastId:t})},xit);Kue.set(t,s)},vit=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,git)};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?LCe(r):t.toasts.forEach(n=>{LCe(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)}}},TR=[];let AR={toasts:[]};function LE(t){AR=vit(AR,t),TR.forEach(s=>{s(AR)})}function dn({...t}){const s=yit(),r=a=>LE({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>LE({type:"DISMISS_TOAST",toastId:s});return LE({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function La(){const[t,s]=M.useState(AR);return M.useEffect(()=>(TR.push(s),()=>{const r=TR.indexOf(s);r>-1&&TR.splice(r,1)}),[t]),{...t,toast:dn,dismiss:r=>LE({type:"DISMISS_TOAST",toastId:r})}}function Sr(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 DCe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function O0(...t){return s=>{let r=!1;const n=t.map(a=>{const o=DCe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=M.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,children:l})};n.displayName=t+"Provider";function a(o){const l=M.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 Cc(t,s=[]){let r=[];function n(o,l){const i=M.createContext(l),d=r.length;r=[...r,l];const u=g=>{var N;const{scope:v,children:_,...b}=g,w=((N=v==null?void 0:v[t])==null?void 0:N[d])||i,j=M.useMemo(()=>b,Object.values(b));return e.jsx(w.Provider,{value:j,children:_})};u.displayName=o+"Provider";function f(g,v){var w;const _=((w=v==null?void 0:v[t])==null?void 0:w[d])||i,b=M.useContext(_);if(b)return b;if(l!==void 0)return l;throw new Error(`\`${g}\` must be used within \`${o}\``)}return[u,f]}const a=()=>{const o=r.map(l=>M.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return M.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,bit(a,...s)]}function bit(...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:d,scopeName:u})=>{const g=d(o)[`__scope${u}`];return{...i,...g}},{});return M.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function m_(t){const s=wit(t),r=M.forwardRef((n,a)=>{const{children:o,...l}=n,i=M.Children.toArray(o),d=i.find(jit);if(d){const u=d.props.children,f=i.map(g=>g===d?M.Children.count(u)>1?M.Children.only(null):M.isValidElement(u)?u.props.children:null:g);return e.jsx(s,{...l,ref:a,children:M.isValidElement(u)?M.cloneElement(u,void 0,f):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var Dve=m_("Slot");function wit(t){const s=M.forwardRef((r,n)=>{const{children:a,...o}=r;if(M.isValidElement(a)){const l=Nit(a),i=kit(o,a.props);return a.type!==M.Fragment&&(i.ref=n?O0(n,l):l),M.cloneElement(a,i)}return M.Children.count(a)>1?M.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var v8e=Symbol("radix.slottable");function _8e(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=v8e,s}function jit(t){return M.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===v8e}function kit(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 d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function Nit(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 W6(t){const s=t+"CollectionProvider",[r,n]=Cc(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=w=>{const{scope:j,children:N}=w,S=ut.useRef(null),A=ut.useRef(new Map).current;return e.jsx(a,{scope:j,itemMap:A,collectionRef:S,children:N})};l.displayName=s;const i=t+"CollectionSlot",d=m_(i),u=ut.forwardRef((w,j)=>{const{scope:N,children:S}=w,A=o(i,N),I=Sa(j,A.collectionRef);return e.jsx(d,{ref:I,children:S})});u.displayName=i;const f=t+"CollectionItemSlot",g="data-radix-collection-item",v=m_(f),_=ut.forwardRef((w,j)=>{const{scope:N,children:S,...A}=w,I=ut.useRef(null),L=Sa(j,I),F=o(f,N);return ut.useEffect(()=>(F.itemMap.set(I,{ref:I,...A}),()=>void F.itemMap.delete(I))),e.jsx(v,{[g]:"",ref:L,children:S})});_.displayName=f;function b(w){const j=o(t+"CollectionConsumer",w);return ut.useCallback(()=>{const S=j.collectionRef.current;if(!S)return[];const A=Array.from(S.querySelectorAll(`[${g}]`));return Array.from(j.itemMap.values()).sort((F,$)=>A.indexOf(F.ref.current)-A.indexOf($.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:l,Slot:u,ItemSlot:_},b,n]}var Sit=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Qr=Sit.reduce((t,s)=>{const r=m_(`Primitive.${s}`),n=M.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{});function Ove(t,s){t&&xm.flushSync(()=>t.dispatchEvent(s))}function Bc(t){const s=M.useRef(t);return M.useEffect(()=>{s.current=t}),M.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function Cit(t,s=globalThis==null?void 0:globalThis.document){const r=Bc(t);M.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 Mit="DismissableLayer",xfe="dismissableLayer.update",Tit="dismissableLayer.pointerDownOutside",Ait="dismissableLayer.focusOutside",OCe,b8e=M.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),C_=M.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,u=M.useContext(b8e),[f,g]=M.useState(null),v=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=M.useState({}),b=Sa(s,$=>g($)),w=Array.from(u.layers),[j]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),N=w.indexOf(j),S=f?w.indexOf(f):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,I=S>=N,L=Pit($=>{const q=$.target,H=[...u.branches].some(U=>U.contains(q));!I||H||(a==null||a($),l==null||l($),$.defaultPrevented||i==null||i())},v),F=Iit($=>{const q=$.target;[...u.branches].some(U=>U.contains(q))||(o==null||o($),l==null||l($),$.defaultPrevented||i==null||i())},v);return Cit($=>{S===u.layers.size-1&&(n==null||n($),!$.defaultPrevented&&i&&($.preventDefault(),i()))},v),M.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(OCe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),RCe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=OCe)}},[f,v,r,u]),M.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),RCe())},[f,u]),M.useEffect(()=>{const $=()=>_({});return document.addEventListener(xfe,$),()=>document.removeEventListener(xfe,$)},[]),e.jsx(Qr.div,{...d,ref:b,style:{pointerEvents:A?I?"auto":"none":void 0,...t.style},onFocusCapture:Sr(t.onFocusCapture,F.onFocusCapture),onBlurCapture:Sr(t.onBlurCapture,F.onBlurCapture),onPointerDownCapture:Sr(t.onPointerDownCapture,L.onPointerDownCapture)})});C_.displayName=Mit;var Eit="DismissableLayerBranch",w8e=M.forwardRef((t,s)=>{const r=M.useContext(b8e),n=M.useRef(null),a=Sa(s,n);return M.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(Qr.div,{...t,ref:a})});w8e.displayName=Eit;function Pit(t,s=globalThis==null?void 0:globalThis.document){const r=Bc(t),n=M.useRef(!1),a=M.useRef(()=>{});return M.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){j8e(Tit,r,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=d,s.addEventListener("click",a.current,{once:!0})):d()}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 Iit(t,s=globalThis==null?void 0:globalThis.document){const r=Bc(t),n=M.useRef(!1);return M.useEffect(()=>{const a=o=>{o.target&&!n.current&&j8e(Ait,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 RCe(){const t=new CustomEvent(xfe);document.dispatchEvent(t)}function j8e(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?Ove(a,o):a.dispatchEvent(o)}var Lit=C_,Dit=w8e,Hc=globalThis!=null&&globalThis.document?M.useLayoutEffect:()=>{},Oit="Portal",Z3=M.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=M.useState(!1);Hc(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?Lve.createPortal(e.jsx(Qr.div,{...n,ref:s}),l):null});Z3.displayName=Oit;function Rit(t,s){return M.useReducer((r,n)=>s[r][n]??r,t)}var od=t=>{const{present:s,children:r}=t,n=Fit(s),a=typeof r=="function"?r({present:n.isPresent}):M.Children.only(r),o=Sa(n.ref,zit(a));return typeof r=="function"||n.isPresent?M.cloneElement(a,{ref:o}):null};od.displayName="Presence";function Fit(t){const[s,r]=M.useState(),n=M.useRef(null),a=M.useRef(t),o=M.useRef("none"),l=t?"mounted":"unmounted",[i,d]=Rit(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return M.useEffect(()=>{const u=e8(n.current);o.current=i==="mounted"?u:"none"},[i]),Hc(()=>{const u=n.current,f=a.current;if(f!==t){const v=o.current,_=e8(u);t?d("MOUNT"):_==="none"||(u==null?void 0:u.display)==="none"?d("UNMOUNT"):d(f&&v!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,d]),Hc(()=>{if(s){let u;const f=s.ownerDocument.defaultView??window,g=_=>{const w=e8(n.current).includes(_.animationName);if(_.target===s&&w&&(d("ANIMATION_END"),!a.current)){const j=s.style.animationFillMode;s.style.animationFillMode="forwards",u=f.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=j)})}},v=_=>{_.target===s&&(o.current=e8(n.current))};return s.addEventListener("animationstart",v),s.addEventListener("animationcancel",g),s.addEventListener("animationend",g),()=>{f.clearTimeout(u),s.removeEventListener("animationstart",v),s.removeEventListener("animationcancel",g),s.removeEventListener("animationend",g)}}else d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:M.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function e8(t){return(t==null?void 0:t.animationName)||"none"}function zit(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 Bit=U0e[" useInsertionEffect ".trim().toString()]||Hc;function uu({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=$it({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const f=M.useRef(t!==void 0);M.useEffect(()=>{const g=f.current;g!==i&&console.warn(`${n} is changing from ${g?"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.`),f.current=i},[i,n])}const u=M.useCallback(f=>{var g;if(i){const v=qit(f)?f(t):f;v!==t&&((g=l.current)==null||g.call(l,v))}else o(f)},[i,t,o,l]);return[d,u]}function $it({defaultProp:t,onChange:s}){const[r,n]=M.useState(t),a=M.useRef(r),o=M.useRef(s);return Bit(()=>{o.current=s},[s]),M.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function qit(t){return typeof t=="function"}var k8e=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"}),Uit="VisuallyHidden",zie=M.forwardRef((t,s)=>e.jsx(Qr.span,{...t,ref:s,style:{...k8e,...t.style}}));zie.displayName=Uit;var Vit=zie,Rve="ToastProvider",[Fve,Hit,Wit]=W6("Toast"),[N8e]=Cc("Toast",[Wit]),[Git,Bie]=N8e(Rve),S8e=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=M.useState(null),[u,f]=M.useState(0),g=M.useRef(!1),v=M.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${Rve}\`. Expected non-empty \`string\`.`),e.jsx(Fve.Provider,{scope:s,children:e.jsx(Git,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:d,onToastAdd:M.useCallback(()=>f(_=>_+1),[]),onToastRemove:M.useCallback(()=>f(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:v,children:l})})};S8e.displayName=Rve;var C8e="ToastViewport",Kit=["F8"],yfe="toast.viewportPause",vfe="toast.viewportResume",M8e=M.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=Kit,label:a="Notifications ({hotkey})",...o}=t,l=Bie(C8e,r),i=Hit(r),d=M.useRef(null),u=M.useRef(null),f=M.useRef(null),g=M.useRef(null),v=Sa(s,g,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;M.useEffect(()=>{const j=N=>{var A;n.length!==0&&n.every(I=>N[I]||N.code===I)&&((A=g.current)==null||A.focus())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[n]),M.useEffect(()=>{const j=d.current,N=g.current;if(b&&j&&N){const S=()=>{if(!l.isClosePausedRef.current){const F=new CustomEvent(yfe);N.dispatchEvent(F),l.isClosePausedRef.current=!0}},A=()=>{if(l.isClosePausedRef.current){const F=new CustomEvent(vfe);N.dispatchEvent(F),l.isClosePausedRef.current=!1}},I=F=>{!j.contains(F.relatedTarget)&&A()},L=()=>{j.contains(document.activeElement)||A()};return j.addEventListener("focusin",S),j.addEventListener("focusout",I),j.addEventListener("pointermove",S),j.addEventListener("pointerleave",L),window.addEventListener("blur",S),window.addEventListener("focus",A),()=>{j.removeEventListener("focusin",S),j.removeEventListener("focusout",I),j.removeEventListener("pointermove",S),j.removeEventListener("pointerleave",L),window.removeEventListener("blur",S),window.removeEventListener("focus",A)}}},[b,l.isClosePausedRef]);const w=M.useCallback(({tabbingDirection:j})=>{const S=i().map(A=>{const I=A.ref.current,L=[I,...oot(I)];return j==="forwards"?L:L.reverse()});return(j==="forwards"?S.reverse():S).flat()},[i]);return M.useEffect(()=>{const j=g.current;if(j){const N=S=>{var L,F,$;const A=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!A){const q=document.activeElement,H=S.shiftKey;if(S.target===j&&H){(L=u.current)==null||L.focus();return}const se=w({tabbingDirection:H?"backwards":"forwards"}),te=se.findIndex(Y=>Y===q);Zue(se.slice(te+1))?S.preventDefault():H?(F=u.current)==null||F.focus():($=f.current)==null||$.focus()}};return j.addEventListener("keydown",N),()=>j.removeEventListener("keydown",N)}},[i,w]),e.jsxs(Dit,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&e.jsx(_fe,{ref:u,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"forwards"});Zue(j)}}),e.jsx(Fve.Slot,{scope:r,children:e.jsx(Qr.ol,{tabIndex:-1,...o,ref:v})}),b&&e.jsx(_fe,{ref:f,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"backwards"});Zue(j)}})]})});M8e.displayName=C8e;var T8e="ToastFocusProxy",_fe=M.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Bie(T8e,r);return e.jsx(zie,{"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()}})});_fe.displayName=T8e;var G6="Toast",Zit="toast.swipeStart",Yit="toast.swipeMove",Xit="toast.swipeCancel",Qit="toast.swipeEnd",A8e=M.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,d]=uu({prop:n,defaultProp:a??!0,onChange:o,caller:G6});return e.jsx(od,{present:r||i,children:e.jsx(tot,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:Bc(t.onPause),onResume:Bc(t.onResume),onSwipeStart:Sr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Sr(t.onSwipeMove,u=>{const{x:f,y:g}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:Sr(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:Sr(t.onSwipeEnd,u=>{const{x:f,y:g}=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",`${f}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),d(!1)})})})});A8e.displayName=G6;var[Jit,eot]=N8e(G6,{onClose(){}}),tot=M.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:u,onSwipeStart:f,onSwipeMove:g,onSwipeCancel:v,onSwipeEnd:_,...b}=t,w=Bie(G6,r),[j,N]=M.useState(null),S=Sa(s,Y=>N(Y)),A=M.useRef(null),I=M.useRef(null),L=a||w.duration,F=M.useRef(0),$=M.useRef(L),q=M.useRef(0),{onToastAdd:H,onToastRemove:U}=w,Q=Bc(()=>{var ce;(j==null?void 0:j.contains(document.activeElement))&&((ce=w.viewport)==null||ce.focus()),l()}),se=M.useCallback(Y=>{!Y||Y===1/0||(window.clearTimeout(q.current),F.current=new Date().getTime(),q.current=window.setTimeout(Q,Y))},[Q]);M.useEffect(()=>{const Y=w.viewport;if(Y){const ce=()=>{se($.current),u==null||u()},oe=()=>{const le=new Date().getTime()-F.current;$.current=$.current-le,window.clearTimeout(q.current),d==null||d()};return Y.addEventListener(yfe,oe),Y.addEventListener(vfe,ce),()=>{Y.removeEventListener(yfe,oe),Y.removeEventListener(vfe,ce)}}},[w.viewport,L,d,u,se]),M.useEffect(()=>{o&&!w.isClosePausedRef.current&&se(L)},[o,L,w.isClosePausedRef,se]),M.useEffect(()=>(H(),()=>U()),[H,U]);const te=M.useMemo(()=>j?R8e(j):null,[j]);return w.viewport?e.jsxs(e.Fragment,{children:[te&&e.jsx(sot,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:te}),e.jsx(Jit,{scope:r,onClose:Q,children:xm.createPortal(e.jsx(Fve.ItemSlot,{scope:r,children:e.jsx(Lit,{asChild:!0,onEscapeKeyDown:Sr(i,()=>{w.isFocusedToastEscapeKeyDownRef.current||Q(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(Qr.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":w.swipeDirection,...b,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Sr(t.onKeyDown,Y=>{Y.key==="Escape"&&(i==null||i(Y.nativeEvent),Y.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,Q()))}),onPointerDown:Sr(t.onPointerDown,Y=>{Y.button===0&&(A.current={x:Y.clientX,y:Y.clientY})}),onPointerMove:Sr(t.onPointerMove,Y=>{if(!A.current)return;const ce=Y.clientX-A.current.x,oe=Y.clientY-A.current.y,le=!!I.current,de=["left","right"].includes(w.swipeDirection),xe=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,be=de?xe(0,ce):0,ye=de?0:xe(0,oe),ve=Y.pointerType==="touch"?10:2,ke={x:be,y:ye},Ge={originalEvent:Y,delta:ke};le?(I.current=ke,t8(Yit,g,Ge,{discrete:!1})):FCe(ke,w.swipeDirection,ve)?(I.current=ke,t8(Zit,f,Ge,{discrete:!1}),Y.target.setPointerCapture(Y.pointerId)):(Math.abs(ce)>ve||Math.abs(oe)>ve)&&(A.current=null)}),onPointerUp:Sr(t.onPointerUp,Y=>{const ce=I.current,oe=Y.target;if(oe.hasPointerCapture(Y.pointerId)&&oe.releasePointerCapture(Y.pointerId),I.current=null,A.current=null,ce){const le=Y.currentTarget,de={originalEvent:Y,delta:ce};FCe(ce,w.swipeDirection,w.swipeThreshold)?t8(Qit,_,de,{discrete:!0}):t8(Xit,v,de,{discrete:!0}),le.addEventListener("click",xe=>xe.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),sot=t=>{const{__scopeToast:s,children:r,...n}=t,a=Bie(G6,s),[o,l]=M.useState(!1),[i,d]=M.useState(!1);return aot(()=>l(!0)),M.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(Z3,{asChild:!0,children:e.jsx(zie,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},rot="ToastTitle",E8e=M.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});E8e.displayName=rot;var not="ToastDescription",P8e=M.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});P8e.displayName=not;var I8e="ToastAction",L8e=M.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(O8e,{altText:r,asChild:!0,children:e.jsx(zve,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${I8e}\`. Expected non-empty \`string\`.`),null)});L8e.displayName=I8e;var D8e="ToastClose",zve=M.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=eot(D8e,r);return e.jsx(O8e,{asChild:!0,children:e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Sr(t.onClick,a.onClose)})})});zve.displayName=D8e;var O8e=M.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(Qr.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function R8e(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),iot(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(...R8e(n))}}),s}function t8(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?Ove(a,o):a.dispatchEvent(o)}var FCe=(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 aot(t=()=>{}){const s=Bc(t);Hc(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function iot(t){return t.nodeType===t.ELEMENT_NODE}function oot(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 Zue(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var lot=S8e,F8e=M8e,z8e=A8e,B8e=E8e,$8e=P8e,q8e=L8e,U8e=zve;function V8e(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,BCe=Ri,VN=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return BCe(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 f=r==null?void 0:r[u],g=o==null?void 0:o[u];if(f===null)return null;const v=zCe(f)||zCe(g);return a[u][v]}),i=r&&Object.entries(r).reduce((u,f)=>{let[g,v]=f;return v===void 0||(u[g]=v),u},{}),d=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:g,className:v,..._}=f;return Object.entries(_).every(b=>{let[w,j]=b;return Array.isArray(j)?j.includes({...o,...i}[w]):{...o,...i}[w]===j})?[...u,g,v]:u},[]);return BCe(t,l,d,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 cot=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),H8e=(...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 dot={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 W8e=M.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>M.createElement("svg",{ref:d,...dot,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:H8e("lucide",a),...i},[...l.map(([u,f])=>M.createElement(u,f)),...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 G=(t,s)=>{const r=M.forwardRef(({className:n,...a},o)=>M.createElement(W8e,{ref:o,iconNode:s,className:H8e(`lucide-${cot(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 ER=G("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 PR=G("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 IR=G("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 LR=G("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 Fx=G("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 DR=G("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 OR=G("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 Gb=G("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 Kb=G("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 RR=G("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 Zb=G("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 FR=G("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 zR=G("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 BR=G("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 $R=G("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 qR=G("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 H4=G("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 UR=G("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 VR=G("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 HR=G("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 WR=G("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 GR=G("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 KR=G("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 ZR=G("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 YR=G("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 XR=G("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 QR=G("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 JR=G("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 W4=G("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 G4=G("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 eF=G("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 tF=G("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 sF=G("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 rF=G("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 nF=G("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 aF=G("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 iF=G("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 oF=G("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 lF=G("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 cF=G("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 dF=G("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 uF=G("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 hF=G("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 mF=G("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 pF=G("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 fF=G("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 gF=G("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 xF=G("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 yF=G("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 vF=G("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 _F=G("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 DE=G("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 bF=G("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 OE=G("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 wF=G("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 K4=G("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 jF=G("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 kF=G("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 NF=G("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 SF=G("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 CF=G("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 MF=G("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 TF=G("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 AF=G("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 EF=G("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 PF=G("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 IF=G("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 Yb=G("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 LF=G("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 DF=G("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 OF=G("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 RF=G("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 FF=G("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 zF=G("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 BF=G("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 Xb=G("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 Qb=G("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 Ku=G("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 $F=G("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 qF=G("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 UF=G("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 Ba=G("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 VF=G("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 p0=G("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 HF=G("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 Ai=G("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 WF=G("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 GF=G("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 Jb=G("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 $c=G("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 KF=G("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 ZF=G("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 YF=G("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 ew=G("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 XF=G("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 QF=G("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 JF=G("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 tw=G("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 Rd=G("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 ez=G("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 tz=G("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 sz=G("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 rz=G("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 nz=G("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 az=G("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 dc=G("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 iz=G("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 sw=G("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 oz=G("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 lz=G("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 cz=G("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 dz=G("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 rw=G("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 uz=G("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 hz=G("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 mz=G("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 pz=G("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 fz=G("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 gz=G("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 xz=G("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 yz=G("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 vz=G("BadgePlus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"16",key:"10p56q"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _z=G("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 bz=G("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 wz=G("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 jz=G("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 kz=G("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 Nz=G("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 Sz=G("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 Cz=G("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 Mz=G("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 Tz=G("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 Az=G("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 Ez=G("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 f0=G("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 Pz=G("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 Iz=G("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 Lz=G("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 Dz=G("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 Oz=G("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 Rz=G("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 Fz=G("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 zz=G("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 Bz=G("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 RE=G("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $z=G("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 q1=G("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 qz=G("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 Uz=G("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 Vz=G("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 Hz=G("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 Wz=G("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 Gz=G("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 U1=G("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 Kz=G("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 Zz=G("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 af=G("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 nw=G("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 aw=G("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 Yz=G("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 Xz=G("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 Qz=G("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 Jz=G("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 e7=G("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 t7=G("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 s7=G("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 r7=G("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 n7=G("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 a7=G("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 i7=G("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 o7=G("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 l7=G("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 c7=G("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 d7=G("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 u7=G("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 Z4=G("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 h7=G("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 m7=G("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 p7=G("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 f7=G("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 g7=G("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 x7=G("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 y7=G("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 iw=G("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 v7=G("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 _7=G("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 b7=G("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 w7=G("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 j7=G("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 k7=G("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 N7=G("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 S7=G("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 C7=G("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 M7=G("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 nu=G("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 T7=G("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 A7=G("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 E7=G("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 P7=G("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 I7=G("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 L7=G("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 D7=G("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 O7=G("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 R7=G("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 F7=G("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 FE=G("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 z7=G("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 Cg=G("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 B7=G("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 $7=G("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 q7=G("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 Y4=G("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 U7=G("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 V7=G("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 ow=G("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 H7=G("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 W7=G("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 G7=G("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 zE=G("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 K7=G("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 Z7=G("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 Y7=G("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 X7=G("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 Zu=G("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 Q7=G("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 J7=G("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 eB=G("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 tB=G("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 sB=G("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 _a=G("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 Uk=G("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 rB=G("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 nB=G("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 aB=G("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 iB=G("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 oB=G("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 Lh=G("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 lB=G("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 cB=G("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 dB=G("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 uB=G("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 hB=G("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 mB=G("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 BE=G("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 pB=G("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 jc=G("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 fB=G("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 gB=G("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 xB=G("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 yB=G("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 $E=G("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 vB=G("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 V1=G("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 _B=G("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 bB=G("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 wB=G("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 jB=G("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 kB=G("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 nn=G("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 NB=G("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 Mg=G("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 SB=G("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 CB=G("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 MB=G("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 TB=G("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 AB=G("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 lw=G("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 EB=G("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 PB=G("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 IB=G("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 LB=G("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 DB=G("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 OB=G("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 RB=G("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 FB=G("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 zB=G("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 BB=G("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 $B=G("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 qB=G("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 UB=G("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 cw=G("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 dw=G("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 VB=G("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 HB=G("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 WB=G("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 uw=G("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 hw=G("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 mw=G("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 GB=G("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 pw=G("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 KB=G("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 ol=G("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 ZB=G("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 fw=G("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 YB=G("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 XB=G("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 gw=G("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 xw=G("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 QB=G("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 yw=G("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 vw=G("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 _w=G("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 JB=G("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 e9=G("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 ma=G("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 t9=G("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 s9=G("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 tl=G("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 r9=G("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 n9=G("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 ec=G("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 ei=G("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 Tg=G("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 a9=G("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 i9=G("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 o9=G("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 l9=G("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 c9=G("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 d9=G("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 u9=G("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 of=G("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 h9=G("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 m9=G("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 p9=G("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 f9=G("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 g9=G("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 Yo=G("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 bw=G("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 ww=G("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 jw=G("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 kw=G("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 Nw=G("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 Sw=G("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 Cw=G("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 Mw=G("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 hi=G("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 Ma=G("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 Tw=G("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 Aw=G("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 Ew=G("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 Pw=G("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 x9=G("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 Iw=G("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 y9=G("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 v9=G("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 _9=G("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 b9=G("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 w9=G("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 j9=G("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 k9=G("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 Lw=G("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 Qy=G("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 Dw=G("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 N9=G("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 Ow=G("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 Rw=G("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 Fw=G("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 zw=G("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 mm=G("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 Bw=G("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 $w=G("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 qw=G("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 S9=G("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 Uw=G("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 Vw=G("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 Hw=G("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 bc=G("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 qc=G("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 C9=G("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 M9=G("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 T9=G("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 X4=G("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 A9=G("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 qE=G("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 E9=G("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 P9=G("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 Ww=G("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 Gw=G("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 I9=G("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 L9=G("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 D9=G("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 O9=G("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 R9=G("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 F9=G("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 z9=G("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 B9=G("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 $9=G("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 q9=G("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 U9=G("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 V9=G("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 H9=G("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 W9=G("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 G9=G("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 K9=G("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 Z9=G("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 Y9=G("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 X9=G("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 Tn=G("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 Q9=G("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 J9=G("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 Kw=G("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 e$=G("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 t$=G("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 s$=G("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 r$=G("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 n$=G("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 a$=G("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 i$=G("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 o$=G("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 l$=G("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 c$=G("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 d$=G("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 u$=G("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 Zw=G("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 h$=G("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 m$=G("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 l0=G("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 p$=G("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 Yw=G("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 Vk=G("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 f$=G("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 g$=G("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 Hk=G("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 x$=G("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 UE=G("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 Xw=G("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 Qw=G("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 y$=G("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 v$=G("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 _$=G("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 b$=G("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 w$=G("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 j$=G("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 k$=G("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 N$=G("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 S$=G("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 Jw=G("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 Wk=G("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 C$=G("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 M$=G("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 T$=G("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 A$=G("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 E$=G("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 P$=G("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 I$=G("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 L$=G("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 D$=G("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 Ni=G("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 O$=G("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 R$=G("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 F$=G("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 z$=G("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 B$=G("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 $$=G("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 q$=G("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 U$=G("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 V$=G("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 H$=G("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 W$=G("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 G$=G("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 cp=G("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 K$=G("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 Z$=G("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 Y$=G("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 X$=G("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 Dh=G("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 Q$=G("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 J$=G("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 eq=G("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 tq=G("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 sq=G("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 rq=G("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 nq=G("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 aq=G("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 iq=G("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 oq=G("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 lq=G("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 cq=G("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 e2=G("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 dq=G("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 uq=G("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 hq=G("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 mq=G("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 pq=G("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 fq=G("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 gq=G("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 xq=G("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 yq=G("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 vq=G("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 _q=G("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 bq=G("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 wq=G("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 jq=G("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 kq=G("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 Nq=G("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 Sq=G("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 Cq=G("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 Mq=G("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 Uc=G("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 Tq=G("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 Aq=G("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 g0=G("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 Eq=G("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 Ei=G("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 Pq=G("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 Iq=G("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 Lq=G("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 Dq=G("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 Oq=G("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 zx=G("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 Rq=G("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 Fq=G("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 zq=G("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 Bq=G("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 $q=G("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 qq=G("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 t2=G("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 Uq=G("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 Vq=G("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 Hq=G("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 Q4=G("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 xg=G("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 Xp=G("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 Wq=G("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 Gq=G("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 Kq=G("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 Zq=G("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 Yq=G("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 Xq=G("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 Qq=G("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 un=G("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 Jq=G("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 Nm=G("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 Na=G("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 Fd=G("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 eU=G("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 tU=G("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 sU=G("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 rU=G("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 nU=G("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 aU=G("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 iU=G("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 oU=G("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 lU=G("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 cU=G("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 s2=G("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 dU=G("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 uU=G("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 hU=G("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 r2=G("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 n2=G("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 a2=G("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 i2=G("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 mU=G("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 pU=G("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 fU=G("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 gU=G("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 xU=G("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 o2=G("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 yU=G("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 vU=G("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 _U=G("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 bU=G("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 H1=G("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 wU=G("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 jU=G("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 kU=G("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 NU=G("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 SU=G("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 CU=G("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 MU=G("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 TU=G("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 AU=G("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 EU=G("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 PU=G("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 l2=G("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 c2=G("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 IU=G("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 LU=G("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 DU=G("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 OU=G("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 RU=G("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 FU=G("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 zU=G("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 x0=G("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 VE=G("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 BU=G("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 $U=G("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 Un=G("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 qU=G("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 UU=G("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 VU=G("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 HU=G("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 WU=G("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 GU=G("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 KU=G("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 ZU=G("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 YU=G("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 XU=G("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 QU=G("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 J4=G("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 JU=G("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 eu=G("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 eV=G("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 y0=G("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 tV=G("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 sV=G("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 rV=G("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 nV=G("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 aV=G("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 iV=G("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 oV=G("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 lV=G("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 v0=G("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 cV=G("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 dp=G("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 dV=G("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 uV=G("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 hV=G("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 W1=G("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 mV=G("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 pV=G("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 fV=G("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 gV=G("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 xV=G("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 wg=G("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 yV=G("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 vV=G("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 _V=G("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 bV=G("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 wV=G("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 jV=G("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 kV=G("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 NV=G("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 SV=G("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 d2=G("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 CV=G("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 MV=G("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 TV=G("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 AV=G("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 EV=G("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 PV=G("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 IV=G("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 LV=G("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 DV=G("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 OV=G("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 RV=G("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 Oh=G("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 FV=G("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 u2=G("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 zV=G("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 BV=G("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 $V=G("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 qV=G("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 UV=G("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 VV=G("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 HV=G("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 WV=G("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 GV=G("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 KV=G("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 ZV=G("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 YV=G("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 XV=G("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 QV=G("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 JV=G("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 eH=G("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 tH=G("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 sH=G("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 rH=G("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 nH=G("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 aH=G("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 iH=G("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 oH=G("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 lH=G("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 cH=G("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 dH=G("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 uH=G("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 hH=G("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 mH=G("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 Gk=G("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 uo=G("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 pH=G("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 fH=G("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 h2=G("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 gH=G("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 xH=G("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 yH=G("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 vH=G("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 _H=G("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 bH=G("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 wH=G("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 jH=G("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 kH=G("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 NH=G("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 SH=G("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 CH=G("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 MH=G("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 TH=G("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 AH=G("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 EH=G("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 PH=G("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 up=G("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 IH=G("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 LH=G("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 Yu=G("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 DH=G("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 OH=G("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 m2=G("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 RH=G("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 p2=G("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 Ym=G("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 FH=G("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 Rh=G("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 zH=G("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 BH=G("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 $H=G("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 qH=G("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 UH=G("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 VH=G("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 HH=G("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 f2=G("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 WH=G("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 GH=G("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 HE=G("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 KH=G("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 ZH=G("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 YH=G("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 WE=G("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 XH=G("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 e5=G("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 QH=G("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 JH=G("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 GE=G("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 KE=G("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 eW=G("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 tW=G("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 sW=G("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 rW=G("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 nW=G("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 aW=G("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 iW=G("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 oW=G("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 lW=G("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 cW=G("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 dW=G("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 uW=G("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 Oi=G("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 hW=G("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 mW=G("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 pW=G("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 t5=G("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 fW=G("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 gW=G("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 xW=G("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 yW=G("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 vW=G("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 _W=G("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 bW=G("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 Hn=G("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 g2=G("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 x2=G("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 wW=G("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 jW=G("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 kW=G("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 NW=G("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 SW=G("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 _0=G("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 CW=G("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 MW=G("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 Xo=G("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 TW=G("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 AW=G("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 EW=G("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 y2=G("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 v2=G("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 PW=G("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 IW=G("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 ZE=G("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 LW=G("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 zd=G("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 s5=G("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 DW=G("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 OW=G("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 RW=G("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 FW=G("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 Bx=G("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 Kk=G("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 zW=G("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 Sm=G("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 BW=G("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 $W=G("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 qW=G("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 UW=G("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 VW=G("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 HW=G("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 WW=G("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 GW=G("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 KW=G("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 ZW=G("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 YW=G("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 XW=G("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 QW=G("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 _2=G("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 JW=G("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 eG=G("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 tG=G("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 sG=G("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 rG=G("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 nG=G("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 aG=G("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 Zk=G("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 hp=G("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 iG=G("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 oG=G("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 lG=G("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 Yk=G("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 cG=G("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 dG=G("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 uG=G("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 hG=G("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 mG=G("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 r5=G("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 n5=G("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 pG=G("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 fG=G("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 G1=G("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 gG=G("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 Al=G("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 Po=G("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 Cm=G("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 xG=G("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 yG=G("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 vG=G("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 _G=G("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 bG=G("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 wG=G("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 jG=G("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 b0=G("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 kG=G("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 NG=G("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 SG=G("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 CG=G("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 MG=G("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 TG=G("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 AG=G("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 Fh=G("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 Rs=G("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 EG=G("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 PG=G("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 IG=G("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 LG=G("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 YE=G("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 b2=G("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 DG=G("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 w2=G("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 Pu=G("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 a5=G("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 i5=G("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 OG=G("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 RG=G("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 FG=G("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 zG=G("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 BG=G("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 $G=G("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 qG=G("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 UG=G("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 VG=G("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 HG=G("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 WG=G("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 XE=G("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 Ar=G("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 GG=G("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 KG=G("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 ZG=G("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 YG=G("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 XG=G("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 QG=G("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 JG=G("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 eK=G("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 tK=G("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 sK=G("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 rK=G("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 nK=G("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 Pi=G("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 aK=G("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 iK=G("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 oK=G("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 lK=G("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 QE=G("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 w0=G("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 cK=G("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 Ag=G("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 dK=G("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 uK=G("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 JE=G("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 hK=G("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 mK=G("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 pK=G("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 o5=G("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 fK=G("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 gK=G("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 xK=G("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 eP=G("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 yK=G("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 vK=G("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 _K=G("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 mc=G("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 bK=G("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 wK=G("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 jK=G("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 kK=G("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 NK=G("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 SK=G("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 tP=G("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 CK=G("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 l5=G("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 sP=G("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 MK=G("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 TK=G("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 AK=G("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 EK=G("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 PK=G("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 ho=G("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 IK=G("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 LK=G("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 j2=G("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 rP=G("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 DK=G("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 OK=G("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 RK=G("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 FK=G("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 zK=G("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 BK=G("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 $K=G("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 qK=G("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 K1=G("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 UK=G("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 VK=G("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 HK=G("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 WK=G("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 GK=G("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 KK=G("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 ZK=G("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 YK=G("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 XK=G("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 QK=G("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 JK=G("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 eZ=G("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 Xk=G("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 tZ=G("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 sZ=G("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 rZ=G("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 nZ=G("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 aZ=G("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 iZ=G("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 oZ=G("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 Z1=G("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 ym=G("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 lZ=G("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 k2=G("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 cZ=G("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 dZ=G("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 uZ=G("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 hZ=G("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 mZ=G("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 pZ=G("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 fZ=G("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 gZ=G("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 xZ=G("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 yZ=G("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 vZ=G("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 _Z=G("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 bZ=G("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 wZ=G("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 jZ=G("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 kZ=G("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 NZ=G("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 SZ=G("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 CZ=G("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 MZ=G("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 nP=G("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 TZ=G("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 j0=G("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 AZ=G("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 EZ=G("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 PZ=G("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 IZ=G("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 LZ=G("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 DZ=G("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 OZ=G("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 RZ=G("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 FZ=G("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 N2=G("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 zZ=G("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 S2=G("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 C2=G("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 BZ=G("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 $Z=G("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 qZ=G("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 UZ=G("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 VZ=G("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 HZ=G("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 WZ=G("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 GZ=G("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 KZ=G("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 ZZ=G("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 YZ=G("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 XZ=G("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=G("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 QZ=G("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 JZ=G("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 M2=G("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 eY=G("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 El=G("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 tY=G("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 T2=G("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 sY=G("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 rY=G("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 A2=G("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 E2=G("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 P2=G("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 I2=G("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 nY=G("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 L2=G("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 aY=G("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 iY=G("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 oY=G("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 D2=G("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 lY=G("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 cY=G("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 dY=G("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 uY=G("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 Jy=G("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 Qk=G("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 hY=G("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 mY=G("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 bd=G("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 mp=G("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 pY=G("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 fY=G("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 Xv=G("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 gY=G("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 Jk=G("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 Cx=G("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 xY=G("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 yY=G("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 vY=G("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 Ga=G("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 _Y=G("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 c5=G("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 bY=G("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 wY=G("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 jY=G("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 kY=G("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 NY=G("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 SY=G("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 CY=G("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 MY=G("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 ga=G("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 TY=G("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 AY=G("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 EY=G("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 PY=G("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 IY=G("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 LY=G("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 DY=G("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 OY=G("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 RY=G("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 FY=G("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 zY=G("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 aP=G("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 Y1=G("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 BY=G("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 $Y=G("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 qY=G("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 UY=G("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 VY=G("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 dl=G("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 HY=G("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 O2=G("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 iP=G("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 Ys=G("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 WY=G("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 GY=G("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 KY=G("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 ZY=G("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 YY=G("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 XY=G("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 QY=G("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 JY=G("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 eX=G("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 oP=G("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 lf=G("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 tX=G("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 lP=G("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 sX=G("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 rX=G("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 nX=G("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 aX=G("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 eN=G("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 d5=G("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 iX=G("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 oX=G("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 lX=G("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 cX=G("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 dX=G("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 uX=G("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 tN=G("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 hX=G("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 mX=G("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 pX=G("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 fX=G("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 gX=G("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 xX=G("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 yX=G("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 vX=G("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 _X=G("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 bX=G("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 wX=G("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 jX=G("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 kX=G("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 NX=G("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 R2=G("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 SX=G("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 CX=G("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 MX=G("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 TX=G("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 AX=G("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 u5=G("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 EX=G("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 PX=G("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 IX=G("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 Ao=G("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 LX=G("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 DX=G("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 OX=G("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 RX=G("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 FX=G("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 cP=G("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 zX=G("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 BX=G("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 $X=G("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 dP=G("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 qX=G("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 UX=G("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 $x=G("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 VX=G("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 HX=G("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 F2=G("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 WX=G("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 k0=G("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 GX=G("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 uP=G("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 KX=G("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 ZX=G("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 YX=G("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 z2=G("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 B2=G("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 XX=G("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 QX=G("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 JX=G("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 eQ=G("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 tQ=G("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 sQ=G("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 rQ=G("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 nQ=G("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 aQ=G("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 iQ=G("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 oQ=G("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 zh=G("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 $2=G("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 lQ=G("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 cQ=G("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 dQ=G("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 uQ=G("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 hQ=G("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 mQ=G("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 pQ=G("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 fQ=G("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 gQ=G("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 xQ=G("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 yQ=G("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 vQ=G("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 _Q=G("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 bQ=G("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 wQ=G("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 jQ=G("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 kQ=G("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 NQ=G("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 SQ=G("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 CQ=G("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 MQ=G("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 xn=G("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 TQ=G("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 q2=G("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 AQ=G("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 Pa=G("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 EQ=G("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 PQ=G("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 IQ=G("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 LQ=G("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 DQ=G("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 OQ=G("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 hP=G("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 Pl=G("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 RQ=G("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nd=G("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 mP=G("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 FQ=G("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 zQ=G("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 BQ=G("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 $Q=G("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 pP=G("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 qQ=G("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 UQ=G("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 VQ=G("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 HQ=G("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 WQ=G("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 GQ=G("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 U2=G("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 Xu=G("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 KQ=G("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 ZQ=G("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 YQ=G("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 qx=G("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 XQ=G("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 vm=G("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 QQ=G("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 JQ=G("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 eJ=G("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 tJ=G("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 sN=G("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 sJ=G("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 rJ=G("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 nJ=G("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 aJ=G("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 iJ=G("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 oJ=G("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 lJ=G("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 cJ=G("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 dJ=G("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 uJ=G("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 hJ=G("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 mJ=G("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 pJ=G("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 fJ=G("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 gJ=G("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 xJ=G("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 fP=G("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 V2=G("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 yJ=G("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 vJ=G("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 N0=G("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 _J=G("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 bJ=G("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 wJ=G("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 S1=G("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 jJ=G("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 kJ=G("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 NJ=G("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 SJ=G("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 CJ=G("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 gn=G("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 MJ=G("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 TJ=G("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 AJ=G("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 EJ=G("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 PJ=G("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 IJ=G("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 LJ=G("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 DJ=G("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 H2=G("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 W2=G("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 G2=G("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 K2=G("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 Z2=G("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 Y2=G("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 X2=G("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 Q2=G("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 J2=G("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 ej=G("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 tj=G("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 sj=G("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 rj=G("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 nj=G("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 aj=G("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 xx=G("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 e0=G("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 ij=G("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 oj=G("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 lj=G("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 cj=G("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 dj=G("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 uj=G("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 OJ=G("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 RJ=G("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 hj=G("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 mj=G("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 pj=G("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 fj=G("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 gj=G("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 xj=G("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 yj=G("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 vj=G("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 _j=G("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 bj=G("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 wj=G("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 jj=G("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 kj=G("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 Nj=G("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 Sj=G("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 Pc=G("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 Cj=G("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 Mj=G("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 Tj=G("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 Aj=G("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 Ej=G("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 Pj=G("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 FJ=G("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 Ij=G("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 Lj=G("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 Dj=G("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 Oj=G("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 Rj=G("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 zJ=G("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 BJ=G("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 Fj=G("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 zj=G("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 Bj=G("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 $j=G("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 Ux=G("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 $J=G("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 qJ=G("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 UJ=G("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 VJ=G("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 HJ=G("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 Gn=G("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 WJ=G("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 GJ=G("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 KJ=G("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 ZJ=G("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 YJ=G("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 XJ=G("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 QJ=G("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 JJ=G("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 eee=G("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 tee=G("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 see=G("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 ree=G("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 nee=G("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 aee=G("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 X1=G("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 iee=G("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 oee=G("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 lee=G("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 cee=G("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 dee=G("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 uee=G("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 hee=G("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 mee=G("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 pee=G("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 h5=G("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 fee=G("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 gee=G("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 xee=G("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 yee=G("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 vee=G("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 _ee=G("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 gP=G("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 bee=G("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 wee=G("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 jee=G("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 pp=G("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 kee=G("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 Nee=G("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 See=G("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 Cee=G("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 Mee=G("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 Tee=G("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 Aee=G("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 Mm=G("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 Eee=G("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 Pee=G("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 Iee=G("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 Lee=G("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 qj=G("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 Dee=G("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 Oee=G("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 Ree=G("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 Fee=G("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 zee=G("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 Bee=G("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 Uj=G("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 $ee=G("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 qee=G("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 Uee=G("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 Vee=G("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 Hee=G("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 xP=G("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 lu=G("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 Wee=G("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 Gee=G("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 Kee=G("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 Zee=G("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 Yee=G("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 Xee=G("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 yP=G("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 Qee=G("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 Jee=G("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 ete=G("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 tte=G("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 ste=G("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 rte=G("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 nte=G("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 ate=G("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 ite=G("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 ote=G("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 lte=G("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 cte=G("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 dte=G("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 ute=G("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 hte=G("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 mte=G("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 pte=G("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 fte=G("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 gte=G("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 Vj=G("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 Cr=G("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 xte=G("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 yte=G("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 Hj=G("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 Q1=G("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 vte=G("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 _te=G("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 rN=G("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 bte=G("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 Vc=G("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 jh=G("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 wte=G("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 jte=G("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 so=G("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 vP=G("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 kte=G("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 Nte=G("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 Wj=G("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 Ste=G("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 Cte=G("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 Mte=G("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 Tte=G("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 Ate=G("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 Ete=G("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 Pte=G("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 Ite=G("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 Lte=G("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 Dte=G("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 m5=G("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 Ote=G("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 Rte=G("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 Fte=G("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 Gj=G("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 zte=G("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 nN=G("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 Bte=G("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 xi=G("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 $te=G("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 J1=G("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 _P=G("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 bP=G("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 qte=G("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 pc=G("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 Kj=G("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 Zj=G("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 Yj=G("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 Ute=G("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 Xj=G("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 Vte=G("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 Qj=G("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 Jj=G("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 Hte=G("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 Wte=G("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 mo=G("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 ek=G("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 xr=G("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 tk=G("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 sk=G("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 Gte=G("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 wP=G("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 Kte=G("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 Zte=G("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 Yte=G("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 Xte=G("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 Qte=G("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 Jte=G("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=G("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 ese=G("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 tse=G("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 sse=G("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 rse=G("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 nse=G("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 ase=G("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 ise=G("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 ose=G("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 lse=G("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 cse=G("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 dse=G("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 rk=G("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 jP=G("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 use=G("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 t0=G("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 hse=G("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 mse=G("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 pse=G("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 fse=G("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 gse=G("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 xse=G("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 yse=G("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 vse=G("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 _se=G("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 bse=G("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 wse=G("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 jse=G("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 kse=G("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 Nse=G("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 Sse=G("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 Cse=G("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 Mse=G("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 Tse=G("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 Ase=G("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 Ese=G("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 Pse=G("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 Ise=G("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 Lse=G("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 Dse=G("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 Ose=G("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 Vx=G("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 Vr=G("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 Rse=G("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 Fse=G("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 Tm=G("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 p5=G("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 f5=G("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 uot=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:ER,AArrowUp:PR,ALargeSmall:IR,Accessibility:LR,Activity:Fx,AirVent:DR,Airplay:OR,AlarmClock:FR,AlarmClockCheck:Gb,AlarmClockMinus:Kb,AlarmClockOff:RR,AlarmClockPlus:Zb,AlarmSmoke:zR,Album:BR,AlignCenter:H4,AlignCenterHorizontal:$R,AlignCenterVertical:qR,AlignEndHorizontal:UR,AlignEndVertical:VR,AlignHorizontalDistributeCenter:HR,AlignHorizontalDistributeEnd:WR,AlignHorizontalDistributeStart:GR,AlignHorizontalJustifyCenter:KR,AlignHorizontalJustifyEnd:ZR,AlignHorizontalJustifyStart:YR,AlignHorizontalSpaceAround:XR,AlignHorizontalSpaceBetween:QR,AlignJustify:JR,AlignLeft:W4,AlignRight:G4,AlignStartHorizontal:eF,AlignStartVertical:tF,AlignVerticalDistributeCenter:sF,AlignVerticalDistributeEnd:rF,AlignVerticalDistributeStart:nF,AlignVerticalJustifyCenter:aF,AlignVerticalJustifyEnd:iF,AlignVerticalJustifyStart:oF,AlignVerticalSpaceAround:lF,AlignVerticalSpaceBetween:cF,Ambulance:dF,Ampersand:uF,Ampersands:hF,Amphora:mF,Anchor:pF,Angry:fF,Annoyed:gF,Antenna:xF,Anvil:yF,Aperture:vF,AppWindow:DE,AppWindowMac:_F,Apple:bF,Archive:K4,ArchiveRestore:OE,ArchiveX:wF,Armchair:jF,ArrowBigDown:NF,ArrowBigDownDash:kF,ArrowBigLeft:CF,ArrowBigLeftDash:SF,ArrowBigRight:TF,ArrowBigRightDash:MF,ArrowBigUp:EF,ArrowBigUpDash:AF,ArrowDown:Ku,ArrowDown01:PF,ArrowDown10:IF,ArrowDownAZ:Yb,ArrowDownFromLine:LF,ArrowDownLeft:DF,ArrowDownNarrowWide:OF,ArrowDownRight:RF,ArrowDownToDot:FF,ArrowDownToLine:zF,ArrowDownUp:BF,ArrowDownWideNarrow:Xb,ArrowDownZA:Qb,ArrowLeft:Ba,ArrowLeftFromLine:$F,ArrowLeftRight:qF,ArrowLeftToLine:UF,ArrowRight:Ai,ArrowRightFromLine:VF,ArrowRightLeft:p0,ArrowRightToLine:HF,ArrowUp:Rd,ArrowUp01:WF,ArrowUp10:GF,ArrowUpAZ:Jb,ArrowUpDown:$c,ArrowUpFromDot:KF,ArrowUpFromLine:ZF,ArrowUpLeft:YF,ArrowUpNarrowWide:ew,ArrowUpRight:XF,ArrowUpToLine:QF,ArrowUpWideNarrow:JF,ArrowUpZA:tw,ArrowsUpFromLine:ez,Asterisk:tz,AtSign:sz,Atom:rz,AudioLines:nz,AudioWaveform:az,Award:dc,Axe:iz,Axis3d:sw,Baby:oz,Backpack:lz,Badge:kz,BadgeAlert:cz,BadgeCent:dz,BadgeCheck:rw,BadgeDollarSign:uz,BadgeEuro:hz,BadgeHelp:mz,BadgeIndianRupee:pz,BadgeInfo:fz,BadgeJapaneseYen:gz,BadgeMinus:xz,BadgePercent:yz,BadgePlus:vz,BadgePoundSterling:_z,BadgeRussianRuble:bz,BadgeSwissFranc:wz,BadgeX:jz,BaggageClaim:Nz,Ban:Sz,Banana:Cz,Bandage:Mz,Banknote:Tz,Barcode:Az,Baseline:Ez,Bath:f0,Battery:Rz,BatteryCharging:Pz,BatteryFull:Iz,BatteryLow:Lz,BatteryMedium:Dz,BatteryWarning:Oz,Beaker:Fz,Bean:Bz,BeanOff:zz,Bed:q1,BedDouble:RE,BedSingle:$z,Beef:qz,Beer:Vz,BeerOff:Uz,Bell:af,BellDot:Hz,BellElectric:Wz,BellMinus:Gz,BellOff:U1,BellPlus:Kz,BellRing:Zz,BetweenHorizontalEnd:nw,BetweenHorizontalStart:aw,BetweenVerticalEnd:Yz,BetweenVerticalStart:Xz,BicepsFlexed:Qz,Bike:Jz,Binary:e7,Binoculars:t7,Biohazard:s7,Bird:r7,Bitcoin:n7,Blend:a7,Blinds:i7,Blocks:o7,Bluetooth:u7,BluetoothConnected:l7,BluetoothOff:c7,BluetoothSearching:d7,Bold:Z4,Bolt:h7,Bomb:m7,Bone:p7,Book:O7,BookA:f7,BookAudio:g7,BookCheck:x7,BookCopy:y7,BookDashed:iw,BookDown:v7,BookHeadphones:_7,BookHeart:b7,BookImage:w7,BookKey:j7,BookLock:k7,BookMarked:N7,BookMinus:S7,BookOpen:nu,BookOpenCheck:C7,BookOpenText:M7,BookPlus:T7,BookText:A7,BookType:E7,BookUp:I7,BookUp2:P7,BookUser:L7,BookX:D7,Bookmark:Cg,BookmarkCheck:R7,BookmarkMinus:F7,BookmarkPlus:FE,BookmarkX:z7,BoomBox:B7,Bot:Y4,BotMessageSquare:$7,BotOff:q7,Box:U7,Boxes:V7,Braces:ow,Brackets:H7,Brain:zE,BrainCircuit:W7,BrainCog:G7,BrickWall:K7,Briefcase:Zu,BriefcaseBusiness:Z7,BriefcaseConveyorBelt:Y7,BriefcaseMedical:X7,BringToFront:Q7,Brush:J7,Bug:sB,BugOff:eB,BugPlay:tB,Building:Uk,Building2:_a,Bus:nB,BusFront:rB,Cable:iB,CableCar:aB,Cake:Lh,CakeSlice:oB,Calculator:lB,Calendar:nn,Calendar1:cB,CalendarArrowDown:dB,CalendarArrowUp:uB,CalendarCheck:mB,CalendarCheck2:hB,CalendarClock:BE,CalendarCog:pB,CalendarDays:jc,CalendarFold:fB,CalendarHeart:gB,CalendarMinus:yB,CalendarMinus2:xB,CalendarOff:$E,CalendarPlus:V1,CalendarPlus2:vB,CalendarRange:_B,CalendarSearch:bB,CalendarSync:wB,CalendarX:kB,CalendarX2:jB,Camera:Mg,CameraOff:NB,Candy:MB,CandyCane:SB,CandyOff:CB,Cannabis:TB,Captions:lw,CaptionsOff:AB,Car:IB,CarFront:EB,CarTaxiFront:PB,Caravan:LB,Carrot:DB,CaseLower:OB,CaseSensitive:RB,CaseUpper:FB,CassetteTape:zB,Cast:BB,Castle:$B,Cat:qB,Cctv:UB,ChartArea:cw,ChartBar:uw,ChartBarBig:dw,ChartBarDecreasing:VB,ChartBarIncreasing:HB,ChartBarStacked:WB,ChartCandlestick:hw,ChartColumn:ol,ChartColumnBig:mw,ChartColumnDecreasing:GB,ChartColumnIncreasing:pw,ChartColumnStacked:KB,ChartGantt:ZB,ChartLine:fw,ChartNetwork:YB,ChartNoAxesColumn:xw,ChartNoAxesColumnDecreasing:XB,ChartNoAxesColumnIncreasing:gw,ChartNoAxesCombined:QB,ChartNoAxesGantt:yw,ChartPie:vw,ChartScatter:_w,ChartSpline:JB,Check:ma,CheckCheck:e9,ChefHat:t9,Cherry:s9,ChevronDown:tl,ChevronFirst:r9,ChevronLast:n9,ChevronLeft:ec,ChevronRight:ei,ChevronUp:Tg,ChevronsDown:i9,ChevronsDownUp:a9,ChevronsLeft:c9,ChevronsLeftRight:l9,ChevronsLeftRightEllipsis:o9,ChevronsRight:u9,ChevronsRightLeft:d9,ChevronsUp:h9,ChevronsUpDown:of,Chrome:m9,Church:p9,Cigarette:g9,CigaretteOff:f9,Circle:qc,CircleAlert:Yo,CircleArrowDown:bw,CircleArrowLeft:ww,CircleArrowOutDownLeft:jw,CircleArrowOutDownRight:kw,CircleArrowOutUpLeft:Nw,CircleArrowOutUpRight:Sw,CircleArrowRight:Cw,CircleArrowUp:Mw,CircleCheck:Ma,CircleCheckBig:hi,CircleChevronDown:Tw,CircleChevronLeft:Aw,CircleChevronRight:Ew,CircleChevronUp:Pw,CircleDashed:x9,CircleDivide:Iw,CircleDollarSign:y9,CircleDot:_9,CircleDotDashed:v9,CircleEllipsis:b9,CircleEqual:w9,CircleFadingArrowUp:j9,CircleFadingPlus:k9,CircleGauge:Lw,CircleHelp:Qy,CircleMinus:Dw,CircleOff:N9,CircleParking:Rw,CircleParkingOff:Ow,CirclePause:Fw,CirclePercent:zw,CirclePlay:mm,CirclePlus:Bw,CirclePower:$w,CircleSlash:S9,CircleSlash2:qw,CircleStop:Uw,CircleUser:Hw,CircleUserRound:Vw,CircleX:bc,CircuitBoard:C9,Citrus:M9,Clapperboard:T9,Clipboard:O9,ClipboardCheck:X4,ClipboardCopy:A9,ClipboardList:qE,ClipboardMinus:E9,ClipboardPaste:P9,ClipboardPen:Gw,ClipboardPenLine:Ww,ClipboardPlus:I9,ClipboardType:L9,ClipboardX:D9,Clock:Tn,Clock1:R9,Clock10:F9,Clock11:z9,Clock12:B9,Clock2:$9,Clock3:q9,Clock4:U9,Clock5:V9,Clock6:H9,Clock7:W9,Clock8:G9,Clock9:K9,ClockAlert:Z9,ClockArrowDown:Y9,ClockArrowUp:X9,Cloud:h$,CloudAlert:Q9,CloudCog:J9,CloudDownload:Kw,CloudDrizzle:e$,CloudFog:t$,CloudHail:s$,CloudLightning:r$,CloudMoon:a$,CloudMoonRain:n$,CloudOff:i$,CloudRain:l$,CloudRainWind:o$,CloudSnow:c$,CloudSun:u$,CloudSunRain:d$,CloudUpload:Zw,Cloudy:m$,Clover:l0,Club:p$,Code:Vk,CodeXml:Yw,Codepen:f$,Codesandbox:g$,Coffee:Hk,Cog:x$,Coins:UE,Columns2:Xw,Columns3:Qw,Columns4:y$,Combine:v$,Command:_$,Compass:b$,Component:w$,Computer:j$,ConciergeBell:k$,Cone:N$,Construction:S$,Contact:Wk,ContactRound:Jw,Container:C$,Contrast:M$,Cookie:T$,CookingPot:A$,Copy:Ni,CopyCheck:E$,CopyMinus:P$,CopyPlus:I$,CopySlash:L$,CopyX:D$,Copyleft:O$,Copyright:R$,CornerDownLeft:F$,CornerDownRight:z$,CornerLeftDown:B$,CornerLeftUp:$$,CornerRightDown:q$,CornerRightUp:U$,CornerUpLeft:V$,CornerUpRight:H$,Cpu:W$,CreativeCommons:G$,CreditCard:cp,Croissant:K$,Crop:Z$,Cross:Y$,Crosshair:X$,Crown:Dh,Cuboid:Q$,CupSoda:J$,Currency:eq,Cylinder:tq,Dam:sq,Database:aq,DatabaseBackup:rq,DatabaseZap:nq,Delete:iq,Dessert:oq,Diameter:lq,Diamond:uq,DiamondMinus:cq,DiamondPercent:e2,DiamondPlus:dq,Dice1:hq,Dice2:mq,Dice3:pq,Dice4:fq,Dice5:gq,Dice6:xq,Dices:yq,Diff:vq,Disc:jq,Disc2:_q,Disc3:bq,DiscAlbum:wq,Divide:kq,Dna:Sq,DnaOff:Nq,Dock:Cq,Dog:Mq,DollarSign:Uc,Donut:Tq,DoorClosed:Aq,DoorOpen:g0,Dot:Eq,Download:Ei,DraftingCompass:Pq,Drama:Iq,Dribbble:Lq,Drill:Dq,Droplet:Oq,Droplets:zx,Drum:Rq,Drumstick:Fq,Dumbbell:zq,Ear:$q,EarOff:Bq,Earth:t2,EarthLock:qq,Eclipse:Uq,Egg:Q4,EggFried:Vq,EggOff:Hq,Ellipsis:Xp,EllipsisVertical:xg,Equal:Kq,EqualApproximately:Wq,EqualNot:Gq,Eraser:Zq,EthernetPort:Yq,Euro:Xq,Expand:Qq,ExternalLink:un,Eye:Na,EyeClosed:Jq,EyeOff:Nm,Facebook:Fd,Factory:eU,Fan:tU,FastForward:sU,Feather:rU,Fence:nU,FerrisWheel:aU,Figma:iU,File:J4,FileArchive:oU,FileAudio:cU,FileAudio2:lU,FileAxis3d:s2,FileBadge:uU,FileBadge2:dU,FileBox:hU,FileChartColumn:n2,FileChartColumnIncreasing:r2,FileChartLine:a2,FileChartPie:i2,FileCheck:pU,FileCheck2:mU,FileClock:fU,FileCode:xU,FileCode2:gU,FileCog:o2,FileDiff:yU,FileDigit:vU,FileDown:_U,FileHeart:bU,FileImage:H1,FileInput:wU,FileJson:kU,FileJson2:jU,FileKey:SU,FileKey2:NU,FileLock:MU,FileLock2:CU,FileMinus:AU,FileMinus2:TU,FileMusic:EU,FileOutput:PU,FilePen:c2,FilePenLine:l2,FilePlus:LU,FilePlus2:IU,FileQuestion:DU,FileScan:OU,FileSearch:FU,FileSearch2:RU,FileSliders:zU,FileSpreadsheet:x0,FileStack:VE,FileSymlink:BU,FileTerminal:$U,FileText:Un,FileType:UU,FileType2:qU,FileUp:VU,FileUser:HU,FileVideo:GU,FileVideo2:WU,FileVolume:ZU,FileVolume2:KU,FileWarning:YU,FileX:QU,FileX2:XU,Files:JU,Film:eu,Filter:y0,FilterX:eV,Fingerprint:tV,FireExtinguisher:sV,Fish:aV,FishOff:rV,FishSymbol:nV,Flag:v0,FlagOff:iV,FlagTriangleLeft:oV,FlagTriangleRight:lV,Flame:dp,FlameKindling:cV,Flashlight:uV,FlashlightOff:dV,FlaskConical:W1,FlaskConicalOff:hV,FlaskRound:mV,FlipHorizontal:fV,FlipHorizontal2:pV,FlipVertical:xV,FlipVertical2:gV,Flower:yV,Flower2:wg,Focus:vV,FoldHorizontal:_V,FoldVertical:bV,Folder:KV,FolderArchive:wV,FolderCheck:jV,FolderClock:kV,FolderClosed:NV,FolderCode:SV,FolderCog:d2,FolderDot:CV,FolderDown:MV,FolderGit:AV,FolderGit2:TV,FolderHeart:EV,FolderInput:PV,FolderKanban:IV,FolderKey:LV,FolderLock:DV,FolderMinus:OV,FolderOpen:Oh,FolderOpenDot:RV,FolderOutput:FV,FolderPen:u2,FolderPlus:zV,FolderRoot:BV,FolderSearch:qV,FolderSearch2:$V,FolderSymlink:UV,FolderSync:VV,FolderTree:HV,FolderUp:WV,FolderX:GV,Folders:ZV,Footprints:YV,Forklift:XV,Forward:QV,Frame:JV,Framer:eH,Frown:tH,Fuel:sH,Fullscreen:rH,GalleryHorizontal:aH,GalleryHorizontalEnd:nH,GalleryThumbnails:iH,GalleryVertical:lH,GalleryVerticalEnd:oH,Gamepad:dH,Gamepad2:cH,Gauge:uH,Gavel:hH,Gem:mH,Ghost:Gk,Gift:uo,GitBranch:fH,GitBranchPlus:pH,GitCommitHorizontal:h2,GitCommitVertical:gH,GitCompare:yH,GitCompareArrows:xH,GitFork:vH,GitGraph:_H,GitMerge:bH,GitPullRequest:CH,GitPullRequestArrow:wH,GitPullRequestClosed:jH,GitPullRequestCreate:NH,GitPullRequestCreateArrow:kH,GitPullRequestDraft:SH,Github:MH,Gitlab:TH,GlassWater:AH,Glasses:EH,Globe:up,GlobeLock:PH,Goal:IH,Grab:LH,GraduationCap:Yu,Grape:DH,Grid2x2:p2,Grid2x2Check:OH,Grid2x2Plus:m2,Grid2x2X:RH,Grid3x3:Ym,Grip:zH,GripHorizontal:FH,GripVertical:Rh,Group:BH,Guitar:$H,Ham:qH,Hammer:UH,Hand:HE,HandCoins:VH,HandHeart:HH,HandHelping:f2,HandMetal:WH,HandPlatter:GH,Handshake:KH,HardDrive:WE,HardDriveDownload:ZH,HardDriveUpload:YH,HardHat:XH,Hash:e5,Haze:QH,HdmiPort:JH,Heading:nW,Heading1:GE,Heading2:KE,Heading3:eW,Heading4:tW,Heading5:sW,Heading6:rW,HeadphoneOff:aW,Headphones:iW,Headset:oW,Heart:Oi,HeartCrack:lW,HeartHandshake:cW,HeartOff:dW,HeartPulse:uW,Heater:hW,Hexagon:mW,Highlighter:pW,History:t5,Hop:gW,HopOff:fW,Hospital:xW,Hotel:yW,Hourglass:vW,House:Hn,HousePlug:_W,HousePlus:bW,IceCreamBowl:g2,IceCreamCone:x2,IdCard:wW,Image:Xo,ImageDown:jW,ImageMinus:kW,ImageOff:NW,ImagePlay:SW,ImagePlus:_0,ImageUp:CW,ImageUpscale:MW,Images:TW,Import:AW,Inbox:EW,IndentDecrease:y2,IndentIncrease:v2,IndianRupee:PW,Infinity:IW,Info:ZE,InspectionPanel:LW,Instagram:zd,Italic:s5,IterationCcw:DW,IterationCw:OW,JapaneseYen:RW,Joystick:FW,Kanban:Bx,Key:Sm,KeyRound:Kk,KeySquare:zW,Keyboard:qW,KeyboardMusic:BW,KeyboardOff:$W,Lamp:KW,LampCeiling:UW,LampDesk:VW,LampFloor:HW,LampWallDown:WW,LampWallUp:GW,LandPlot:ZW,Landmark:YW,Languages:XW,Laptop:JW,LaptopMinimal:_2,LaptopMinimalCheck:QW,Lasso:tG,LassoSelect:eG,Laugh:sG,Layers:aG,Layers2:rG,Layers3:nG,LayoutDashboard:Zk,LayoutGrid:hp,LayoutList:iG,LayoutPanelLeft:oG,LayoutPanelTop:lG,LayoutTemplate:Yk,Leaf:cG,LeafyGreen:dG,Lectern:uG,LetterText:hG,Library:r5,LibraryBig:mG,LifeBuoy:n5,Ligature:pG,Lightbulb:G1,LightbulbOff:fG,Link:Po,Link2:Al,Link2Off:gG,Linkedin:Cm,List:Fh,ListCheck:xG,ListChecks:yG,ListCollapse:vG,ListEnd:_G,ListFilter:bG,ListMinus:wG,ListMusic:jG,ListOrdered:b0,ListPlus:kG,ListRestart:NG,ListStart:SG,ListTodo:CG,ListTree:MG,ListVideo:TG,ListX:AG,Loader:PG,LoaderCircle:Rs,LoaderPinwheel:EG,Locate:YE,LocateFixed:IG,LocateOff:LG,Lock:Pu,LockKeyhole:DG,LockKeyholeOpen:b2,LockOpen:w2,LogIn:a5,LogOut:i5,Logs:OG,Lollipop:RG,Luggage:FG,Magnet:zG,Mail:Ar,MailCheck:BG,MailMinus:$G,MailOpen:qG,MailPlus:UG,MailQuestion:VG,MailSearch:HG,MailWarning:WG,MailX:XE,Mailbox:GG,Mails:KG,Map:iK,MapPin:Pi,MapPinCheck:YG,MapPinCheckInside:ZG,MapPinHouse:XG,MapPinMinus:JG,MapPinMinusInside:QG,MapPinOff:eK,MapPinPlus:sK,MapPinPlusInside:tK,MapPinX:nK,MapPinXInside:rK,MapPinned:aK,Martini:oK,Maximize:QE,Maximize2:lK,Medal:w0,Megaphone:Ag,MegaphoneOff:cK,Meh:dK,MemoryStick:uK,Menu:JE,Merge:hK,MessageCircle:mc,MessageCircleCode:mK,MessageCircleDashed:pK,MessageCircleHeart:o5,MessageCircleMore:fK,MessageCircleOff:gK,MessageCirclePlus:xK,MessageCircleQuestion:eP,MessageCircleReply:yK,MessageCircleWarning:vK,MessageCircleX:_K,MessageSquare:ho,MessageSquareCode:bK,MessageSquareDashed:wK,MessageSquareDiff:jK,MessageSquareDot:kK,MessageSquareHeart:NK,MessageSquareLock:SK,MessageSquareMore:tP,MessageSquareOff:CK,MessageSquarePlus:l5,MessageSquareQuote:sP,MessageSquareReply:MK,MessageSquareShare:TK,MessageSquareText:AK,MessageSquareWarning:EK,MessageSquareX:PK,MessagesSquare:IK,Mic:rP,MicOff:LK,MicVocal:j2,Microchip:DK,Microscope:OK,Microwave:RK,Milestone:FK,Milk:BK,MilkOff:zK,Minimize:qK,Minimize2:$K,Minus:K1,Monitor:Xk,MonitorCheck:UK,MonitorCog:VK,MonitorDot:HK,MonitorDown:WK,MonitorOff:GK,MonitorPause:KK,MonitorPlay:ZK,MonitorSmartphone:YK,MonitorSpeaker:XK,MonitorStop:QK,MonitorUp:JK,MonitorX:eZ,Moon:sZ,MoonStar:tZ,Mountain:nZ,MountainSnow:rZ,Mouse:lZ,MouseOff:aZ,MousePointer:ym,MousePointer2:iZ,MousePointerBan:oZ,MousePointerClick:Z1,Move:bZ,Move3d:k2,MoveDiagonal:dZ,MoveDiagonal2:cZ,MoveDown:mZ,MoveDownLeft:uZ,MoveDownRight:hZ,MoveHorizontal:pZ,MoveLeft:fZ,MoveRight:gZ,MoveUp:vZ,MoveUpLeft:xZ,MoveUpRight:yZ,MoveVertical:_Z,Music:NZ,Music2:wZ,Music3:jZ,Music4:kZ,Navigation:nP,Navigation2:CZ,Navigation2Off:SZ,NavigationOff:MZ,Network:TZ,Newspaper:j0,Nfc:AZ,Notebook:LZ,NotebookPen:EZ,NotebookTabs:PZ,NotebookText:IZ,NotepadText:OZ,NotepadTextDashed:DZ,Nut:FZ,NutOff:RZ,Octagon:BZ,OctagonAlert:N2,OctagonMinus:zZ,OctagonPause:S2,OctagonX:C2,Omega:$Z,Option:qZ,Orbit:UZ,Origami:VZ,Package:cl,Package2:HZ,PackageCheck:WZ,PackageMinus:GZ,PackageOpen:KZ,PackagePlus:ZZ,PackageSearch:YZ,PackageX:XZ,PaintBucket:QZ,PaintRoller:JZ,Paintbrush:eY,PaintbrushVertical:M2,Palette:El,PanelBottom:rY,PanelBottomClose:tY,PanelBottomDashed:T2,PanelBottomOpen:sY,PanelLeft:I2,PanelLeftClose:A2,PanelLeftDashed:E2,PanelLeftOpen:P2,PanelRight:iY,PanelRightClose:nY,PanelRightDashed:L2,PanelRightOpen:aY,PanelTop:cY,PanelTopClose:oY,PanelTopDashed:D2,PanelTopOpen:lY,PanelsLeftBottom:dY,PanelsRightBottom:uY,PanelsTopLeft:Jy,Paperclip:Qk,Parentheses:hY,ParkingMeter:mY,PartyPopper:bd,Pause:mp,PawPrint:pY,PcCase:fY,Pen:Cx,PenLine:Xv,PenOff:gY,PenTool:Jk,Pencil:Ga,PencilLine:xY,PencilOff:yY,PencilRuler:vY,Pentagon:_Y,Percent:c5,PersonStanding:bY,PhilippinePeso:wY,Phone:ga,PhoneCall:jY,PhoneForwarded:kY,PhoneIncoming:NY,PhoneMissed:SY,PhoneOff:CY,PhoneOutgoing:MY,Pi:TY,Piano:AY,Pickaxe:EY,PictureInPicture:IY,PictureInPicture2:PY,PiggyBank:LY,Pilcrow:RY,PilcrowLeft:DY,PilcrowRight:OY,Pill:zY,PillBottle:FY,Pin:Y1,PinOff:aP,Pipette:BY,Pizza:$Y,Plane:VY,PlaneLanding:qY,PlaneTakeoff:UY,Play:dl,Plug:iP,Plug2:HY,PlugZap:O2,Plus:Ys,Pocket:GY,PocketKnife:WY,Podcast:KY,Pointer:YY,PointerOff:ZY,Popcorn:XY,Popsicle:QY,PoundSterling:JY,Power:oP,PowerOff:eX,Presentation:lf,Printer:lP,PrinterCheck:tX,Projector:sX,Proportions:rX,Puzzle:nX,Pyramid:aX,QrCode:eN,Quote:d5,Rabbit:iX,Radar:oX,Radiation:lX,Radical:cX,Radio:tN,RadioReceiver:dX,RadioTower:uX,Radius:hX,RailSymbol:mX,Rainbow:pX,Rat:fX,Ratio:gX,Receipt:NX,ReceiptCent:xX,ReceiptEuro:yX,ReceiptIndianRupee:vX,ReceiptJapaneseYen:_X,ReceiptPoundSterling:bX,ReceiptRussianRuble:wX,ReceiptSwissFranc:jX,ReceiptText:kX,RectangleEllipsis:R2,RectangleHorizontal:SX,RectangleVertical:CX,Recycle:MX,Redo:u5,Redo2:TX,RedoDot:AX,RefreshCcw:PX,RefreshCcwDot:EX,RefreshCw:Ao,RefreshCwOff:IX,Refrigerator:LX,Regex:DX,RemoveFormatting:OX,Repeat:cP,Repeat1:RX,Repeat2:FX,Replace:BX,ReplaceAll:zX,Reply:dP,ReplyAll:$X,Rewind:qX,Ribbon:UX,Rocket:$x,RockingChair:VX,RollerCoaster:HX,Rotate3d:F2,RotateCcw:k0,RotateCcwSquare:WX,RotateCw:uP,RotateCwSquare:GX,Route:ZX,RouteOff:KX,Router:YX,Rows2:z2,Rows3:B2,Rows4:XX,Rss:QX,Ruler:JX,RussianRuble:eQ,Sailboat:tQ,Salad:sQ,Sandwich:rQ,Satellite:aQ,SatelliteDish:nQ,Save:zh,SaveAll:iQ,SaveOff:oQ,Scale:lQ,Scale3d:$2,Scaling:cQ,Scan:xQ,ScanBarcode:dQ,ScanEye:uQ,ScanFace:hQ,ScanLine:mQ,ScanQrCode:pQ,ScanSearch:fQ,ScanText:gQ,School:yQ,Scissors:_Q,ScissorsLineDashed:vQ,ScreenShare:wQ,ScreenShareOff:bQ,Scroll:kQ,ScrollText:jQ,Search:xn,SearchCheck:NQ,SearchCode:SQ,SearchSlash:CQ,SearchX:MQ,Section:TQ,Send:Pa,SendHorizontal:q2,SendToBack:AQ,SeparatorHorizontal:EQ,SeparatorVertical:PQ,Server:OQ,ServerCog:IQ,ServerCrash:LQ,ServerOff:DQ,Settings:Pl,Settings2:hP,Shapes:RQ,Share:mP,Share2:nd,Sheet:FQ,Shell:zQ,Shield:Xu,ShieldAlert:BQ,ShieldBan:$Q,ShieldCheck:pP,ShieldEllipsis:qQ,ShieldHalf:UQ,ShieldMinus:VQ,ShieldOff:HQ,ShieldPlus:WQ,ShieldQuestion:GQ,ShieldX:U2,Ship:ZQ,ShipWheel:KQ,Shirt:YQ,ShoppingBag:qx,ShoppingBasket:XQ,ShoppingCart:vm,Shovel:QQ,ShowerHead:JQ,Shrink:eJ,Shrub:tJ,Shuffle:sN,Sigma:sJ,Signal:oJ,SignalHigh:rJ,SignalLow:nJ,SignalMedium:aJ,SignalZero:iJ,Signature:lJ,Signpost:dJ,SignpostBig:cJ,Siren:uJ,SkipBack:hJ,SkipForward:mJ,Skull:pJ,Slack:fJ,Slash:gJ,Slice:xJ,SlidersHorizontal:fP,SlidersVertical:V2,Smartphone:N0,SmartphoneCharging:yJ,SmartphoneNfc:vJ,Smile:bJ,SmilePlus:_J,Snail:wJ,Snowflake:S1,Sofa:jJ,Soup:kJ,Space:NJ,Spade:SJ,Sparkle:CJ,Sparkles:gn,Speaker:MJ,Speech:TJ,SpellCheck:EJ,SpellCheck2:AJ,Spline:PJ,Split:IJ,SprayCan:LJ,Sprout:DJ,Square:Ux,SquareActivity:H2,SquareArrowDown:K2,SquareArrowDownLeft:W2,SquareArrowDownRight:G2,SquareArrowLeft:Z2,SquareArrowOutDownLeft:Y2,SquareArrowOutDownRight:X2,SquareArrowOutUpLeft:Q2,SquareArrowOutUpRight:J2,SquareArrowRight:ej,SquareArrowUp:rj,SquareArrowUpLeft:tj,SquareArrowUpRight:sj,SquareAsterisk:nj,SquareBottomDashedScissors:aj,SquareChartGantt:xx,SquareCheck:ij,SquareCheckBig:e0,SquareChevronDown:oj,SquareChevronLeft:lj,SquareChevronRight:cj,SquareChevronUp:dj,SquareCode:uj,SquareDashed:pj,SquareDashedBottom:RJ,SquareDashedBottomCode:OJ,SquareDashedKanban:hj,SquareDashedMousePointer:mj,SquareDivide:fj,SquareDot:gj,SquareEqual:xj,SquareFunction:yj,SquareKanban:vj,SquareLibrary:_j,SquareM:bj,SquareMenu:wj,SquareMinus:jj,SquareMousePointer:kj,SquareParking:Sj,SquareParkingOff:Nj,SquarePen:Pc,SquarePercent:Cj,SquarePi:Mj,SquarePilcrow:Tj,SquarePlay:Aj,SquarePlus:Ej,SquarePower:Pj,SquareRadical:FJ,SquareScissors:Ij,SquareSigma:Lj,SquareSlash:Dj,SquareSplitHorizontal:Oj,SquareSplitVertical:Rj,SquareSquare:zJ,SquareStack:BJ,SquareTerminal:Fj,SquareUser:Bj,SquareUserRound:zj,SquareX:$j,Squircle:$J,Squirrel:qJ,Stamp:UJ,Star:Gn,StarHalf:VJ,StarOff:HJ,StepBack:WJ,StepForward:GJ,Stethoscope:KJ,Sticker:ZJ,StickyNote:YJ,Store:XJ,StretchHorizontal:QJ,StretchVertical:JJ,Strikethrough:eee,Subscript:tee,Sun:X1,SunDim:see,SunMedium:ree,SunMoon:nee,SunSnow:aee,Sunrise:iee,Sunset:oee,Superscript:lee,SwatchBook:cee,SwissFranc:dee,SwitchCamera:uee,Sword:hee,Swords:mee,Syringe:pee,Table:gP,Table2:h5,TableCellsMerge:fee,TableCellsSplit:gee,TableColumnsSplit:xee,TableOfContents:yee,TableProperties:vee,TableRowsSplit:_ee,Tablet:wee,TabletSmartphone:bee,Tablets:jee,Tag:pp,Tags:kee,Tally1:Nee,Tally2:See,Tally3:Cee,Tally4:Mee,Tally5:Tee,Tangent:Aee,Target:Mm,Telescope:Eee,Tent:Iee,TentTree:Pee,Terminal:Lee,TestTube:Dee,TestTubeDiagonal:qj,TestTubes:Oee,Text:$ee,TextCursor:Fee,TextCursorInput:Ree,TextQuote:zee,TextSearch:Bee,TextSelect:Uj,Theater:qee,Thermometer:Hee,ThermometerSnowflake:Uee,ThermometerSun:Vee,ThumbsDown:xP,ThumbsUp:lu,Ticket:yP,TicketCheck:Wee,TicketMinus:Gee,TicketPercent:Kee,TicketPlus:Zee,TicketSlash:Yee,TicketX:Xee,Tickets:Jee,TicketsPlane:Qee,Timer:ste,TimerOff:ete,TimerReset:tte,ToggleLeft:rte,ToggleRight:nte,Toilet:ate,Tornado:ite,Torus:ote,Touchpad:cte,TouchpadOff:lte,TowerControl:dte,ToyBrick:ute,Tractor:hte,TrafficCone:mte,TrainFront:fte,TrainFrontTunnel:pte,TrainTrack:gte,TramFront:Vj,Trash:xte,Trash2:Cr,TreeDeciduous:yte,TreePalm:Hj,TreePine:Q1,Trees:vte,Trello:_te,TrendingDown:rN,TrendingUp:Vc,TrendingUpDown:bte,Triangle:jte,TriangleAlert:jh,TriangleRight:wte,Trophy:so,Truck:vP,Turtle:kte,Tv:Ste,TvMinimal:Wj,TvMinimalPlay:Nte,Twitch:Cte,Twitter:Mte,Type:Ate,TypeOutline:Tte,Umbrella:Pte,UmbrellaOff:Ete,Underline:Ite,Undo:m5,Undo2:Lte,UndoDot:Dte,UnfoldHorizontal:Ote,UnfoldVertical:Rte,Ungroup:Fte,University:Gj,Unlink:nN,Unlink2:zte,Unplug:Bte,Upload:xi,Usb:$te,User:mo,UserCheck:J1,UserCog:_P,UserMinus:bP,UserPen:qte,UserPlus:pc,UserRound:Jj,UserRoundCheck:Kj,UserRoundCog:Zj,UserRoundMinus:Yj,UserRoundPen:Ute,UserRoundPlus:Xj,UserRoundSearch:Vte,UserRoundX:Qj,UserSearch:Hte,UserX:Wte,Users:xr,UsersRound:ek,Utensils:sk,UtensilsCrossed:tk,UtilityPole:Gte,Variable:wP,Vault:Kte,Vegan:Zte,VenetianMask:Yte,Vibrate:Qte,VibrateOff:Xte,Video:Cn,VideoOff:Jte,Videotape:ese,View:tse,Voicemail:sse,Volleyball:rse,Volume:lse,Volume1:nse,Volume2:ase,VolumeOff:ise,VolumeX:ose,Vote:cse,Wallet:jP,WalletCards:dse,WalletMinimal:rk,Wallpaper:use,Wand:hse,WandSparkles:t0,Warehouse:mse,WashingMachine:pse,Watch:fse,Waves:gse,Waypoints:xse,Webcam:yse,Webhook:_se,WebhookOff:vse,Weight:bse,Wheat:jse,WheatOff:wse,WholeWord:kse,Wifi:Tse,WifiHigh:Nse,WifiLow:Sse,WifiOff:Cse,WifiZero:Mse,Wind:Ese,WindArrowDown:Ase,Wine:Ise,WineOff:Pse,Workflow:Lse,Worm:Dse,WrapText:Ose,Wrench:Vx,X:Vr,Youtube:Rse,Zap:Tm,ZapOff:Fse,ZoomIn:p5,ZoomOut:f5},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 Bve=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:ER,AArrowDownIcon:ER,AArrowUp:PR,AArrowUpIcon:PR,ALargeSmall:IR,ALargeSmallIcon:IR,Accessibility:LR,AccessibilityIcon:LR,Activity:Fx,ActivityIcon:Fx,ActivitySquare:H2,ActivitySquareIcon:H2,AirVent:DR,AirVentIcon:DR,Airplay:OR,AirplayIcon:OR,AlarmCheck:Gb,AlarmCheckIcon:Gb,AlarmClock:FR,AlarmClockCheck:Gb,AlarmClockCheckIcon:Gb,AlarmClockIcon:FR,AlarmClockMinus:Kb,AlarmClockMinusIcon:Kb,AlarmClockOff:RR,AlarmClockOffIcon:RR,AlarmClockPlus:Zb,AlarmClockPlusIcon:Zb,AlarmMinus:Kb,AlarmMinusIcon:Kb,AlarmPlus:Zb,AlarmPlusIcon:Zb,AlarmSmoke:zR,AlarmSmokeIcon:zR,Album:BR,AlbumIcon:BR,AlertCircle:Yo,AlertCircleIcon:Yo,AlertOctagon:N2,AlertOctagonIcon:N2,AlertTriangle:jh,AlertTriangleIcon:jh,AlignCenter:H4,AlignCenterHorizontal:$R,AlignCenterHorizontalIcon:$R,AlignCenterIcon:H4,AlignCenterVertical:qR,AlignCenterVerticalIcon:qR,AlignEndHorizontal:UR,AlignEndHorizontalIcon:UR,AlignEndVertical:VR,AlignEndVerticalIcon:VR,AlignHorizontalDistributeCenter:HR,AlignHorizontalDistributeCenterIcon:HR,AlignHorizontalDistributeEnd:WR,AlignHorizontalDistributeEndIcon:WR,AlignHorizontalDistributeStart:GR,AlignHorizontalDistributeStartIcon:GR,AlignHorizontalJustifyCenter:KR,AlignHorizontalJustifyCenterIcon:KR,AlignHorizontalJustifyEnd:ZR,AlignHorizontalJustifyEndIcon:ZR,AlignHorizontalJustifyStart:YR,AlignHorizontalJustifyStartIcon:YR,AlignHorizontalSpaceAround:XR,AlignHorizontalSpaceAroundIcon:XR,AlignHorizontalSpaceBetween:QR,AlignHorizontalSpaceBetweenIcon:QR,AlignJustify:JR,AlignJustifyIcon:JR,AlignLeft:W4,AlignLeftIcon:W4,AlignRight:G4,AlignRightIcon:G4,AlignStartHorizontal:eF,AlignStartHorizontalIcon:eF,AlignStartVertical:tF,AlignStartVerticalIcon:tF,AlignVerticalDistributeCenter:sF,AlignVerticalDistributeCenterIcon:sF,AlignVerticalDistributeEnd:rF,AlignVerticalDistributeEndIcon:rF,AlignVerticalDistributeStart:nF,AlignVerticalDistributeStartIcon:nF,AlignVerticalJustifyCenter:aF,AlignVerticalJustifyCenterIcon:aF,AlignVerticalJustifyEnd:iF,AlignVerticalJustifyEndIcon:iF,AlignVerticalJustifyStart:oF,AlignVerticalJustifyStartIcon:oF,AlignVerticalSpaceAround:lF,AlignVerticalSpaceAroundIcon:lF,AlignVerticalSpaceBetween:cF,AlignVerticalSpaceBetweenIcon:cF,Ambulance:dF,AmbulanceIcon:dF,Ampersand:uF,AmpersandIcon:uF,Ampersands:hF,AmpersandsIcon:hF,Amphora:mF,AmphoraIcon:mF,Anchor:pF,AnchorIcon:pF,Angry:fF,AngryIcon:fF,Annoyed:gF,AnnoyedIcon:gF,Antenna:xF,AntennaIcon:xF,Anvil:yF,AnvilIcon:yF,Aperture:vF,ApertureIcon:vF,AppWindow:DE,AppWindowIcon:DE,AppWindowMac:_F,AppWindowMacIcon:_F,Apple:bF,AppleIcon:bF,Archive:K4,ArchiveIcon:K4,ArchiveRestore:OE,ArchiveRestoreIcon:OE,ArchiveX:wF,ArchiveXIcon:wF,AreaChart:cw,AreaChartIcon:cw,Armchair:jF,ArmchairIcon:jF,ArrowBigDown:NF,ArrowBigDownDash:kF,ArrowBigDownDashIcon:kF,ArrowBigDownIcon:NF,ArrowBigLeft:CF,ArrowBigLeftDash:SF,ArrowBigLeftDashIcon:SF,ArrowBigLeftIcon:CF,ArrowBigRight:TF,ArrowBigRightDash:MF,ArrowBigRightDashIcon:MF,ArrowBigRightIcon:TF,ArrowBigUp:EF,ArrowBigUpDash:AF,ArrowBigUpDashIcon:AF,ArrowBigUpIcon:EF,ArrowDown:Ku,ArrowDown01:PF,ArrowDown01Icon:PF,ArrowDown10:IF,ArrowDown10Icon:IF,ArrowDownAZ:Yb,ArrowDownAZIcon:Yb,ArrowDownAz:Yb,ArrowDownAzIcon:Yb,ArrowDownCircle:bw,ArrowDownCircleIcon:bw,ArrowDownFromLine:LF,ArrowDownFromLineIcon:LF,ArrowDownIcon:Ku,ArrowDownLeft:DF,ArrowDownLeftFromCircle:jw,ArrowDownLeftFromCircleIcon:jw,ArrowDownLeftFromSquare:Y2,ArrowDownLeftFromSquareIcon:Y2,ArrowDownLeftIcon:DF,ArrowDownLeftSquare:W2,ArrowDownLeftSquareIcon:W2,ArrowDownNarrowWide:OF,ArrowDownNarrowWideIcon:OF,ArrowDownRight:RF,ArrowDownRightFromCircle:kw,ArrowDownRightFromCircleIcon:kw,ArrowDownRightFromSquare:X2,ArrowDownRightFromSquareIcon:X2,ArrowDownRightIcon:RF,ArrowDownRightSquare:G2,ArrowDownRightSquareIcon:G2,ArrowDownSquare:K2,ArrowDownSquareIcon:K2,ArrowDownToDot:FF,ArrowDownToDotIcon:FF,ArrowDownToLine:zF,ArrowDownToLineIcon:zF,ArrowDownUp:BF,ArrowDownUpIcon:BF,ArrowDownWideNarrow:Xb,ArrowDownWideNarrowIcon:Xb,ArrowDownZA:Qb,ArrowDownZAIcon:Qb,ArrowDownZa:Qb,ArrowDownZaIcon:Qb,ArrowLeft:Ba,ArrowLeftCircle:ww,ArrowLeftCircleIcon:ww,ArrowLeftFromLine:$F,ArrowLeftFromLineIcon:$F,ArrowLeftIcon:Ba,ArrowLeftRight:qF,ArrowLeftRightIcon:qF,ArrowLeftSquare:Z2,ArrowLeftSquareIcon:Z2,ArrowLeftToLine:UF,ArrowLeftToLineIcon:UF,ArrowRight:Ai,ArrowRightCircle:Cw,ArrowRightCircleIcon:Cw,ArrowRightFromLine:VF,ArrowRightFromLineIcon:VF,ArrowRightIcon:Ai,ArrowRightLeft:p0,ArrowRightLeftIcon:p0,ArrowRightSquare:ej,ArrowRightSquareIcon:ej,ArrowRightToLine:HF,ArrowRightToLineIcon:HF,ArrowUp:Rd,ArrowUp01:WF,ArrowUp01Icon:WF,ArrowUp10:GF,ArrowUp10Icon:GF,ArrowUpAZ:Jb,ArrowUpAZIcon:Jb,ArrowUpAz:Jb,ArrowUpAzIcon:Jb,ArrowUpCircle:Mw,ArrowUpCircleIcon:Mw,ArrowUpDown:$c,ArrowUpDownIcon:$c,ArrowUpFromDot:KF,ArrowUpFromDotIcon:KF,ArrowUpFromLine:ZF,ArrowUpFromLineIcon:ZF,ArrowUpIcon:Rd,ArrowUpLeft:YF,ArrowUpLeftFromCircle:Nw,ArrowUpLeftFromCircleIcon:Nw,ArrowUpLeftFromSquare:Q2,ArrowUpLeftFromSquareIcon:Q2,ArrowUpLeftIcon:YF,ArrowUpLeftSquare:tj,ArrowUpLeftSquareIcon:tj,ArrowUpNarrowWide:ew,ArrowUpNarrowWideIcon:ew,ArrowUpRight:XF,ArrowUpRightFromCircle:Sw,ArrowUpRightFromCircleIcon:Sw,ArrowUpRightFromSquare:J2,ArrowUpRightFromSquareIcon:J2,ArrowUpRightIcon:XF,ArrowUpRightSquare:sj,ArrowUpRightSquareIcon:sj,ArrowUpSquare:rj,ArrowUpSquareIcon:rj,ArrowUpToLine:QF,ArrowUpToLineIcon:QF,ArrowUpWideNarrow:JF,ArrowUpWideNarrowIcon:JF,ArrowUpZA:tw,ArrowUpZAIcon:tw,ArrowUpZa:tw,ArrowUpZaIcon:tw,ArrowsUpFromLine:ez,ArrowsUpFromLineIcon:ez,Asterisk:tz,AsteriskIcon:tz,AsteriskSquare:nj,AsteriskSquareIcon:nj,AtSign:sz,AtSignIcon:sz,Atom:rz,AtomIcon:rz,AudioLines:nz,AudioLinesIcon:nz,AudioWaveform:az,AudioWaveformIcon:az,Award:dc,AwardIcon:dc,Axe:iz,AxeIcon:iz,Axis3D:sw,Axis3DIcon:sw,Axis3d:sw,Axis3dIcon:sw,Baby:oz,BabyIcon:oz,Backpack:lz,BackpackIcon:lz,Badge:kz,BadgeAlert:cz,BadgeAlertIcon:cz,BadgeCent:dz,BadgeCentIcon:dz,BadgeCheck:rw,BadgeCheckIcon:rw,BadgeDollarSign:uz,BadgeDollarSignIcon:uz,BadgeEuro:hz,BadgeEuroIcon:hz,BadgeHelp:mz,BadgeHelpIcon:mz,BadgeIcon:kz,BadgeIndianRupee:pz,BadgeIndianRupeeIcon:pz,BadgeInfo:fz,BadgeInfoIcon:fz,BadgeJapaneseYen:gz,BadgeJapaneseYenIcon:gz,BadgeMinus:xz,BadgeMinusIcon:xz,BadgePercent:yz,BadgePercentIcon:yz,BadgePlus:vz,BadgePlusIcon:vz,BadgePoundSterling:_z,BadgePoundSterlingIcon:_z,BadgeRussianRuble:bz,BadgeRussianRubleIcon:bz,BadgeSwissFranc:wz,BadgeSwissFrancIcon:wz,BadgeX:jz,BadgeXIcon:jz,BaggageClaim:Nz,BaggageClaimIcon:Nz,Ban:Sz,BanIcon:Sz,Banana:Cz,BananaIcon:Cz,Bandage:Mz,BandageIcon:Mz,Banknote:Tz,BanknoteIcon:Tz,BarChart:gw,BarChart2:xw,BarChart2Icon:xw,BarChart3:ol,BarChart3Icon:ol,BarChart4:pw,BarChart4Icon:pw,BarChartBig:mw,BarChartBigIcon:mw,BarChartHorizontal:uw,BarChartHorizontalBig:dw,BarChartHorizontalBigIcon:dw,BarChartHorizontalIcon:uw,BarChartIcon:gw,Barcode:Az,BarcodeIcon:Az,Baseline:Ez,BaselineIcon:Ez,Bath:f0,BathIcon:f0,Battery:Rz,BatteryCharging:Pz,BatteryChargingIcon:Pz,BatteryFull:Iz,BatteryFullIcon:Iz,BatteryIcon:Rz,BatteryLow:Lz,BatteryLowIcon:Lz,BatteryMedium:Dz,BatteryMediumIcon:Dz,BatteryWarning:Oz,BatteryWarningIcon:Oz,Beaker:Fz,BeakerIcon:Fz,Bean:Bz,BeanIcon:Bz,BeanOff:zz,BeanOffIcon:zz,Bed:q1,BedDouble:RE,BedDoubleIcon:RE,BedIcon:q1,BedSingle:$z,BedSingleIcon:$z,Beef:qz,BeefIcon:qz,Beer:Vz,BeerIcon:Vz,BeerOff:Uz,BeerOffIcon:Uz,Bell:af,BellDot:Hz,BellDotIcon:Hz,BellElectric:Wz,BellElectricIcon:Wz,BellIcon:af,BellMinus:Gz,BellMinusIcon:Gz,BellOff:U1,BellOffIcon:U1,BellPlus:Kz,BellPlusIcon:Kz,BellRing:Zz,BellRingIcon:Zz,BetweenHorizonalEnd:nw,BetweenHorizonalEndIcon:nw,BetweenHorizonalStart:aw,BetweenHorizonalStartIcon:aw,BetweenHorizontalEnd:nw,BetweenHorizontalEndIcon:nw,BetweenHorizontalStart:aw,BetweenHorizontalStartIcon:aw,BetweenVerticalEnd:Yz,BetweenVerticalEndIcon:Yz,BetweenVerticalStart:Xz,BetweenVerticalStartIcon:Xz,BicepsFlexed:Qz,BicepsFlexedIcon:Qz,Bike:Jz,BikeIcon:Jz,Binary:e7,BinaryIcon:e7,Binoculars:t7,BinocularsIcon:t7,Biohazard:s7,BiohazardIcon:s7,Bird:r7,BirdIcon:r7,Bitcoin:n7,BitcoinIcon:n7,Blend:a7,BlendIcon:a7,Blinds:i7,BlindsIcon:i7,Blocks:o7,BlocksIcon:o7,Bluetooth:u7,BluetoothConnected:l7,BluetoothConnectedIcon:l7,BluetoothIcon:u7,BluetoothOff:c7,BluetoothOffIcon:c7,BluetoothSearching:d7,BluetoothSearchingIcon:d7,Bold:Z4,BoldIcon:Z4,Bolt:h7,BoltIcon:h7,Bomb:m7,BombIcon:m7,Bone:p7,BoneIcon:p7,Book:O7,BookA:f7,BookAIcon:f7,BookAudio:g7,BookAudioIcon:g7,BookCheck:x7,BookCheckIcon:x7,BookCopy:y7,BookCopyIcon:y7,BookDashed:iw,BookDashedIcon:iw,BookDown:v7,BookDownIcon:v7,BookHeadphones:_7,BookHeadphonesIcon:_7,BookHeart:b7,BookHeartIcon:b7,BookIcon:O7,BookImage:w7,BookImageIcon:w7,BookKey:j7,BookKeyIcon:j7,BookLock:k7,BookLockIcon:k7,BookMarked:N7,BookMarkedIcon:N7,BookMinus:S7,BookMinusIcon:S7,BookOpen:nu,BookOpenCheck:C7,BookOpenCheckIcon:C7,BookOpenIcon:nu,BookOpenText:M7,BookOpenTextIcon:M7,BookPlus:T7,BookPlusIcon:T7,BookTemplate:iw,BookTemplateIcon:iw,BookText:A7,BookTextIcon:A7,BookType:E7,BookTypeIcon:E7,BookUp:I7,BookUp2:P7,BookUp2Icon:P7,BookUpIcon:I7,BookUser:L7,BookUserIcon:L7,BookX:D7,BookXIcon:D7,Bookmark:Cg,BookmarkCheck:R7,BookmarkCheckIcon:R7,BookmarkIcon:Cg,BookmarkMinus:F7,BookmarkMinusIcon:F7,BookmarkPlus:FE,BookmarkPlusIcon:FE,BookmarkX:z7,BookmarkXIcon:z7,BoomBox:B7,BoomBoxIcon:B7,Bot:Y4,BotIcon:Y4,BotMessageSquare:$7,BotMessageSquareIcon:$7,BotOff:q7,BotOffIcon:q7,Box:U7,BoxIcon:U7,BoxSelect:pj,BoxSelectIcon:pj,Boxes:V7,BoxesIcon:V7,Braces:ow,BracesIcon:ow,Brackets:H7,BracketsIcon:H7,Brain:zE,BrainCircuit:W7,BrainCircuitIcon:W7,BrainCog:G7,BrainCogIcon:G7,BrainIcon:zE,BrickWall:K7,BrickWallIcon:K7,Briefcase:Zu,BriefcaseBusiness:Z7,BriefcaseBusinessIcon:Z7,BriefcaseConveyorBelt:Y7,BriefcaseConveyorBeltIcon:Y7,BriefcaseIcon:Zu,BriefcaseMedical:X7,BriefcaseMedicalIcon:X7,BringToFront:Q7,BringToFrontIcon:Q7,Brush:J7,BrushIcon:J7,Bug:sB,BugIcon:sB,BugOff:eB,BugOffIcon:eB,BugPlay:tB,BugPlayIcon:tB,Building:Uk,Building2:_a,Building2Icon:_a,BuildingIcon:Uk,Bus:nB,BusFront:rB,BusFrontIcon:rB,BusIcon:nB,Cable:iB,CableCar:aB,CableCarIcon:aB,CableIcon:iB,Cake:Lh,CakeIcon:Lh,CakeSlice:oB,CakeSliceIcon:oB,Calculator:lB,CalculatorIcon:lB,Calendar:nn,Calendar1:cB,Calendar1Icon:cB,CalendarArrowDown:dB,CalendarArrowDownIcon:dB,CalendarArrowUp:uB,CalendarArrowUpIcon:uB,CalendarCheck:mB,CalendarCheck2:hB,CalendarCheck2Icon:hB,CalendarCheckIcon:mB,CalendarClock:BE,CalendarClockIcon:BE,CalendarCog:pB,CalendarCogIcon:pB,CalendarDays:jc,CalendarDaysIcon:jc,CalendarFold:fB,CalendarFoldIcon:fB,CalendarHeart:gB,CalendarHeartIcon:gB,CalendarIcon:nn,CalendarMinus:yB,CalendarMinus2:xB,CalendarMinus2Icon:xB,CalendarMinusIcon:yB,CalendarOff:$E,CalendarOffIcon:$E,CalendarPlus:V1,CalendarPlus2:vB,CalendarPlus2Icon:vB,CalendarPlusIcon:V1,CalendarRange:_B,CalendarRangeIcon:_B,CalendarSearch:bB,CalendarSearchIcon:bB,CalendarSync:wB,CalendarSyncIcon:wB,CalendarX:kB,CalendarX2:jB,CalendarX2Icon:jB,CalendarXIcon:kB,Camera:Mg,CameraIcon:Mg,CameraOff:NB,CameraOffIcon:NB,CandlestickChart:hw,CandlestickChartIcon:hw,Candy:MB,CandyCane:SB,CandyCaneIcon:SB,CandyIcon:MB,CandyOff:CB,CandyOffIcon:CB,Cannabis:TB,CannabisIcon:TB,Captions:lw,CaptionsIcon:lw,CaptionsOff:AB,CaptionsOffIcon:AB,Car:IB,CarFront:EB,CarFrontIcon:EB,CarIcon:IB,CarTaxiFront:PB,CarTaxiFrontIcon:PB,Caravan:LB,CaravanIcon:LB,Carrot:DB,CarrotIcon:DB,CaseLower:OB,CaseLowerIcon:OB,CaseSensitive:RB,CaseSensitiveIcon:RB,CaseUpper:FB,CaseUpperIcon:FB,CassetteTape:zB,CassetteTapeIcon:zB,Cast:BB,CastIcon:BB,Castle:$B,CastleIcon:$B,Cat:qB,CatIcon:qB,Cctv:UB,CctvIcon:UB,ChartArea:cw,ChartAreaIcon:cw,ChartBar:uw,ChartBarBig:dw,ChartBarBigIcon:dw,ChartBarDecreasing:VB,ChartBarDecreasingIcon:VB,ChartBarIcon:uw,ChartBarIncreasing:HB,ChartBarIncreasingIcon:HB,ChartBarStacked:WB,ChartBarStackedIcon:WB,ChartCandlestick:hw,ChartCandlestickIcon:hw,ChartColumn:ol,ChartColumnBig:mw,ChartColumnBigIcon:mw,ChartColumnDecreasing:GB,ChartColumnDecreasingIcon:GB,ChartColumnIcon:ol,ChartColumnIncreasing:pw,ChartColumnIncreasingIcon:pw,ChartColumnStacked:KB,ChartColumnStackedIcon:KB,ChartGantt:ZB,ChartGanttIcon:ZB,ChartLine:fw,ChartLineIcon:fw,ChartNetwork:YB,ChartNetworkIcon:YB,ChartNoAxesColumn:xw,ChartNoAxesColumnDecreasing:XB,ChartNoAxesColumnDecreasingIcon:XB,ChartNoAxesColumnIcon:xw,ChartNoAxesColumnIncreasing:gw,ChartNoAxesColumnIncreasingIcon:gw,ChartNoAxesCombined:QB,ChartNoAxesCombinedIcon:QB,ChartNoAxesGantt:yw,ChartNoAxesGanttIcon:yw,ChartPie:vw,ChartPieIcon:vw,ChartScatter:_w,ChartScatterIcon:_w,ChartSpline:JB,ChartSplineIcon:JB,Check:ma,CheckCheck:e9,CheckCheckIcon:e9,CheckCircle:hi,CheckCircle2:Ma,CheckCircle2Icon:Ma,CheckCircleIcon:hi,CheckIcon:ma,CheckSquare:e0,CheckSquare2:ij,CheckSquare2Icon:ij,CheckSquareIcon:e0,ChefHat:t9,ChefHatIcon:t9,Cherry:s9,CherryIcon:s9,ChevronDown:tl,ChevronDownCircle:Tw,ChevronDownCircleIcon:Tw,ChevronDownIcon:tl,ChevronDownSquare:oj,ChevronDownSquareIcon:oj,ChevronFirst:r9,ChevronFirstIcon:r9,ChevronLast:n9,ChevronLastIcon:n9,ChevronLeft:ec,ChevronLeftCircle:Aw,ChevronLeftCircleIcon:Aw,ChevronLeftIcon:ec,ChevronLeftSquare:lj,ChevronLeftSquareIcon:lj,ChevronRight:ei,ChevronRightCircle:Ew,ChevronRightCircleIcon:Ew,ChevronRightIcon:ei,ChevronRightSquare:cj,ChevronRightSquareIcon:cj,ChevronUp:Tg,ChevronUpCircle:Pw,ChevronUpCircleIcon:Pw,ChevronUpIcon:Tg,ChevronUpSquare:dj,ChevronUpSquareIcon:dj,ChevronsDown:i9,ChevronsDownIcon:i9,ChevronsDownUp:a9,ChevronsDownUpIcon:a9,ChevronsLeft:c9,ChevronsLeftIcon:c9,ChevronsLeftRight:l9,ChevronsLeftRightEllipsis:o9,ChevronsLeftRightEllipsisIcon:o9,ChevronsLeftRightIcon:l9,ChevronsRight:u9,ChevronsRightIcon:u9,ChevronsRightLeft:d9,ChevronsRightLeftIcon:d9,ChevronsUp:h9,ChevronsUpDown:of,ChevronsUpDownIcon:of,ChevronsUpIcon:h9,Chrome:m9,ChromeIcon:m9,Church:p9,ChurchIcon:p9,Cigarette:g9,CigaretteIcon:g9,CigaretteOff:f9,CigaretteOffIcon:f9,Circle:qc,CircleAlert:Yo,CircleAlertIcon:Yo,CircleArrowDown:bw,CircleArrowDownIcon:bw,CircleArrowLeft:ww,CircleArrowLeftIcon:ww,CircleArrowOutDownLeft:jw,CircleArrowOutDownLeftIcon:jw,CircleArrowOutDownRight:kw,CircleArrowOutDownRightIcon:kw,CircleArrowOutUpLeft:Nw,CircleArrowOutUpLeftIcon:Nw,CircleArrowOutUpRight:Sw,CircleArrowOutUpRightIcon:Sw,CircleArrowRight:Cw,CircleArrowRightIcon:Cw,CircleArrowUp:Mw,CircleArrowUpIcon:Mw,CircleCheck:Ma,CircleCheckBig:hi,CircleCheckBigIcon:hi,CircleCheckIcon:Ma,CircleChevronDown:Tw,CircleChevronDownIcon:Tw,CircleChevronLeft:Aw,CircleChevronLeftIcon:Aw,CircleChevronRight:Ew,CircleChevronRightIcon:Ew,CircleChevronUp:Pw,CircleChevronUpIcon:Pw,CircleDashed:x9,CircleDashedIcon:x9,CircleDivide:Iw,CircleDivideIcon:Iw,CircleDollarSign:y9,CircleDollarSignIcon:y9,CircleDot:_9,CircleDotDashed:v9,CircleDotDashedIcon:v9,CircleDotIcon:_9,CircleEllipsis:b9,CircleEllipsisIcon:b9,CircleEqual:w9,CircleEqualIcon:w9,CircleFadingArrowUp:j9,CircleFadingArrowUpIcon:j9,CircleFadingPlus:k9,CircleFadingPlusIcon:k9,CircleGauge:Lw,CircleGaugeIcon:Lw,CircleHelp:Qy,CircleHelpIcon:Qy,CircleIcon:qc,CircleMinus:Dw,CircleMinusIcon:Dw,CircleOff:N9,CircleOffIcon:N9,CircleParking:Rw,CircleParkingIcon:Rw,CircleParkingOff:Ow,CircleParkingOffIcon:Ow,CirclePause:Fw,CirclePauseIcon:Fw,CirclePercent:zw,CirclePercentIcon:zw,CirclePlay:mm,CirclePlayIcon:mm,CirclePlus:Bw,CirclePlusIcon:Bw,CirclePower:$w,CirclePowerIcon:$w,CircleSlash:S9,CircleSlash2:qw,CircleSlash2Icon:qw,CircleSlashIcon:S9,CircleSlashed:qw,CircleSlashedIcon:qw,CircleStop:Uw,CircleStopIcon:Uw,CircleUser:Hw,CircleUserIcon:Hw,CircleUserRound:Vw,CircleUserRoundIcon:Vw,CircleX:bc,CircleXIcon:bc,CircuitBoard:C9,CircuitBoardIcon:C9,Citrus:M9,CitrusIcon:M9,Clapperboard:T9,ClapperboardIcon:T9,Clipboard:O9,ClipboardCheck:X4,ClipboardCheckIcon:X4,ClipboardCopy:A9,ClipboardCopyIcon:A9,ClipboardEdit:Gw,ClipboardEditIcon:Gw,ClipboardIcon:O9,ClipboardList:qE,ClipboardListIcon:qE,ClipboardMinus:E9,ClipboardMinusIcon:E9,ClipboardPaste:P9,ClipboardPasteIcon:P9,ClipboardPen:Gw,ClipboardPenIcon:Gw,ClipboardPenLine:Ww,ClipboardPenLineIcon:Ww,ClipboardPlus:I9,ClipboardPlusIcon:I9,ClipboardSignature:Ww,ClipboardSignatureIcon:Ww,ClipboardType:L9,ClipboardTypeIcon:L9,ClipboardX:D9,ClipboardXIcon:D9,Clock:Tn,Clock1:R9,Clock10:F9,Clock10Icon:F9,Clock11:z9,Clock11Icon:z9,Clock12:B9,Clock12Icon:B9,Clock1Icon:R9,Clock2:$9,Clock2Icon:$9,Clock3:q9,Clock3Icon:q9,Clock4:U9,Clock4Icon:U9,Clock5:V9,Clock5Icon:V9,Clock6:H9,Clock6Icon:H9,Clock7:W9,Clock7Icon:W9,Clock8:G9,Clock8Icon:G9,Clock9:K9,Clock9Icon:K9,ClockAlert:Z9,ClockAlertIcon:Z9,ClockArrowDown:Y9,ClockArrowDownIcon:Y9,ClockArrowUp:X9,ClockArrowUpIcon:X9,ClockIcon:Tn,Cloud:h$,CloudAlert:Q9,CloudAlertIcon:Q9,CloudCog:J9,CloudCogIcon:J9,CloudDownload:Kw,CloudDownloadIcon:Kw,CloudDrizzle:e$,CloudDrizzleIcon:e$,CloudFog:t$,CloudFogIcon:t$,CloudHail:s$,CloudHailIcon:s$,CloudIcon:h$,CloudLightning:r$,CloudLightningIcon:r$,CloudMoon:a$,CloudMoonIcon:a$,CloudMoonRain:n$,CloudMoonRainIcon:n$,CloudOff:i$,CloudOffIcon:i$,CloudRain:l$,CloudRainIcon:l$,CloudRainWind:o$,CloudRainWindIcon:o$,CloudSnow:c$,CloudSnowIcon:c$,CloudSun:u$,CloudSunIcon:u$,CloudSunRain:d$,CloudSunRainIcon:d$,CloudUpload:Zw,CloudUploadIcon:Zw,Cloudy:m$,CloudyIcon:m$,Clover:l0,CloverIcon:l0,Club:p$,ClubIcon:p$,Code:Vk,Code2:Yw,Code2Icon:Yw,CodeIcon:Vk,CodeSquare:uj,CodeSquareIcon:uj,CodeXml:Yw,CodeXmlIcon:Yw,Codepen:f$,CodepenIcon:f$,Codesandbox:g$,CodesandboxIcon:g$,Coffee:Hk,CoffeeIcon:Hk,Cog:x$,CogIcon:x$,Coins:UE,CoinsIcon:UE,Columns:Xw,Columns2:Xw,Columns2Icon:Xw,Columns3:Qw,Columns3Icon:Qw,Columns4:y$,Columns4Icon:y$,ColumnsIcon:Xw,Combine:v$,CombineIcon:v$,Command:_$,CommandIcon:_$,Compass:b$,CompassIcon:b$,Component:w$,ComponentIcon:w$,Computer:j$,ComputerIcon:j$,ConciergeBell:k$,ConciergeBellIcon:k$,Cone:N$,ConeIcon:N$,Construction:S$,ConstructionIcon:S$,Contact:Wk,Contact2:Jw,Contact2Icon:Jw,ContactIcon:Wk,ContactRound:Jw,ContactRoundIcon:Jw,Container:C$,ContainerIcon:C$,Contrast:M$,ContrastIcon:M$,Cookie:T$,CookieIcon:T$,CookingPot:A$,CookingPotIcon:A$,Copy:Ni,CopyCheck:E$,CopyCheckIcon:E$,CopyIcon:Ni,CopyMinus:P$,CopyMinusIcon:P$,CopyPlus:I$,CopyPlusIcon:I$,CopySlash:L$,CopySlashIcon:L$,CopyX:D$,CopyXIcon:D$,Copyleft:O$,CopyleftIcon:O$,Copyright:R$,CopyrightIcon:R$,CornerDownLeft:F$,CornerDownLeftIcon:F$,CornerDownRight:z$,CornerDownRightIcon:z$,CornerLeftDown:B$,CornerLeftDownIcon:B$,CornerLeftUp:$$,CornerLeftUpIcon:$$,CornerRightDown:q$,CornerRightDownIcon:q$,CornerRightUp:U$,CornerRightUpIcon:U$,CornerUpLeft:V$,CornerUpLeftIcon:V$,CornerUpRight:H$,CornerUpRightIcon:H$,Cpu:W$,CpuIcon:W$,CreativeCommons:G$,CreativeCommonsIcon:G$,CreditCard:cp,CreditCardIcon:cp,Croissant:K$,CroissantIcon:K$,Crop:Z$,CropIcon:Z$,Cross:Y$,CrossIcon:Y$,Crosshair:X$,CrosshairIcon:X$,Crown:Dh,CrownIcon:Dh,Cuboid:Q$,CuboidIcon:Q$,CupSoda:J$,CupSodaIcon:J$,CurlyBraces:ow,CurlyBracesIcon:ow,Currency:eq,CurrencyIcon:eq,Cylinder:tq,CylinderIcon:tq,Dam:sq,DamIcon:sq,Database:aq,DatabaseBackup:rq,DatabaseBackupIcon:rq,DatabaseIcon:aq,DatabaseZap:nq,DatabaseZapIcon:nq,Delete:iq,DeleteIcon:iq,Dessert:oq,DessertIcon:oq,Diameter:lq,DiameterIcon:lq,Diamond:uq,DiamondIcon:uq,DiamondMinus:cq,DiamondMinusIcon:cq,DiamondPercent:e2,DiamondPercentIcon:e2,DiamondPlus:dq,DiamondPlusIcon:dq,Dice1:hq,Dice1Icon:hq,Dice2:mq,Dice2Icon:mq,Dice3:pq,Dice3Icon:pq,Dice4:fq,Dice4Icon:fq,Dice5:gq,Dice5Icon:gq,Dice6:xq,Dice6Icon:xq,Dices:yq,DicesIcon:yq,Diff:vq,DiffIcon:vq,Disc:jq,Disc2:_q,Disc2Icon:_q,Disc3:bq,Disc3Icon:bq,DiscAlbum:wq,DiscAlbumIcon:wq,DiscIcon:jq,Divide:kq,DivideCircle:Iw,DivideCircleIcon:Iw,DivideIcon:kq,DivideSquare:fj,DivideSquareIcon:fj,Dna:Sq,DnaIcon:Sq,DnaOff:Nq,DnaOffIcon:Nq,Dock:Cq,DockIcon:Cq,Dog:Mq,DogIcon:Mq,DollarSign:Uc,DollarSignIcon:Uc,Donut:Tq,DonutIcon:Tq,DoorClosed:Aq,DoorClosedIcon:Aq,DoorOpen:g0,DoorOpenIcon:g0,Dot:Eq,DotIcon:Eq,DotSquare:gj,DotSquareIcon:gj,Download:Ei,DownloadCloud:Kw,DownloadCloudIcon:Kw,DownloadIcon:Ei,DraftingCompass:Pq,DraftingCompassIcon:Pq,Drama:Iq,DramaIcon:Iq,Dribbble:Lq,DribbbleIcon:Lq,Drill:Dq,DrillIcon:Dq,Droplet:Oq,DropletIcon:Oq,Droplets:zx,DropletsIcon:zx,Drum:Rq,DrumIcon:Rq,Drumstick:Fq,DrumstickIcon:Fq,Dumbbell:zq,DumbbellIcon:zq,Ear:$q,EarIcon:$q,EarOff:Bq,EarOffIcon:Bq,Earth:t2,EarthIcon:t2,EarthLock:qq,EarthLockIcon:qq,Eclipse:Uq,EclipseIcon:Uq,Edit:Pc,Edit2:Cx,Edit2Icon:Cx,Edit3:Xv,Edit3Icon:Xv,EditIcon:Pc,Egg:Q4,EggFried:Vq,EggFriedIcon:Vq,EggIcon:Q4,EggOff:Hq,EggOffIcon:Hq,Ellipsis:Xp,EllipsisIcon:Xp,EllipsisVertical:xg,EllipsisVerticalIcon:xg,Equal:Kq,EqualApproximately:Wq,EqualApproximatelyIcon:Wq,EqualIcon:Kq,EqualNot:Gq,EqualNotIcon:Gq,EqualSquare:xj,EqualSquareIcon:xj,Eraser:Zq,EraserIcon:Zq,EthernetPort:Yq,EthernetPortIcon:Yq,Euro:Xq,EuroIcon:Xq,Expand:Qq,ExpandIcon:Qq,ExternalLink:un,ExternalLinkIcon:un,Eye:Na,EyeClosed:Jq,EyeClosedIcon:Jq,EyeIcon:Na,EyeOff:Nm,EyeOffIcon:Nm,Facebook:Fd,FacebookIcon:Fd,Factory:eU,FactoryIcon:eU,Fan:tU,FanIcon:tU,FastForward:sU,FastForwardIcon:sU,Feather:rU,FeatherIcon:rU,Fence:nU,FenceIcon:nU,FerrisWheel:aU,FerrisWheelIcon:aU,Figma:iU,FigmaIcon:iU,File:J4,FileArchive:oU,FileArchiveIcon:oU,FileAudio:cU,FileAudio2:lU,FileAudio2Icon:lU,FileAudioIcon:cU,FileAxis3D:s2,FileAxis3DIcon:s2,FileAxis3d:s2,FileAxis3dIcon:s2,FileBadge:uU,FileBadge2:dU,FileBadge2Icon:dU,FileBadgeIcon:uU,FileBarChart:r2,FileBarChart2:n2,FileBarChart2Icon:n2,FileBarChartIcon:r2,FileBox:hU,FileBoxIcon:hU,FileChartColumn:n2,FileChartColumnIcon:n2,FileChartColumnIncreasing:r2,FileChartColumnIncreasingIcon:r2,FileChartLine:a2,FileChartLineIcon:a2,FileChartPie:i2,FileChartPieIcon:i2,FileCheck:pU,FileCheck2:mU,FileCheck2Icon:mU,FileCheckIcon:pU,FileClock:fU,FileClockIcon:fU,FileCode:xU,FileCode2:gU,FileCode2Icon:gU,FileCodeIcon:xU,FileCog:o2,FileCog2:o2,FileCog2Icon:o2,FileCogIcon:o2,FileDiff:yU,FileDiffIcon:yU,FileDigit:vU,FileDigitIcon:vU,FileDown:_U,FileDownIcon:_U,FileEdit:c2,FileEditIcon:c2,FileHeart:bU,FileHeartIcon:bU,FileIcon:J4,FileImage:H1,FileImageIcon:H1,FileInput:wU,FileInputIcon:wU,FileJson:kU,FileJson2:jU,FileJson2Icon:jU,FileJsonIcon:kU,FileKey:SU,FileKey2:NU,FileKey2Icon:NU,FileKeyIcon:SU,FileLineChart:a2,FileLineChartIcon:a2,FileLock:MU,FileLock2:CU,FileLock2Icon:CU,FileLockIcon:MU,FileMinus:AU,FileMinus2:TU,FileMinus2Icon:TU,FileMinusIcon:AU,FileMusic:EU,FileMusicIcon:EU,FileOutput:PU,FileOutputIcon:PU,FilePen:c2,FilePenIcon:c2,FilePenLine:l2,FilePenLineIcon:l2,FilePieChart:i2,FilePieChartIcon:i2,FilePlus:LU,FilePlus2:IU,FilePlus2Icon:IU,FilePlusIcon:LU,FileQuestion:DU,FileQuestionIcon:DU,FileScan:OU,FileScanIcon:OU,FileSearch:FU,FileSearch2:RU,FileSearch2Icon:RU,FileSearchIcon:FU,FileSignature:l2,FileSignatureIcon:l2,FileSliders:zU,FileSlidersIcon:zU,FileSpreadsheet:x0,FileSpreadsheetIcon:x0,FileStack:VE,FileStackIcon:VE,FileSymlink:BU,FileSymlinkIcon:BU,FileTerminal:$U,FileTerminalIcon:$U,FileText:Un,FileTextIcon:Un,FileType:UU,FileType2:qU,FileType2Icon:qU,FileTypeIcon:UU,FileUp:VU,FileUpIcon:VU,FileUser:HU,FileUserIcon:HU,FileVideo:GU,FileVideo2:WU,FileVideo2Icon:WU,FileVideoIcon:GU,FileVolume:ZU,FileVolume2:KU,FileVolume2Icon:KU,FileVolumeIcon:ZU,FileWarning:YU,FileWarningIcon:YU,FileX:QU,FileX2:XU,FileX2Icon:XU,FileXIcon:QU,Files:JU,FilesIcon:JU,Film:eu,FilmIcon:eu,Filter:y0,FilterIcon:y0,FilterX:eV,FilterXIcon:eV,Fingerprint:tV,FingerprintIcon:tV,FireExtinguisher:sV,FireExtinguisherIcon:sV,Fish:aV,FishIcon:aV,FishOff:rV,FishOffIcon:rV,FishSymbol:nV,FishSymbolIcon:nV,Flag:v0,FlagIcon:v0,FlagOff:iV,FlagOffIcon:iV,FlagTriangleLeft:oV,FlagTriangleLeftIcon:oV,FlagTriangleRight:lV,FlagTriangleRightIcon:lV,Flame:dp,FlameIcon:dp,FlameKindling:cV,FlameKindlingIcon:cV,Flashlight:uV,FlashlightIcon:uV,FlashlightOff:dV,FlashlightOffIcon:dV,FlaskConical:W1,FlaskConicalIcon:W1,FlaskConicalOff:hV,FlaskConicalOffIcon:hV,FlaskRound:mV,FlaskRoundIcon:mV,FlipHorizontal:fV,FlipHorizontal2:pV,FlipHorizontal2Icon:pV,FlipHorizontalIcon:fV,FlipVertical:xV,FlipVertical2:gV,FlipVertical2Icon:gV,FlipVerticalIcon:xV,Flower:yV,Flower2:wg,Flower2Icon:wg,FlowerIcon:yV,Focus:vV,FocusIcon:vV,FoldHorizontal:_V,FoldHorizontalIcon:_V,FoldVertical:bV,FoldVerticalIcon:bV,Folder:KV,FolderArchive:wV,FolderArchiveIcon:wV,FolderCheck:jV,FolderCheckIcon:jV,FolderClock:kV,FolderClockIcon:kV,FolderClosed:NV,FolderClosedIcon:NV,FolderCode:SV,FolderCodeIcon:SV,FolderCog:d2,FolderCog2:d2,FolderCog2Icon:d2,FolderCogIcon:d2,FolderDot:CV,FolderDotIcon:CV,FolderDown:MV,FolderDownIcon:MV,FolderEdit:u2,FolderEditIcon:u2,FolderGit:AV,FolderGit2:TV,FolderGit2Icon:TV,FolderGitIcon:AV,FolderHeart:EV,FolderHeartIcon:EV,FolderIcon:KV,FolderInput:PV,FolderInputIcon:PV,FolderKanban:IV,FolderKanbanIcon:IV,FolderKey:LV,FolderKeyIcon:LV,FolderLock:DV,FolderLockIcon:DV,FolderMinus:OV,FolderMinusIcon:OV,FolderOpen:Oh,FolderOpenDot:RV,FolderOpenDotIcon:RV,FolderOpenIcon:Oh,FolderOutput:FV,FolderOutputIcon:FV,FolderPen:u2,FolderPenIcon:u2,FolderPlus:zV,FolderPlusIcon:zV,FolderRoot:BV,FolderRootIcon:BV,FolderSearch:qV,FolderSearch2:$V,FolderSearch2Icon:$V,FolderSearchIcon:qV,FolderSymlink:UV,FolderSymlinkIcon:UV,FolderSync:VV,FolderSyncIcon:VV,FolderTree:HV,FolderTreeIcon:HV,FolderUp:WV,FolderUpIcon:WV,FolderX:GV,FolderXIcon:GV,Folders:ZV,FoldersIcon:ZV,Footprints:YV,FootprintsIcon:YV,ForkKnife:sk,ForkKnifeCrossed:tk,ForkKnifeCrossedIcon:tk,ForkKnifeIcon:sk,Forklift:XV,ForkliftIcon:XV,FormInput:R2,FormInputIcon:R2,Forward:QV,ForwardIcon:QV,Frame:JV,FrameIcon:JV,Framer:eH,FramerIcon:eH,Frown:tH,FrownIcon:tH,Fuel:sH,FuelIcon:sH,Fullscreen:rH,FullscreenIcon:rH,FunctionSquare:yj,FunctionSquareIcon:yj,GalleryHorizontal:aH,GalleryHorizontalEnd:nH,GalleryHorizontalEndIcon:nH,GalleryHorizontalIcon:aH,GalleryThumbnails:iH,GalleryThumbnailsIcon:iH,GalleryVertical:lH,GalleryVerticalEnd:oH,GalleryVerticalEndIcon:oH,GalleryVerticalIcon:lH,Gamepad:dH,Gamepad2:cH,Gamepad2Icon:cH,GamepadIcon:dH,GanttChart:yw,GanttChartIcon:yw,GanttChartSquare:xx,GanttChartSquareIcon:xx,Gauge:uH,GaugeCircle:Lw,GaugeCircleIcon:Lw,GaugeIcon:uH,Gavel:hH,GavelIcon:hH,Gem:mH,GemIcon:mH,Ghost:Gk,GhostIcon:Gk,Gift:uo,GiftIcon:uo,GitBranch:fH,GitBranchIcon:fH,GitBranchPlus:pH,GitBranchPlusIcon:pH,GitCommit:h2,GitCommitHorizontal:h2,GitCommitHorizontalIcon:h2,GitCommitIcon:h2,GitCommitVertical:gH,GitCommitVerticalIcon:gH,GitCompare:yH,GitCompareArrows:xH,GitCompareArrowsIcon:xH,GitCompareIcon:yH,GitFork:vH,GitForkIcon:vH,GitGraph:_H,GitGraphIcon:_H,GitMerge:bH,GitMergeIcon:bH,GitPullRequest:CH,GitPullRequestArrow:wH,GitPullRequestArrowIcon:wH,GitPullRequestClosed:jH,GitPullRequestClosedIcon:jH,GitPullRequestCreate:NH,GitPullRequestCreateArrow:kH,GitPullRequestCreateArrowIcon:kH,GitPullRequestCreateIcon:NH,GitPullRequestDraft:SH,GitPullRequestDraftIcon:SH,GitPullRequestIcon:CH,Github:MH,GithubIcon:MH,Gitlab:TH,GitlabIcon:TH,GlassWater:AH,GlassWaterIcon:AH,Glasses:EH,GlassesIcon:EH,Globe:up,Globe2:t2,Globe2Icon:t2,GlobeIcon:up,GlobeLock:PH,GlobeLockIcon:PH,Goal:IH,GoalIcon:IH,Grab:LH,GrabIcon:LH,GraduationCap:Yu,GraduationCapIcon:Yu,Grape:DH,GrapeIcon:DH,Grid:Ym,Grid2X2:p2,Grid2X2Icon:p2,Grid2X2Plus:m2,Grid2X2PlusIcon:m2,Grid2x2:p2,Grid2x2Check:OH,Grid2x2CheckIcon:OH,Grid2x2Icon:p2,Grid2x2Plus:m2,Grid2x2PlusIcon:m2,Grid2x2X:RH,Grid2x2XIcon:RH,Grid3X3:Ym,Grid3X3Icon:Ym,Grid3x3:Ym,Grid3x3Icon:Ym,GridIcon:Ym,Grip:zH,GripHorizontal:FH,GripHorizontalIcon:FH,GripIcon:zH,GripVertical:Rh,GripVerticalIcon:Rh,Group:BH,GroupIcon:BH,Guitar:$H,GuitarIcon:$H,Ham:qH,HamIcon:qH,Hammer:UH,HammerIcon:UH,Hand:HE,HandCoins:VH,HandCoinsIcon:VH,HandHeart:HH,HandHeartIcon:HH,HandHelping:f2,HandHelpingIcon:f2,HandIcon:HE,HandMetal:WH,HandMetalIcon:WH,HandPlatter:GH,HandPlatterIcon:GH,Handshake:KH,HandshakeIcon:KH,HardDrive:WE,HardDriveDownload:ZH,HardDriveDownloadIcon:ZH,HardDriveIcon:WE,HardDriveUpload:YH,HardDriveUploadIcon:YH,HardHat:XH,HardHatIcon:XH,Hash:e5,HashIcon:e5,Haze:QH,HazeIcon:QH,HdmiPort:JH,HdmiPortIcon:JH,Heading:nW,Heading1:GE,Heading1Icon:GE,Heading2:KE,Heading2Icon:KE,Heading3:eW,Heading3Icon:eW,Heading4:tW,Heading4Icon:tW,Heading5:sW,Heading5Icon:sW,Heading6:rW,Heading6Icon:rW,HeadingIcon:nW,HeadphoneOff:aW,HeadphoneOffIcon:aW,Headphones:iW,HeadphonesIcon:iW,Headset:oW,HeadsetIcon:oW,Heart:Oi,HeartCrack:lW,HeartCrackIcon:lW,HeartHandshake:cW,HeartHandshakeIcon:cW,HeartIcon:Oi,HeartOff:dW,HeartOffIcon:dW,HeartPulse:uW,HeartPulseIcon:uW,Heater:hW,HeaterIcon:hW,HelpCircle:Qy,HelpCircleIcon:Qy,HelpingHand:f2,HelpingHandIcon:f2,Hexagon:mW,HexagonIcon:mW,Highlighter:pW,HighlighterIcon:pW,History:t5,HistoryIcon:t5,Home:Hn,HomeIcon:Hn,Hop:gW,HopIcon:gW,HopOff:fW,HopOffIcon:fW,Hospital:xW,HospitalIcon:xW,Hotel:yW,HotelIcon:yW,Hourglass:vW,HourglassIcon:vW,House:Hn,HouseIcon:Hn,HousePlug:_W,HousePlugIcon:_W,HousePlus:bW,HousePlusIcon:bW,IceCream:x2,IceCream2:g2,IceCream2Icon:g2,IceCreamBowl:g2,IceCreamBowlIcon:g2,IceCreamCone:x2,IceCreamConeIcon:x2,IceCreamIcon:x2,Icon:W8e,IdCard:wW,IdCardIcon:wW,Image:Xo,ImageDown:jW,ImageDownIcon:jW,ImageIcon:Xo,ImageMinus:kW,ImageMinusIcon:kW,ImageOff:NW,ImageOffIcon:NW,ImagePlay:SW,ImagePlayIcon:SW,ImagePlus:_0,ImagePlusIcon:_0,ImageUp:CW,ImageUpIcon:CW,ImageUpscale:MW,ImageUpscaleIcon:MW,Images:TW,ImagesIcon:TW,Import:AW,ImportIcon:AW,Inbox:EW,InboxIcon:EW,Indent:v2,IndentDecrease:y2,IndentDecreaseIcon:y2,IndentIcon:v2,IndentIncrease:v2,IndentIncreaseIcon:v2,IndianRupee:PW,IndianRupeeIcon:PW,Infinity:IW,InfinityIcon:IW,Info:ZE,InfoIcon:ZE,Inspect:kj,InspectIcon:kj,InspectionPanel:LW,InspectionPanelIcon:LW,Instagram:zd,InstagramIcon:zd,Italic:s5,ItalicIcon:s5,IterationCcw:DW,IterationCcwIcon:DW,IterationCw:OW,IterationCwIcon:OW,JapaneseYen:RW,JapaneseYenIcon:RW,Joystick:FW,JoystickIcon:FW,Kanban:Bx,KanbanIcon:Bx,KanbanSquare:vj,KanbanSquareDashed:hj,KanbanSquareDashedIcon:hj,KanbanSquareIcon:vj,Key:Sm,KeyIcon:Sm,KeyRound:Kk,KeyRoundIcon:Kk,KeySquare:zW,KeySquareIcon:zW,Keyboard:qW,KeyboardIcon:qW,KeyboardMusic:BW,KeyboardMusicIcon:BW,KeyboardOff:$W,KeyboardOffIcon:$W,Lamp:KW,LampCeiling:UW,LampCeilingIcon:UW,LampDesk:VW,LampDeskIcon:VW,LampFloor:HW,LampFloorIcon:HW,LampIcon:KW,LampWallDown:WW,LampWallDownIcon:WW,LampWallUp:GW,LampWallUpIcon:GW,LandPlot:ZW,LandPlotIcon:ZW,Landmark:YW,LandmarkIcon:YW,Languages:XW,LanguagesIcon:XW,Laptop:JW,Laptop2:_2,Laptop2Icon:_2,LaptopIcon:JW,LaptopMinimal:_2,LaptopMinimalCheck:QW,LaptopMinimalCheckIcon:QW,LaptopMinimalIcon:_2,Lasso:tG,LassoIcon:tG,LassoSelect:eG,LassoSelectIcon:eG,Laugh:sG,LaughIcon:sG,Layers:aG,Layers2:rG,Layers2Icon:rG,Layers3:nG,Layers3Icon:nG,LayersIcon:aG,Layout:Jy,LayoutDashboard:Zk,LayoutDashboardIcon:Zk,LayoutGrid:hp,LayoutGridIcon:hp,LayoutIcon:Jy,LayoutList:iG,LayoutListIcon:iG,LayoutPanelLeft:oG,LayoutPanelLeftIcon:oG,LayoutPanelTop:lG,LayoutPanelTopIcon:lG,LayoutTemplate:Yk,LayoutTemplateIcon:Yk,Leaf:cG,LeafIcon:cG,LeafyGreen:dG,LeafyGreenIcon:dG,Lectern:uG,LecternIcon:uG,LetterText:hG,LetterTextIcon:hG,Library:r5,LibraryBig:mG,LibraryBigIcon:mG,LibraryIcon:r5,LibrarySquare:_j,LibrarySquareIcon:_j,LifeBuoy:n5,LifeBuoyIcon:n5,Ligature:pG,LigatureIcon:pG,Lightbulb:G1,LightbulbIcon:G1,LightbulbOff:fG,LightbulbOffIcon:fG,LineChart:fw,LineChartIcon:fw,Link:Po,Link2:Al,Link2Icon:Al,Link2Off:gG,Link2OffIcon:gG,LinkIcon:Po,Linkedin:Cm,LinkedinIcon:Cm,List:Fh,ListCheck:xG,ListCheckIcon:xG,ListChecks:yG,ListChecksIcon:yG,ListCollapse:vG,ListCollapseIcon:vG,ListEnd:_G,ListEndIcon:_G,ListFilter:bG,ListFilterIcon:bG,ListIcon:Fh,ListMinus:wG,ListMinusIcon:wG,ListMusic:jG,ListMusicIcon:jG,ListOrdered:b0,ListOrderedIcon:b0,ListPlus:kG,ListPlusIcon:kG,ListRestart:NG,ListRestartIcon:NG,ListStart:SG,ListStartIcon:SG,ListTodo:CG,ListTodoIcon:CG,ListTree:MG,ListTreeIcon:MG,ListVideo:TG,ListVideoIcon:TG,ListX:AG,ListXIcon:AG,Loader:PG,Loader2:Rs,Loader2Icon:Rs,LoaderCircle:Rs,LoaderCircleIcon:Rs,LoaderIcon:PG,LoaderPinwheel:EG,LoaderPinwheelIcon:EG,Locate:YE,LocateFixed:IG,LocateFixedIcon:IG,LocateIcon:YE,LocateOff:LG,LocateOffIcon:LG,Lock:Pu,LockIcon:Pu,LockKeyhole:DG,LockKeyholeIcon:DG,LockKeyholeOpen:b2,LockKeyholeOpenIcon:b2,LockOpen:w2,LockOpenIcon:w2,LogIn:a5,LogInIcon:a5,LogOut:i5,LogOutIcon:i5,Logs:OG,LogsIcon:OG,Lollipop:RG,LollipopIcon:RG,LucideAArrowDown:ER,LucideAArrowUp:PR,LucideALargeSmall:IR,LucideAccessibility:LR,LucideActivity:Fx,LucideActivitySquare:H2,LucideAirVent:DR,LucideAirplay:OR,LucideAlarmCheck:Gb,LucideAlarmClock:FR,LucideAlarmClockCheck:Gb,LucideAlarmClockMinus:Kb,LucideAlarmClockOff:RR,LucideAlarmClockPlus:Zb,LucideAlarmMinus:Kb,LucideAlarmPlus:Zb,LucideAlarmSmoke:zR,LucideAlbum:BR,LucideAlertCircle:Yo,LucideAlertOctagon:N2,LucideAlertTriangle:jh,LucideAlignCenter:H4,LucideAlignCenterHorizontal:$R,LucideAlignCenterVertical:qR,LucideAlignEndHorizontal:UR,LucideAlignEndVertical:VR,LucideAlignHorizontalDistributeCenter:HR,LucideAlignHorizontalDistributeEnd:WR,LucideAlignHorizontalDistributeStart:GR,LucideAlignHorizontalJustifyCenter:KR,LucideAlignHorizontalJustifyEnd:ZR,LucideAlignHorizontalJustifyStart:YR,LucideAlignHorizontalSpaceAround:XR,LucideAlignHorizontalSpaceBetween:QR,LucideAlignJustify:JR,LucideAlignLeft:W4,LucideAlignRight:G4,LucideAlignStartHorizontal:eF,LucideAlignStartVertical:tF,LucideAlignVerticalDistributeCenter:sF,LucideAlignVerticalDistributeEnd:rF,LucideAlignVerticalDistributeStart:nF,LucideAlignVerticalJustifyCenter:aF,LucideAlignVerticalJustifyEnd:iF,LucideAlignVerticalJustifyStart:oF,LucideAlignVerticalSpaceAround:lF,LucideAlignVerticalSpaceBetween:cF,LucideAmbulance:dF,LucideAmpersand:uF,LucideAmpersands:hF,LucideAmphora:mF,LucideAnchor:pF,LucideAngry:fF,LucideAnnoyed:gF,LucideAntenna:xF,LucideAnvil:yF,LucideAperture:vF,LucideAppWindow:DE,LucideAppWindowMac:_F,LucideApple:bF,LucideArchive:K4,LucideArchiveRestore:OE,LucideArchiveX:wF,LucideAreaChart:cw,LucideArmchair:jF,LucideArrowBigDown:NF,LucideArrowBigDownDash:kF,LucideArrowBigLeft:CF,LucideArrowBigLeftDash:SF,LucideArrowBigRight:TF,LucideArrowBigRightDash:MF,LucideArrowBigUp:EF,LucideArrowBigUpDash:AF,LucideArrowDown:Ku,LucideArrowDown01:PF,LucideArrowDown10:IF,LucideArrowDownAZ:Yb,LucideArrowDownAz:Yb,LucideArrowDownCircle:bw,LucideArrowDownFromLine:LF,LucideArrowDownLeft:DF,LucideArrowDownLeftFromCircle:jw,LucideArrowDownLeftFromSquare:Y2,LucideArrowDownLeftSquare:W2,LucideArrowDownNarrowWide:OF,LucideArrowDownRight:RF,LucideArrowDownRightFromCircle:kw,LucideArrowDownRightFromSquare:X2,LucideArrowDownRightSquare:G2,LucideArrowDownSquare:K2,LucideArrowDownToDot:FF,LucideArrowDownToLine:zF,LucideArrowDownUp:BF,LucideArrowDownWideNarrow:Xb,LucideArrowDownZA:Qb,LucideArrowDownZa:Qb,LucideArrowLeft:Ba,LucideArrowLeftCircle:ww,LucideArrowLeftFromLine:$F,LucideArrowLeftRight:qF,LucideArrowLeftSquare:Z2,LucideArrowLeftToLine:UF,LucideArrowRight:Ai,LucideArrowRightCircle:Cw,LucideArrowRightFromLine:VF,LucideArrowRightLeft:p0,LucideArrowRightSquare:ej,LucideArrowRightToLine:HF,LucideArrowUp:Rd,LucideArrowUp01:WF,LucideArrowUp10:GF,LucideArrowUpAZ:Jb,LucideArrowUpAz:Jb,LucideArrowUpCircle:Mw,LucideArrowUpDown:$c,LucideArrowUpFromDot:KF,LucideArrowUpFromLine:ZF,LucideArrowUpLeft:YF,LucideArrowUpLeftFromCircle:Nw,LucideArrowUpLeftFromSquare:Q2,LucideArrowUpLeftSquare:tj,LucideArrowUpNarrowWide:ew,LucideArrowUpRight:XF,LucideArrowUpRightFromCircle:Sw,LucideArrowUpRightFromSquare:J2,LucideArrowUpRightSquare:sj,LucideArrowUpSquare:rj,LucideArrowUpToLine:QF,LucideArrowUpWideNarrow:JF,LucideArrowUpZA:tw,LucideArrowUpZa:tw,LucideArrowsUpFromLine:ez,LucideAsterisk:tz,LucideAsteriskSquare:nj,LucideAtSign:sz,LucideAtom:rz,LucideAudioLines:nz,LucideAudioWaveform:az,LucideAward:dc,LucideAxe:iz,LucideAxis3D:sw,LucideAxis3d:sw,LucideBaby:oz,LucideBackpack:lz,LucideBadge:kz,LucideBadgeAlert:cz,LucideBadgeCent:dz,LucideBadgeCheck:rw,LucideBadgeDollarSign:uz,LucideBadgeEuro:hz,LucideBadgeHelp:mz,LucideBadgeIndianRupee:pz,LucideBadgeInfo:fz,LucideBadgeJapaneseYen:gz,LucideBadgeMinus:xz,LucideBadgePercent:yz,LucideBadgePlus:vz,LucideBadgePoundSterling:_z,LucideBadgeRussianRuble:bz,LucideBadgeSwissFranc:wz,LucideBadgeX:jz,LucideBaggageClaim:Nz,LucideBan:Sz,LucideBanana:Cz,LucideBandage:Mz,LucideBanknote:Tz,LucideBarChart:gw,LucideBarChart2:xw,LucideBarChart3:ol,LucideBarChart4:pw,LucideBarChartBig:mw,LucideBarChartHorizontal:uw,LucideBarChartHorizontalBig:dw,LucideBarcode:Az,LucideBaseline:Ez,LucideBath:f0,LucideBattery:Rz,LucideBatteryCharging:Pz,LucideBatteryFull:Iz,LucideBatteryLow:Lz,LucideBatteryMedium:Dz,LucideBatteryWarning:Oz,LucideBeaker:Fz,LucideBean:Bz,LucideBeanOff:zz,LucideBed:q1,LucideBedDouble:RE,LucideBedSingle:$z,LucideBeef:qz,LucideBeer:Vz,LucideBeerOff:Uz,LucideBell:af,LucideBellDot:Hz,LucideBellElectric:Wz,LucideBellMinus:Gz,LucideBellOff:U1,LucideBellPlus:Kz,LucideBellRing:Zz,LucideBetweenHorizonalEnd:nw,LucideBetweenHorizonalStart:aw,LucideBetweenHorizontalEnd:nw,LucideBetweenHorizontalStart:aw,LucideBetweenVerticalEnd:Yz,LucideBetweenVerticalStart:Xz,LucideBicepsFlexed:Qz,LucideBike:Jz,LucideBinary:e7,LucideBinoculars:t7,LucideBiohazard:s7,LucideBird:r7,LucideBitcoin:n7,LucideBlend:a7,LucideBlinds:i7,LucideBlocks:o7,LucideBluetooth:u7,LucideBluetoothConnected:l7,LucideBluetoothOff:c7,LucideBluetoothSearching:d7,LucideBold:Z4,LucideBolt:h7,LucideBomb:m7,LucideBone:p7,LucideBook:O7,LucideBookA:f7,LucideBookAudio:g7,LucideBookCheck:x7,LucideBookCopy:y7,LucideBookDashed:iw,LucideBookDown:v7,LucideBookHeadphones:_7,LucideBookHeart:b7,LucideBookImage:w7,LucideBookKey:j7,LucideBookLock:k7,LucideBookMarked:N7,LucideBookMinus:S7,LucideBookOpen:nu,LucideBookOpenCheck:C7,LucideBookOpenText:M7,LucideBookPlus:T7,LucideBookTemplate:iw,LucideBookText:A7,LucideBookType:E7,LucideBookUp:I7,LucideBookUp2:P7,LucideBookUser:L7,LucideBookX:D7,LucideBookmark:Cg,LucideBookmarkCheck:R7,LucideBookmarkMinus:F7,LucideBookmarkPlus:FE,LucideBookmarkX:z7,LucideBoomBox:B7,LucideBot:Y4,LucideBotMessageSquare:$7,LucideBotOff:q7,LucideBox:U7,LucideBoxSelect:pj,LucideBoxes:V7,LucideBraces:ow,LucideBrackets:H7,LucideBrain:zE,LucideBrainCircuit:W7,LucideBrainCog:G7,LucideBrickWall:K7,LucideBriefcase:Zu,LucideBriefcaseBusiness:Z7,LucideBriefcaseConveyorBelt:Y7,LucideBriefcaseMedical:X7,LucideBringToFront:Q7,LucideBrush:J7,LucideBug:sB,LucideBugOff:eB,LucideBugPlay:tB,LucideBuilding:Uk,LucideBuilding2:_a,LucideBus:nB,LucideBusFront:rB,LucideCable:iB,LucideCableCar:aB,LucideCake:Lh,LucideCakeSlice:oB,LucideCalculator:lB,LucideCalendar:nn,LucideCalendar1:cB,LucideCalendarArrowDown:dB,LucideCalendarArrowUp:uB,LucideCalendarCheck:mB,LucideCalendarCheck2:hB,LucideCalendarClock:BE,LucideCalendarCog:pB,LucideCalendarDays:jc,LucideCalendarFold:fB,LucideCalendarHeart:gB,LucideCalendarMinus:yB,LucideCalendarMinus2:xB,LucideCalendarOff:$E,LucideCalendarPlus:V1,LucideCalendarPlus2:vB,LucideCalendarRange:_B,LucideCalendarSearch:bB,LucideCalendarSync:wB,LucideCalendarX:kB,LucideCalendarX2:jB,LucideCamera:Mg,LucideCameraOff:NB,LucideCandlestickChart:hw,LucideCandy:MB,LucideCandyCane:SB,LucideCandyOff:CB,LucideCannabis:TB,LucideCaptions:lw,LucideCaptionsOff:AB,LucideCar:IB,LucideCarFront:EB,LucideCarTaxiFront:PB,LucideCaravan:LB,LucideCarrot:DB,LucideCaseLower:OB,LucideCaseSensitive:RB,LucideCaseUpper:FB,LucideCassetteTape:zB,LucideCast:BB,LucideCastle:$B,LucideCat:qB,LucideCctv:UB,LucideChartArea:cw,LucideChartBar:uw,LucideChartBarBig:dw,LucideChartBarDecreasing:VB,LucideChartBarIncreasing:HB,LucideChartBarStacked:WB,LucideChartCandlestick:hw,LucideChartColumn:ol,LucideChartColumnBig:mw,LucideChartColumnDecreasing:GB,LucideChartColumnIncreasing:pw,LucideChartColumnStacked:KB,LucideChartGantt:ZB,LucideChartLine:fw,LucideChartNetwork:YB,LucideChartNoAxesColumn:xw,LucideChartNoAxesColumnDecreasing:XB,LucideChartNoAxesColumnIncreasing:gw,LucideChartNoAxesCombined:QB,LucideChartNoAxesGantt:yw,LucideChartPie:vw,LucideChartScatter:_w,LucideChartSpline:JB,LucideCheck:ma,LucideCheckCheck:e9,LucideCheckCircle:hi,LucideCheckCircle2:Ma,LucideCheckSquare:e0,LucideCheckSquare2:ij,LucideChefHat:t9,LucideCherry:s9,LucideChevronDown:tl,LucideChevronDownCircle:Tw,LucideChevronDownSquare:oj,LucideChevronFirst:r9,LucideChevronLast:n9,LucideChevronLeft:ec,LucideChevronLeftCircle:Aw,LucideChevronLeftSquare:lj,LucideChevronRight:ei,LucideChevronRightCircle:Ew,LucideChevronRightSquare:cj,LucideChevronUp:Tg,LucideChevronUpCircle:Pw,LucideChevronUpSquare:dj,LucideChevronsDown:i9,LucideChevronsDownUp:a9,LucideChevronsLeft:c9,LucideChevronsLeftRight:l9,LucideChevronsLeftRightEllipsis:o9,LucideChevronsRight:u9,LucideChevronsRightLeft:d9,LucideChevronsUp:h9,LucideChevronsUpDown:of,LucideChrome:m9,LucideChurch:p9,LucideCigarette:g9,LucideCigaretteOff:f9,LucideCircle:qc,LucideCircleAlert:Yo,LucideCircleArrowDown:bw,LucideCircleArrowLeft:ww,LucideCircleArrowOutDownLeft:jw,LucideCircleArrowOutDownRight:kw,LucideCircleArrowOutUpLeft:Nw,LucideCircleArrowOutUpRight:Sw,LucideCircleArrowRight:Cw,LucideCircleArrowUp:Mw,LucideCircleCheck:Ma,LucideCircleCheckBig:hi,LucideCircleChevronDown:Tw,LucideCircleChevronLeft:Aw,LucideCircleChevronRight:Ew,LucideCircleChevronUp:Pw,LucideCircleDashed:x9,LucideCircleDivide:Iw,LucideCircleDollarSign:y9,LucideCircleDot:_9,LucideCircleDotDashed:v9,LucideCircleEllipsis:b9,LucideCircleEqual:w9,LucideCircleFadingArrowUp:j9,LucideCircleFadingPlus:k9,LucideCircleGauge:Lw,LucideCircleHelp:Qy,LucideCircleMinus:Dw,LucideCircleOff:N9,LucideCircleParking:Rw,LucideCircleParkingOff:Ow,LucideCirclePause:Fw,LucideCirclePercent:zw,LucideCirclePlay:mm,LucideCirclePlus:Bw,LucideCirclePower:$w,LucideCircleSlash:S9,LucideCircleSlash2:qw,LucideCircleSlashed:qw,LucideCircleStop:Uw,LucideCircleUser:Hw,LucideCircleUserRound:Vw,LucideCircleX:bc,LucideCircuitBoard:C9,LucideCitrus:M9,LucideClapperboard:T9,LucideClipboard:O9,LucideClipboardCheck:X4,LucideClipboardCopy:A9,LucideClipboardEdit:Gw,LucideClipboardList:qE,LucideClipboardMinus:E9,LucideClipboardPaste:P9,LucideClipboardPen:Gw,LucideClipboardPenLine:Ww,LucideClipboardPlus:I9,LucideClipboardSignature:Ww,LucideClipboardType:L9,LucideClipboardX:D9,LucideClock:Tn,LucideClock1:R9,LucideClock10:F9,LucideClock11:z9,LucideClock12:B9,LucideClock2:$9,LucideClock3:q9,LucideClock4:U9,LucideClock5:V9,LucideClock6:H9,LucideClock7:W9,LucideClock8:G9,LucideClock9:K9,LucideClockAlert:Z9,LucideClockArrowDown:Y9,LucideClockArrowUp:X9,LucideCloud:h$,LucideCloudAlert:Q9,LucideCloudCog:J9,LucideCloudDownload:Kw,LucideCloudDrizzle:e$,LucideCloudFog:t$,LucideCloudHail:s$,LucideCloudLightning:r$,LucideCloudMoon:a$,LucideCloudMoonRain:n$,LucideCloudOff:i$,LucideCloudRain:l$,LucideCloudRainWind:o$,LucideCloudSnow:c$,LucideCloudSun:u$,LucideCloudSunRain:d$,LucideCloudUpload:Zw,LucideCloudy:m$,LucideClover:l0,LucideClub:p$,LucideCode:Vk,LucideCode2:Yw,LucideCodeSquare:uj,LucideCodeXml:Yw,LucideCodepen:f$,LucideCodesandbox:g$,LucideCoffee:Hk,LucideCog:x$,LucideCoins:UE,LucideColumns:Xw,LucideColumns2:Xw,LucideColumns3:Qw,LucideColumns4:y$,LucideCombine:v$,LucideCommand:_$,LucideCompass:b$,LucideComponent:w$,LucideComputer:j$,LucideConciergeBell:k$,LucideCone:N$,LucideConstruction:S$,LucideContact:Wk,LucideContact2:Jw,LucideContactRound:Jw,LucideContainer:C$,LucideContrast:M$,LucideCookie:T$,LucideCookingPot:A$,LucideCopy:Ni,LucideCopyCheck:E$,LucideCopyMinus:P$,LucideCopyPlus:I$,LucideCopySlash:L$,LucideCopyX:D$,LucideCopyleft:O$,LucideCopyright:R$,LucideCornerDownLeft:F$,LucideCornerDownRight:z$,LucideCornerLeftDown:B$,LucideCornerLeftUp:$$,LucideCornerRightDown:q$,LucideCornerRightUp:U$,LucideCornerUpLeft:V$,LucideCornerUpRight:H$,LucideCpu:W$,LucideCreativeCommons:G$,LucideCreditCard:cp,LucideCroissant:K$,LucideCrop:Z$,LucideCross:Y$,LucideCrosshair:X$,LucideCrown:Dh,LucideCuboid:Q$,LucideCupSoda:J$,LucideCurlyBraces:ow,LucideCurrency:eq,LucideCylinder:tq,LucideDam:sq,LucideDatabase:aq,LucideDatabaseBackup:rq,LucideDatabaseZap:nq,LucideDelete:iq,LucideDessert:oq,LucideDiameter:lq,LucideDiamond:uq,LucideDiamondMinus:cq,LucideDiamondPercent:e2,LucideDiamondPlus:dq,LucideDice1:hq,LucideDice2:mq,LucideDice3:pq,LucideDice4:fq,LucideDice5:gq,LucideDice6:xq,LucideDices:yq,LucideDiff:vq,LucideDisc:jq,LucideDisc2:_q,LucideDisc3:bq,LucideDiscAlbum:wq,LucideDivide:kq,LucideDivideCircle:Iw,LucideDivideSquare:fj,LucideDna:Sq,LucideDnaOff:Nq,LucideDock:Cq,LucideDog:Mq,LucideDollarSign:Uc,LucideDonut:Tq,LucideDoorClosed:Aq,LucideDoorOpen:g0,LucideDot:Eq,LucideDotSquare:gj,LucideDownload:Ei,LucideDownloadCloud:Kw,LucideDraftingCompass:Pq,LucideDrama:Iq,LucideDribbble:Lq,LucideDrill:Dq,LucideDroplet:Oq,LucideDroplets:zx,LucideDrum:Rq,LucideDrumstick:Fq,LucideDumbbell:zq,LucideEar:$q,LucideEarOff:Bq,LucideEarth:t2,LucideEarthLock:qq,LucideEclipse:Uq,LucideEdit:Pc,LucideEdit2:Cx,LucideEdit3:Xv,LucideEgg:Q4,LucideEggFried:Vq,LucideEggOff:Hq,LucideEllipsis:Xp,LucideEllipsisVertical:xg,LucideEqual:Kq,LucideEqualApproximately:Wq,LucideEqualNot:Gq,LucideEqualSquare:xj,LucideEraser:Zq,LucideEthernetPort:Yq,LucideEuro:Xq,LucideExpand:Qq,LucideExternalLink:un,LucideEye:Na,LucideEyeClosed:Jq,LucideEyeOff:Nm,LucideFacebook:Fd,LucideFactory:eU,LucideFan:tU,LucideFastForward:sU,LucideFeather:rU,LucideFence:nU,LucideFerrisWheel:aU,LucideFigma:iU,LucideFile:J4,LucideFileArchive:oU,LucideFileAudio:cU,LucideFileAudio2:lU,LucideFileAxis3D:s2,LucideFileAxis3d:s2,LucideFileBadge:uU,LucideFileBadge2:dU,LucideFileBarChart:r2,LucideFileBarChart2:n2,LucideFileBox:hU,LucideFileChartColumn:n2,LucideFileChartColumnIncreasing:r2,LucideFileChartLine:a2,LucideFileChartPie:i2,LucideFileCheck:pU,LucideFileCheck2:mU,LucideFileClock:fU,LucideFileCode:xU,LucideFileCode2:gU,LucideFileCog:o2,LucideFileCog2:o2,LucideFileDiff:yU,LucideFileDigit:vU,LucideFileDown:_U,LucideFileEdit:c2,LucideFileHeart:bU,LucideFileImage:H1,LucideFileInput:wU,LucideFileJson:kU,LucideFileJson2:jU,LucideFileKey:SU,LucideFileKey2:NU,LucideFileLineChart:a2,LucideFileLock:MU,LucideFileLock2:CU,LucideFileMinus:AU,LucideFileMinus2:TU,LucideFileMusic:EU,LucideFileOutput:PU,LucideFilePen:c2,LucideFilePenLine:l2,LucideFilePieChart:i2,LucideFilePlus:LU,LucideFilePlus2:IU,LucideFileQuestion:DU,LucideFileScan:OU,LucideFileSearch:FU,LucideFileSearch2:RU,LucideFileSignature:l2,LucideFileSliders:zU,LucideFileSpreadsheet:x0,LucideFileStack:VE,LucideFileSymlink:BU,LucideFileTerminal:$U,LucideFileText:Un,LucideFileType:UU,LucideFileType2:qU,LucideFileUp:VU,LucideFileUser:HU,LucideFileVideo:GU,LucideFileVideo2:WU,LucideFileVolume:ZU,LucideFileVolume2:KU,LucideFileWarning:YU,LucideFileX:QU,LucideFileX2:XU,LucideFiles:JU,LucideFilm:eu,LucideFilter:y0,LucideFilterX:eV,LucideFingerprint:tV,LucideFireExtinguisher:sV,LucideFish:aV,LucideFishOff:rV,LucideFishSymbol:nV,LucideFlag:v0,LucideFlagOff:iV,LucideFlagTriangleLeft:oV,LucideFlagTriangleRight:lV,LucideFlame:dp,LucideFlameKindling:cV,LucideFlashlight:uV,LucideFlashlightOff:dV,LucideFlaskConical:W1,LucideFlaskConicalOff:hV,LucideFlaskRound:mV,LucideFlipHorizontal:fV,LucideFlipHorizontal2:pV,LucideFlipVertical:xV,LucideFlipVertical2:gV,LucideFlower:yV,LucideFlower2:wg,LucideFocus:vV,LucideFoldHorizontal:_V,LucideFoldVertical:bV,LucideFolder:KV,LucideFolderArchive:wV,LucideFolderCheck:jV,LucideFolderClock:kV,LucideFolderClosed:NV,LucideFolderCode:SV,LucideFolderCog:d2,LucideFolderCog2:d2,LucideFolderDot:CV,LucideFolderDown:MV,LucideFolderEdit:u2,LucideFolderGit:AV,LucideFolderGit2:TV,LucideFolderHeart:EV,LucideFolderInput:PV,LucideFolderKanban:IV,LucideFolderKey:LV,LucideFolderLock:DV,LucideFolderMinus:OV,LucideFolderOpen:Oh,LucideFolderOpenDot:RV,LucideFolderOutput:FV,LucideFolderPen:u2,LucideFolderPlus:zV,LucideFolderRoot:BV,LucideFolderSearch:qV,LucideFolderSearch2:$V,LucideFolderSymlink:UV,LucideFolderSync:VV,LucideFolderTree:HV,LucideFolderUp:WV,LucideFolderX:GV,LucideFolders:ZV,LucideFootprints:YV,LucideForkKnife:sk,LucideForkKnifeCrossed:tk,LucideForklift:XV,LucideFormInput:R2,LucideForward:QV,LucideFrame:JV,LucideFramer:eH,LucideFrown:tH,LucideFuel:sH,LucideFullscreen:rH,LucideFunctionSquare:yj,LucideGalleryHorizontal:aH,LucideGalleryHorizontalEnd:nH,LucideGalleryThumbnails:iH,LucideGalleryVertical:lH,LucideGalleryVerticalEnd:oH,LucideGamepad:dH,LucideGamepad2:cH,LucideGanttChart:yw,LucideGanttChartSquare:xx,LucideGauge:uH,LucideGaugeCircle:Lw,LucideGavel:hH,LucideGem:mH,LucideGhost:Gk,LucideGift:uo,LucideGitBranch:fH,LucideGitBranchPlus:pH,LucideGitCommit:h2,LucideGitCommitHorizontal:h2,LucideGitCommitVertical:gH,LucideGitCompare:yH,LucideGitCompareArrows:xH,LucideGitFork:vH,LucideGitGraph:_H,LucideGitMerge:bH,LucideGitPullRequest:CH,LucideGitPullRequestArrow:wH,LucideGitPullRequestClosed:jH,LucideGitPullRequestCreate:NH,LucideGitPullRequestCreateArrow:kH,LucideGitPullRequestDraft:SH,LucideGithub:MH,LucideGitlab:TH,LucideGlassWater:AH,LucideGlasses:EH,LucideGlobe:up,LucideGlobe2:t2,LucideGlobeLock:PH,LucideGoal:IH,LucideGrab:LH,LucideGraduationCap:Yu,LucideGrape:DH,LucideGrid:Ym,LucideGrid2X2:p2,LucideGrid2X2Plus:m2,LucideGrid2x2:p2,LucideGrid2x2Check:OH,LucideGrid2x2Plus:m2,LucideGrid2x2X:RH,LucideGrid3X3:Ym,LucideGrid3x3:Ym,LucideGrip:zH,LucideGripHorizontal:FH,LucideGripVertical:Rh,LucideGroup:BH,LucideGuitar:$H,LucideHam:qH,LucideHammer:UH,LucideHand:HE,LucideHandCoins:VH,LucideHandHeart:HH,LucideHandHelping:f2,LucideHandMetal:WH,LucideHandPlatter:GH,LucideHandshake:KH,LucideHardDrive:WE,LucideHardDriveDownload:ZH,LucideHardDriveUpload:YH,LucideHardHat:XH,LucideHash:e5,LucideHaze:QH,LucideHdmiPort:JH,LucideHeading:nW,LucideHeading1:GE,LucideHeading2:KE,LucideHeading3:eW,LucideHeading4:tW,LucideHeading5:sW,LucideHeading6:rW,LucideHeadphoneOff:aW,LucideHeadphones:iW,LucideHeadset:oW,LucideHeart:Oi,LucideHeartCrack:lW,LucideHeartHandshake:cW,LucideHeartOff:dW,LucideHeartPulse:uW,LucideHeater:hW,LucideHelpCircle:Qy,LucideHelpingHand:f2,LucideHexagon:mW,LucideHighlighter:pW,LucideHistory:t5,LucideHome:Hn,LucideHop:gW,LucideHopOff:fW,LucideHospital:xW,LucideHotel:yW,LucideHourglass:vW,LucideHouse:Hn,LucideHousePlug:_W,LucideHousePlus:bW,LucideIceCream:x2,LucideIceCream2:g2,LucideIceCreamBowl:g2,LucideIceCreamCone:x2,LucideIdCard:wW,LucideImage:Xo,LucideImageDown:jW,LucideImageMinus:kW,LucideImageOff:NW,LucideImagePlay:SW,LucideImagePlus:_0,LucideImageUp:CW,LucideImageUpscale:MW,LucideImages:TW,LucideImport:AW,LucideInbox:EW,LucideIndent:v2,LucideIndentDecrease:y2,LucideIndentIncrease:v2,LucideIndianRupee:PW,LucideInfinity:IW,LucideInfo:ZE,LucideInspect:kj,LucideInspectionPanel:LW,LucideInstagram:zd,LucideItalic:s5,LucideIterationCcw:DW,LucideIterationCw:OW,LucideJapaneseYen:RW,LucideJoystick:FW,LucideKanban:Bx,LucideKanbanSquare:vj,LucideKanbanSquareDashed:hj,LucideKey:Sm,LucideKeyRound:Kk,LucideKeySquare:zW,LucideKeyboard:qW,LucideKeyboardMusic:BW,LucideKeyboardOff:$W,LucideLamp:KW,LucideLampCeiling:UW,LucideLampDesk:VW,LucideLampFloor:HW,LucideLampWallDown:WW,LucideLampWallUp:GW,LucideLandPlot:ZW,LucideLandmark:YW,LucideLanguages:XW,LucideLaptop:JW,LucideLaptop2:_2,LucideLaptopMinimal:_2,LucideLaptopMinimalCheck:QW,LucideLasso:tG,LucideLassoSelect:eG,LucideLaugh:sG,LucideLayers:aG,LucideLayers2:rG,LucideLayers3:nG,LucideLayout:Jy,LucideLayoutDashboard:Zk,LucideLayoutGrid:hp,LucideLayoutList:iG,LucideLayoutPanelLeft:oG,LucideLayoutPanelTop:lG,LucideLayoutTemplate:Yk,LucideLeaf:cG,LucideLeafyGreen:dG,LucideLectern:uG,LucideLetterText:hG,LucideLibrary:r5,LucideLibraryBig:mG,LucideLibrarySquare:_j,LucideLifeBuoy:n5,LucideLigature:pG,LucideLightbulb:G1,LucideLightbulbOff:fG,LucideLineChart:fw,LucideLink:Po,LucideLink2:Al,LucideLink2Off:gG,LucideLinkedin:Cm,LucideList:Fh,LucideListCheck:xG,LucideListChecks:yG,LucideListCollapse:vG,LucideListEnd:_G,LucideListFilter:bG,LucideListMinus:wG,LucideListMusic:jG,LucideListOrdered:b0,LucideListPlus:kG,LucideListRestart:NG,LucideListStart:SG,LucideListTodo:CG,LucideListTree:MG,LucideListVideo:TG,LucideListX:AG,LucideLoader:PG,LucideLoader2:Rs,LucideLoaderCircle:Rs,LucideLoaderPinwheel:EG,LucideLocate:YE,LucideLocateFixed:IG,LucideLocateOff:LG,LucideLock:Pu,LucideLockKeyhole:DG,LucideLockKeyholeOpen:b2,LucideLockOpen:w2,LucideLogIn:a5,LucideLogOut:i5,LucideLogs:OG,LucideLollipop:RG,LucideLuggage:FG,LucideMSquare:bj,LucideMagnet:zG,LucideMail:Ar,LucideMailCheck:BG,LucideMailMinus:$G,LucideMailOpen:qG,LucideMailPlus:UG,LucideMailQuestion:VG,LucideMailSearch:HG,LucideMailWarning:WG,LucideMailX:XE,LucideMailbox:GG,LucideMails:KG,LucideMap:iK,LucideMapPin:Pi,LucideMapPinCheck:YG,LucideMapPinCheckInside:ZG,LucideMapPinHouse:XG,LucideMapPinMinus:JG,LucideMapPinMinusInside:QG,LucideMapPinOff:eK,LucideMapPinPlus:sK,LucideMapPinPlusInside:tK,LucideMapPinX:nK,LucideMapPinXInside:rK,LucideMapPinned:aK,LucideMartini:oK,LucideMaximize:QE,LucideMaximize2:lK,LucideMedal:w0,LucideMegaphone:Ag,LucideMegaphoneOff:cK,LucideMeh:dK,LucideMemoryStick:uK,LucideMenu:JE,LucideMenuSquare:wj,LucideMerge:hK,LucideMessageCircle:mc,LucideMessageCircleCode:mK,LucideMessageCircleDashed:pK,LucideMessageCircleHeart:o5,LucideMessageCircleMore:fK,LucideMessageCircleOff:gK,LucideMessageCirclePlus:xK,LucideMessageCircleQuestion:eP,LucideMessageCircleReply:yK,LucideMessageCircleWarning:vK,LucideMessageCircleX:_K,LucideMessageSquare:ho,LucideMessageSquareCode:bK,LucideMessageSquareDashed:wK,LucideMessageSquareDiff:jK,LucideMessageSquareDot:kK,LucideMessageSquareHeart:NK,LucideMessageSquareLock:SK,LucideMessageSquareMore:tP,LucideMessageSquareOff:CK,LucideMessageSquarePlus:l5,LucideMessageSquareQuote:sP,LucideMessageSquareReply:MK,LucideMessageSquareShare:TK,LucideMessageSquareText:AK,LucideMessageSquareWarning:EK,LucideMessageSquareX:PK,LucideMessagesSquare:IK,LucideMic:rP,LucideMic2:j2,LucideMicOff:LK,LucideMicVocal:j2,LucideMicrochip:DK,LucideMicroscope:OK,LucideMicrowave:RK,LucideMilestone:FK,LucideMilk:BK,LucideMilkOff:zK,LucideMinimize:qK,LucideMinimize2:$K,LucideMinus:K1,LucideMinusCircle:Dw,LucideMinusSquare:jj,LucideMonitor:Xk,LucideMonitorCheck:UK,LucideMonitorCog:VK,LucideMonitorDot:HK,LucideMonitorDown:WK,LucideMonitorOff:GK,LucideMonitorPause:KK,LucideMonitorPlay:ZK,LucideMonitorSmartphone:YK,LucideMonitorSpeaker:XK,LucideMonitorStop:QK,LucideMonitorUp:JK,LucideMonitorX:eZ,LucideMoon:sZ,LucideMoonStar:tZ,LucideMoreHorizontal:Xp,LucideMoreVertical:xg,LucideMountain:nZ,LucideMountainSnow:rZ,LucideMouse:lZ,LucideMouseOff:aZ,LucideMousePointer:ym,LucideMousePointer2:iZ,LucideMousePointerBan:oZ,LucideMousePointerClick:Z1,LucideMousePointerSquareDashed:mj,LucideMove:bZ,LucideMove3D:k2,LucideMove3d:k2,LucideMoveDiagonal:dZ,LucideMoveDiagonal2:cZ,LucideMoveDown:mZ,LucideMoveDownLeft:uZ,LucideMoveDownRight:hZ,LucideMoveHorizontal:pZ,LucideMoveLeft:fZ,LucideMoveRight:gZ,LucideMoveUp:vZ,LucideMoveUpLeft:xZ,LucideMoveUpRight:yZ,LucideMoveVertical:_Z,LucideMusic:NZ,LucideMusic2:wZ,LucideMusic3:jZ,LucideMusic4:kZ,LucideNavigation:nP,LucideNavigation2:CZ,LucideNavigation2Off:SZ,LucideNavigationOff:MZ,LucideNetwork:TZ,LucideNewspaper:j0,LucideNfc:AZ,LucideNotebook:LZ,LucideNotebookPen:EZ,LucideNotebookTabs:PZ,LucideNotebookText:IZ,LucideNotepadText:OZ,LucideNotepadTextDashed:DZ,LucideNut:FZ,LucideNutOff:RZ,LucideOctagon:BZ,LucideOctagonAlert:N2,LucideOctagonMinus:zZ,LucideOctagonPause:S2,LucideOctagonX:C2,LucideOmega:$Z,LucideOption:qZ,LucideOrbit:UZ,LucideOrigami:VZ,LucideOutdent:y2,LucidePackage:cl,LucidePackage2:HZ,LucidePackageCheck:WZ,LucidePackageMinus:GZ,LucidePackageOpen:KZ,LucidePackagePlus:ZZ,LucidePackageSearch:YZ,LucidePackageX:XZ,LucidePaintBucket:QZ,LucidePaintRoller:JZ,LucidePaintbrush:eY,LucidePaintbrush2:M2,LucidePaintbrushVertical:M2,LucidePalette:El,LucidePalmtree:Hj,LucidePanelBottom:rY,LucidePanelBottomClose:tY,LucidePanelBottomDashed:T2,LucidePanelBottomInactive:T2,LucidePanelBottomOpen:sY,LucidePanelLeft:I2,LucidePanelLeftClose:A2,LucidePanelLeftDashed:E2,LucidePanelLeftInactive:E2,LucidePanelLeftOpen:P2,LucidePanelRight:iY,LucidePanelRightClose:nY,LucidePanelRightDashed:L2,LucidePanelRightInactive:L2,LucidePanelRightOpen:aY,LucidePanelTop:cY,LucidePanelTopClose:oY,LucidePanelTopDashed:D2,LucidePanelTopInactive:D2,LucidePanelTopOpen:lY,LucidePanelsLeftBottom:dY,LucidePanelsLeftRight:Qw,LucidePanelsRightBottom:uY,LucidePanelsTopBottom:B2,LucidePanelsTopLeft:Jy,LucidePaperclip:Qk,LucideParentheses:hY,LucideParkingCircle:Rw,LucideParkingCircleOff:Ow,LucideParkingMeter:mY,LucideParkingSquare:Sj,LucideParkingSquareOff:Nj,LucidePartyPopper:bd,LucidePause:mp,LucidePauseCircle:Fw,LucidePauseOctagon:S2,LucidePawPrint:pY,LucidePcCase:fY,LucidePen:Cx,LucidePenBox:Pc,LucidePenLine:Xv,LucidePenOff:gY,LucidePenSquare:Pc,LucidePenTool:Jk,LucidePencil:Ga,LucidePencilLine:xY,LucidePencilOff:yY,LucidePencilRuler:vY,LucidePentagon:_Y,LucidePercent:c5,LucidePercentCircle:zw,LucidePercentDiamond:e2,LucidePercentSquare:Cj,LucidePersonStanding:bY,LucidePhilippinePeso:wY,LucidePhone:ga,LucidePhoneCall:jY,LucidePhoneForwarded:kY,LucidePhoneIncoming:NY,LucidePhoneMissed:SY,LucidePhoneOff:CY,LucidePhoneOutgoing:MY,LucidePi:TY,LucidePiSquare:Mj,LucidePiano:AY,LucidePickaxe:EY,LucidePictureInPicture:IY,LucidePictureInPicture2:PY,LucidePieChart:vw,LucidePiggyBank:LY,LucidePilcrow:RY,LucidePilcrowLeft:DY,LucidePilcrowRight:OY,LucidePilcrowSquare:Tj,LucidePill:zY,LucidePillBottle:FY,LucidePin:Y1,LucidePinOff:aP,LucidePipette:BY,LucidePizza:$Y,LucidePlane:VY,LucidePlaneLanding:qY,LucidePlaneTakeoff:UY,LucidePlay:dl,LucidePlayCircle:mm,LucidePlaySquare:Aj,LucidePlug:iP,LucidePlug2:HY,LucidePlugZap:O2,LucidePlugZap2:O2,LucidePlus:Ys,LucidePlusCircle:Bw,LucidePlusSquare:Ej,LucidePocket:GY,LucidePocketKnife:WY,LucidePodcast:KY,LucidePointer:YY,LucidePointerOff:ZY,LucidePopcorn:XY,LucidePopsicle:QY,LucidePoundSterling:JY,LucidePower:oP,LucidePowerCircle:$w,LucidePowerOff:eX,LucidePowerSquare:Pj,LucidePresentation:lf,LucidePrinter:lP,LucidePrinterCheck:tX,LucideProjector:sX,LucideProportions:rX,LucidePuzzle:nX,LucidePyramid:aX,LucideQrCode:eN,LucideQuote:d5,LucideRabbit:iX,LucideRadar:oX,LucideRadiation:lX,LucideRadical:cX,LucideRadio:tN,LucideRadioReceiver:dX,LucideRadioTower:uX,LucideRadius:hX,LucideRailSymbol:mX,LucideRainbow:pX,LucideRat:fX,LucideRatio:gX,LucideReceipt:NX,LucideReceiptCent:xX,LucideReceiptEuro:yX,LucideReceiptIndianRupee:vX,LucideReceiptJapaneseYen:_X,LucideReceiptPoundSterling:bX,LucideReceiptRussianRuble:wX,LucideReceiptSwissFranc:jX,LucideReceiptText:kX,LucideRectangleEllipsis:R2,LucideRectangleHorizontal:SX,LucideRectangleVertical:CX,LucideRecycle:MX,LucideRedo:u5,LucideRedo2:TX,LucideRedoDot:AX,LucideRefreshCcw:PX,LucideRefreshCcwDot:EX,LucideRefreshCw:Ao,LucideRefreshCwOff:IX,LucideRefrigerator:LX,LucideRegex:DX,LucideRemoveFormatting:OX,LucideRepeat:cP,LucideRepeat1:RX,LucideRepeat2:FX,LucideReplace:BX,LucideReplaceAll:zX,LucideReply:dP,LucideReplyAll:$X,LucideRewind:qX,LucideRibbon:UX,LucideRocket:$x,LucideRockingChair:VX,LucideRollerCoaster:HX,LucideRotate3D:F2,LucideRotate3d:F2,LucideRotateCcw:k0,LucideRotateCcwSquare:WX,LucideRotateCw:uP,LucideRotateCwSquare:GX,LucideRoute:ZX,LucideRouteOff:KX,LucideRouter:YX,LucideRows:z2,LucideRows2:z2,LucideRows3:B2,LucideRows4:XX,LucideRss:QX,LucideRuler:JX,LucideRussianRuble:eQ,LucideSailboat:tQ,LucideSalad:sQ,LucideSandwich:rQ,LucideSatellite:aQ,LucideSatelliteDish:nQ,LucideSave:zh,LucideSaveAll:iQ,LucideSaveOff:oQ,LucideScale:lQ,LucideScale3D:$2,LucideScale3d:$2,LucideScaling:cQ,LucideScan:xQ,LucideScanBarcode:dQ,LucideScanEye:uQ,LucideScanFace:hQ,LucideScanLine:mQ,LucideScanQrCode:pQ,LucideScanSearch:fQ,LucideScanText:gQ,LucideScatterChart:_w,LucideSchool:yQ,LucideSchool2:Gj,LucideScissors:_Q,LucideScissorsLineDashed:vQ,LucideScissorsSquare:Ij,LucideScissorsSquareDashedBottom:aj,LucideScreenShare:wQ,LucideScreenShareOff:bQ,LucideScroll:kQ,LucideScrollText:jQ,LucideSearch:xn,LucideSearchCheck:NQ,LucideSearchCode:SQ,LucideSearchSlash:CQ,LucideSearchX:MQ,LucideSection:TQ,LucideSend:Pa,LucideSendHorizonal:q2,LucideSendHorizontal:q2,LucideSendToBack:AQ,LucideSeparatorHorizontal:EQ,LucideSeparatorVertical:PQ,LucideServer:OQ,LucideServerCog:IQ,LucideServerCrash:LQ,LucideServerOff:DQ,LucideSettings:Pl,LucideSettings2:hP,LucideShapes:RQ,LucideShare:mP,LucideShare2:nd,LucideSheet:FQ,LucideShell:zQ,LucideShield:Xu,LucideShieldAlert:BQ,LucideShieldBan:$Q,LucideShieldCheck:pP,LucideShieldClose:U2,LucideShieldEllipsis:qQ,LucideShieldHalf:UQ,LucideShieldMinus:VQ,LucideShieldOff:HQ,LucideShieldPlus:WQ,LucideShieldQuestion:GQ,LucideShieldX:U2,LucideShip:ZQ,LucideShipWheel:KQ,LucideShirt:YQ,LucideShoppingBag:qx,LucideShoppingBasket:XQ,LucideShoppingCart:vm,LucideShovel:QQ,LucideShowerHead:JQ,LucideShrink:eJ,LucideShrub:tJ,LucideShuffle:sN,LucideSidebar:I2,LucideSidebarClose:A2,LucideSidebarOpen:P2,LucideSigma:sJ,LucideSigmaSquare:Lj,LucideSignal:oJ,LucideSignalHigh:rJ,LucideSignalLow:nJ,LucideSignalMedium:aJ,LucideSignalZero:iJ,LucideSignature:lJ,LucideSignpost:dJ,LucideSignpostBig:cJ,LucideSiren:uJ,LucideSkipBack:hJ,LucideSkipForward:mJ,LucideSkull:pJ,LucideSlack:fJ,LucideSlash:gJ,LucideSlashSquare:Dj,LucideSlice:xJ,LucideSliders:V2,LucideSlidersHorizontal:fP,LucideSlidersVertical:V2,LucideSmartphone:N0,LucideSmartphoneCharging:yJ,LucideSmartphoneNfc:vJ,LucideSmile:bJ,LucideSmilePlus:_J,LucideSnail:wJ,LucideSnowflake:S1,LucideSofa:jJ,LucideSortAsc:ew,LucideSortDesc:Xb,LucideSoup:kJ,LucideSpace:NJ,LucideSpade:SJ,LucideSparkle:CJ,LucideSparkles:gn,LucideSpeaker:MJ,LucideSpeech:TJ,LucideSpellCheck:EJ,LucideSpellCheck2:AJ,LucideSpline:PJ,LucideSplit:IJ,LucideSplitSquareHorizontal:Oj,LucideSplitSquareVertical:Rj,LucideSprayCan:LJ,LucideSprout:DJ,LucideSquare:Ux,LucideSquareActivity:H2,LucideSquareArrowDown:K2,LucideSquareArrowDownLeft:W2,LucideSquareArrowDownRight:G2,LucideSquareArrowLeft:Z2,LucideSquareArrowOutDownLeft:Y2,LucideSquareArrowOutDownRight:X2,LucideSquareArrowOutUpLeft:Q2,LucideSquareArrowOutUpRight:J2,LucideSquareArrowRight:ej,LucideSquareArrowUp:rj,LucideSquareArrowUpLeft:tj,LucideSquareArrowUpRight:sj,LucideSquareAsterisk:nj,LucideSquareBottomDashedScissors:aj,LucideSquareChartGantt:xx,LucideSquareCheck:ij,LucideSquareCheckBig:e0,LucideSquareChevronDown:oj,LucideSquareChevronLeft:lj,LucideSquareChevronRight:cj,LucideSquareChevronUp:dj,LucideSquareCode:uj,LucideSquareDashed:pj,LucideSquareDashedBottom:RJ,LucideSquareDashedBottomCode:OJ,LucideSquareDashedKanban:hj,LucideSquareDashedMousePointer:mj,LucideSquareDivide:fj,LucideSquareDot:gj,LucideSquareEqual:xj,LucideSquareFunction:yj,LucideSquareGanttChart:xx,LucideSquareKanban:vj,LucideSquareLibrary:_j,LucideSquareM:bj,LucideSquareMenu:wj,LucideSquareMinus:jj,LucideSquareMousePointer:kj,LucideSquareParking:Sj,LucideSquareParkingOff:Nj,LucideSquarePen:Pc,LucideSquarePercent:Cj,LucideSquarePi:Mj,LucideSquarePilcrow:Tj,LucideSquarePlay:Aj,LucideSquarePlus:Ej,LucideSquarePower:Pj,LucideSquareRadical:FJ,LucideSquareScissors:Ij,LucideSquareSigma:Lj,LucideSquareSlash:Dj,LucideSquareSplitHorizontal:Oj,LucideSquareSplitVertical:Rj,LucideSquareSquare:zJ,LucideSquareStack:BJ,LucideSquareTerminal:Fj,LucideSquareUser:Bj,LucideSquareUserRound:zj,LucideSquareX:$j,LucideSquircle:$J,LucideSquirrel:qJ,LucideStamp:UJ,LucideStar:Gn,LucideStarHalf:VJ,LucideStarOff:HJ,LucideStars:gn,LucideStepBack:WJ,LucideStepForward:GJ,LucideStethoscope:KJ,LucideSticker:ZJ,LucideStickyNote:YJ,LucideStopCircle:Uw,LucideStore:XJ,LucideStretchHorizontal:QJ,LucideStretchVertical:JJ,LucideStrikethrough:eee,LucideSubscript:tee,LucideSubtitles:lw,LucideSun:X1,LucideSunDim:see,LucideSunMedium:ree,LucideSunMoon:nee,LucideSunSnow:aee,LucideSunrise:iee,LucideSunset:oee,LucideSuperscript:lee,LucideSwatchBook:cee,LucideSwissFranc:dee,LucideSwitchCamera:uee,LucideSword:hee,LucideSwords:mee,LucideSyringe:pee,LucideTable:gP,LucideTable2:h5,LucideTableCellsMerge:fee,LucideTableCellsSplit:gee,LucideTableColumnsSplit:xee,LucideTableOfContents:yee,LucideTableProperties:vee,LucideTableRowsSplit:_ee,LucideTablet:wee,LucideTabletSmartphone:bee,LucideTablets:jee,LucideTag:pp,LucideTags:kee,LucideTally1:Nee,LucideTally2:See,LucideTally3:Cee,LucideTally4:Mee,LucideTally5:Tee,LucideTangent:Aee,LucideTarget:Mm,LucideTelescope:Eee,LucideTent:Iee,LucideTentTree:Pee,LucideTerminal:Lee,LucideTerminalSquare:Fj,LucideTestTube:Dee,LucideTestTube2:qj,LucideTestTubeDiagonal:qj,LucideTestTubes:Oee,LucideText:$ee,LucideTextCursor:Fee,LucideTextCursorInput:Ree,LucideTextQuote:zee,LucideTextSearch:Bee,LucideTextSelect:Uj,LucideTextSelection:Uj,LucideTheater:qee,LucideThermometer:Hee,LucideThermometerSnowflake:Uee,LucideThermometerSun:Vee,LucideThumbsDown:xP,LucideThumbsUp:lu,LucideTicket:yP,LucideTicketCheck:Wee,LucideTicketMinus:Gee,LucideTicketPercent:Kee,LucideTicketPlus:Zee,LucideTicketSlash:Yee,LucideTicketX:Xee,LucideTickets:Jee,LucideTicketsPlane:Qee,LucideTimer:ste,LucideTimerOff:ete,LucideTimerReset:tte,LucideToggleLeft:rte,LucideToggleRight:nte,LucideToilet:ate,LucideTornado:ite,LucideTorus:ote,LucideTouchpad:cte,LucideTouchpadOff:lte,LucideTowerControl:dte,LucideToyBrick:ute,LucideTractor:hte,LucideTrafficCone:mte,LucideTrain:Vj,LucideTrainFront:fte,LucideTrainFrontTunnel:pte,LucideTrainTrack:gte,LucideTramFront:Vj,LucideTrash:xte,LucideTrash2:Cr,LucideTreeDeciduous:yte,LucideTreePalm:Hj,LucideTreePine:Q1,LucideTrees:vte,LucideTrello:_te,LucideTrendingDown:rN,LucideTrendingUp:Vc,LucideTrendingUpDown:bte,LucideTriangle:jte,LucideTriangleAlert:jh,LucideTriangleRight:wte,LucideTrophy:so,LucideTruck:vP,LucideTurtle:kte,LucideTv:Ste,LucideTv2:Wj,LucideTvMinimal:Wj,LucideTvMinimalPlay:Nte,LucideTwitch:Cte,LucideTwitter:Mte,LucideType:Ate,LucideTypeOutline:Tte,LucideUmbrella:Pte,LucideUmbrellaOff:Ete,LucideUnderline:Ite,LucideUndo:m5,LucideUndo2:Lte,LucideUndoDot:Dte,LucideUnfoldHorizontal:Ote,LucideUnfoldVertical:Rte,LucideUngroup:Fte,LucideUniversity:Gj,LucideUnlink:nN,LucideUnlink2:zte,LucideUnlock:w2,LucideUnlockKeyhole:b2,LucideUnplug:Bte,LucideUpload:xi,LucideUploadCloud:Zw,LucideUsb:$te,LucideUser:mo,LucideUser2:Jj,LucideUserCheck:J1,LucideUserCheck2:Kj,LucideUserCircle:Hw,LucideUserCircle2:Vw,LucideUserCog:_P,LucideUserCog2:Zj,LucideUserMinus:bP,LucideUserMinus2:Yj,LucideUserPen:qte,LucideUserPlus:pc,LucideUserPlus2:Xj,LucideUserRound:Jj,LucideUserRoundCheck:Kj,LucideUserRoundCog:Zj,LucideUserRoundMinus:Yj,LucideUserRoundPen:Ute,LucideUserRoundPlus:Xj,LucideUserRoundSearch:Vte,LucideUserRoundX:Qj,LucideUserSearch:Hte,LucideUserSquare:Bj,LucideUserSquare2:zj,LucideUserX:Wte,LucideUserX2:Qj,LucideUsers:xr,LucideUsers2:ek,LucideUsersRound:ek,LucideUtensils:sk,LucideUtensilsCrossed:tk,LucideUtilityPole:Gte,LucideVariable:wP,LucideVault:Kte,LucideVegan:Zte,LucideVenetianMask:Yte,LucideVerified:rw,LucideVibrate:Qte,LucideVibrateOff:Xte,LucideVideo:Cn,LucideVideoOff:Jte,LucideVideotape:ese,LucideView:tse,LucideVoicemail:sse,LucideVolleyball:rse,LucideVolume:lse,LucideVolume1:nse,LucideVolume2:ase,LucideVolumeOff:ise,LucideVolumeX:ose,LucideVote:cse,LucideWallet:jP,LucideWallet2:rk,LucideWalletCards:dse,LucideWalletMinimal:rk,LucideWallpaper:use,LucideWand:hse,LucideWand2:t0,LucideWandSparkles:t0,LucideWarehouse:mse,LucideWashingMachine:pse,LucideWatch:fse,LucideWaves:gse,LucideWaypoints:xse,LucideWebcam:yse,LucideWebhook:_se,LucideWebhookOff:vse,LucideWeight:bse,LucideWheat:jse,LucideWheatOff:wse,LucideWholeWord:kse,LucideWifi:Tse,LucideWifiHigh:Nse,LucideWifiLow:Sse,LucideWifiOff:Cse,LucideWifiZero:Mse,LucideWind:Ese,LucideWindArrowDown:Ase,LucideWine:Ise,LucideWineOff:Pse,LucideWorkflow:Lse,LucideWorm:Dse,LucideWrapText:Ose,LucideWrench:Vx,LucideX:Vr,LucideXCircle:bc,LucideXOctagon:C2,LucideXSquare:$j,LucideYoutube:Rse,LucideZap:Tm,LucideZapOff:Fse,LucideZoomIn:p5,LucideZoomOut:f5,Luggage:FG,LuggageIcon:FG,MSquare:bj,MSquareIcon:bj,Magnet:zG,MagnetIcon:zG,Mail:Ar,MailCheck:BG,MailCheckIcon:BG,MailIcon:Ar,MailMinus:$G,MailMinusIcon:$G,MailOpen:qG,MailOpenIcon:qG,MailPlus:UG,MailPlusIcon:UG,MailQuestion:VG,MailQuestionIcon:VG,MailSearch:HG,MailSearchIcon:HG,MailWarning:WG,MailWarningIcon:WG,MailX:XE,MailXIcon:XE,Mailbox:GG,MailboxIcon:GG,Mails:KG,MailsIcon:KG,Map:iK,MapIcon:iK,MapPin:Pi,MapPinCheck:YG,MapPinCheckIcon:YG,MapPinCheckInside:ZG,MapPinCheckInsideIcon:ZG,MapPinHouse:XG,MapPinHouseIcon:XG,MapPinIcon:Pi,MapPinMinus:JG,MapPinMinusIcon:JG,MapPinMinusInside:QG,MapPinMinusInsideIcon:QG,MapPinOff:eK,MapPinOffIcon:eK,MapPinPlus:sK,MapPinPlusIcon:sK,MapPinPlusInside:tK,MapPinPlusInsideIcon:tK,MapPinX:nK,MapPinXIcon:nK,MapPinXInside:rK,MapPinXInsideIcon:rK,MapPinned:aK,MapPinnedIcon:aK,Martini:oK,MartiniIcon:oK,Maximize:QE,Maximize2:lK,Maximize2Icon:lK,MaximizeIcon:QE,Medal:w0,MedalIcon:w0,Megaphone:Ag,MegaphoneIcon:Ag,MegaphoneOff:cK,MegaphoneOffIcon:cK,Meh:dK,MehIcon:dK,MemoryStick:uK,MemoryStickIcon:uK,Menu:JE,MenuIcon:JE,MenuSquare:wj,MenuSquareIcon:wj,Merge:hK,MergeIcon:hK,MessageCircle:mc,MessageCircleCode:mK,MessageCircleCodeIcon:mK,MessageCircleDashed:pK,MessageCircleDashedIcon:pK,MessageCircleHeart:o5,MessageCircleHeartIcon:o5,MessageCircleIcon:mc,MessageCircleMore:fK,MessageCircleMoreIcon:fK,MessageCircleOff:gK,MessageCircleOffIcon:gK,MessageCirclePlus:xK,MessageCirclePlusIcon:xK,MessageCircleQuestion:eP,MessageCircleQuestionIcon:eP,MessageCircleReply:yK,MessageCircleReplyIcon:yK,MessageCircleWarning:vK,MessageCircleWarningIcon:vK,MessageCircleX:_K,MessageCircleXIcon:_K,MessageSquare:ho,MessageSquareCode:bK,MessageSquareCodeIcon:bK,MessageSquareDashed:wK,MessageSquareDashedIcon:wK,MessageSquareDiff:jK,MessageSquareDiffIcon:jK,MessageSquareDot:kK,MessageSquareDotIcon:kK,MessageSquareHeart:NK,MessageSquareHeartIcon:NK,MessageSquareIcon:ho,MessageSquareLock:SK,MessageSquareLockIcon:SK,MessageSquareMore:tP,MessageSquareMoreIcon:tP,MessageSquareOff:CK,MessageSquareOffIcon:CK,MessageSquarePlus:l5,MessageSquarePlusIcon:l5,MessageSquareQuote:sP,MessageSquareQuoteIcon:sP,MessageSquareReply:MK,MessageSquareReplyIcon:MK,MessageSquareShare:TK,MessageSquareShareIcon:TK,MessageSquareText:AK,MessageSquareTextIcon:AK,MessageSquareWarning:EK,MessageSquareWarningIcon:EK,MessageSquareX:PK,MessageSquareXIcon:PK,MessagesSquare:IK,MessagesSquareIcon:IK,Mic:rP,Mic2:j2,Mic2Icon:j2,MicIcon:rP,MicOff:LK,MicOffIcon:LK,MicVocal:j2,MicVocalIcon:j2,Microchip:DK,MicrochipIcon:DK,Microscope:OK,MicroscopeIcon:OK,Microwave:RK,MicrowaveIcon:RK,Milestone:FK,MilestoneIcon:FK,Milk:BK,MilkIcon:BK,MilkOff:zK,MilkOffIcon:zK,Minimize:qK,Minimize2:$K,Minimize2Icon:$K,MinimizeIcon:qK,Minus:K1,MinusCircle:Dw,MinusCircleIcon:Dw,MinusIcon:K1,MinusSquare:jj,MinusSquareIcon:jj,Monitor:Xk,MonitorCheck:UK,MonitorCheckIcon:UK,MonitorCog:VK,MonitorCogIcon:VK,MonitorDot:HK,MonitorDotIcon:HK,MonitorDown:WK,MonitorDownIcon:WK,MonitorIcon:Xk,MonitorOff:GK,MonitorOffIcon:GK,MonitorPause:KK,MonitorPauseIcon:KK,MonitorPlay:ZK,MonitorPlayIcon:ZK,MonitorSmartphone:YK,MonitorSmartphoneIcon:YK,MonitorSpeaker:XK,MonitorSpeakerIcon:XK,MonitorStop:QK,MonitorStopIcon:QK,MonitorUp:JK,MonitorUpIcon:JK,MonitorX:eZ,MonitorXIcon:eZ,Moon:sZ,MoonIcon:sZ,MoonStar:tZ,MoonStarIcon:tZ,MoreHorizontal:Xp,MoreHorizontalIcon:Xp,MoreVertical:xg,MoreVerticalIcon:xg,Mountain:nZ,MountainIcon:nZ,MountainSnow:rZ,MountainSnowIcon:rZ,Mouse:lZ,MouseIcon:lZ,MouseOff:aZ,MouseOffIcon:aZ,MousePointer:ym,MousePointer2:iZ,MousePointer2Icon:iZ,MousePointerBan:oZ,MousePointerBanIcon:oZ,MousePointerClick:Z1,MousePointerClickIcon:Z1,MousePointerIcon:ym,MousePointerSquareDashed:mj,MousePointerSquareDashedIcon:mj,Move:bZ,Move3D:k2,Move3DIcon:k2,Move3d:k2,Move3dIcon:k2,MoveDiagonal:dZ,MoveDiagonal2:cZ,MoveDiagonal2Icon:cZ,MoveDiagonalIcon:dZ,MoveDown:mZ,MoveDownIcon:mZ,MoveDownLeft:uZ,MoveDownLeftIcon:uZ,MoveDownRight:hZ,MoveDownRightIcon:hZ,MoveHorizontal:pZ,MoveHorizontalIcon:pZ,MoveIcon:bZ,MoveLeft:fZ,MoveLeftIcon:fZ,MoveRight:gZ,MoveRightIcon:gZ,MoveUp:vZ,MoveUpIcon:vZ,MoveUpLeft:xZ,MoveUpLeftIcon:xZ,MoveUpRight:yZ,MoveUpRightIcon:yZ,MoveVertical:_Z,MoveVerticalIcon:_Z,Music:NZ,Music2:wZ,Music2Icon:wZ,Music3:jZ,Music3Icon:jZ,Music4:kZ,Music4Icon:kZ,MusicIcon:NZ,Navigation:nP,Navigation2:CZ,Navigation2Icon:CZ,Navigation2Off:SZ,Navigation2OffIcon:SZ,NavigationIcon:nP,NavigationOff:MZ,NavigationOffIcon:MZ,Network:TZ,NetworkIcon:TZ,Newspaper:j0,NewspaperIcon:j0,Nfc:AZ,NfcIcon:AZ,Notebook:LZ,NotebookIcon:LZ,NotebookPen:EZ,NotebookPenIcon:EZ,NotebookTabs:PZ,NotebookTabsIcon:PZ,NotebookText:IZ,NotebookTextIcon:IZ,NotepadText:OZ,NotepadTextDashed:DZ,NotepadTextDashedIcon:DZ,NotepadTextIcon:OZ,Nut:FZ,NutIcon:FZ,NutOff:RZ,NutOffIcon:RZ,Octagon:BZ,OctagonAlert:N2,OctagonAlertIcon:N2,OctagonIcon:BZ,OctagonMinus:zZ,OctagonMinusIcon:zZ,OctagonPause:S2,OctagonPauseIcon:S2,OctagonX:C2,OctagonXIcon:C2,Omega:$Z,OmegaIcon:$Z,Option:qZ,OptionIcon:qZ,Orbit:UZ,OrbitIcon:UZ,Origami:VZ,OrigamiIcon:VZ,Outdent:y2,OutdentIcon:y2,Package:cl,Package2:HZ,Package2Icon:HZ,PackageCheck:WZ,PackageCheckIcon:WZ,PackageIcon:cl,PackageMinus:GZ,PackageMinusIcon:GZ,PackageOpen:KZ,PackageOpenIcon:KZ,PackagePlus:ZZ,PackagePlusIcon:ZZ,PackageSearch:YZ,PackageSearchIcon:YZ,PackageX:XZ,PackageXIcon:XZ,PaintBucket:QZ,PaintBucketIcon:QZ,PaintRoller:JZ,PaintRollerIcon:JZ,Paintbrush:eY,Paintbrush2:M2,Paintbrush2Icon:M2,PaintbrushIcon:eY,PaintbrushVertical:M2,PaintbrushVerticalIcon:M2,Palette:El,PaletteIcon:El,Palmtree:Hj,PalmtreeIcon:Hj,PanelBottom:rY,PanelBottomClose:tY,PanelBottomCloseIcon:tY,PanelBottomDashed:T2,PanelBottomDashedIcon:T2,PanelBottomIcon:rY,PanelBottomInactive:T2,PanelBottomInactiveIcon:T2,PanelBottomOpen:sY,PanelBottomOpenIcon:sY,PanelLeft:I2,PanelLeftClose:A2,PanelLeftCloseIcon:A2,PanelLeftDashed:E2,PanelLeftDashedIcon:E2,PanelLeftIcon:I2,PanelLeftInactive:E2,PanelLeftInactiveIcon:E2,PanelLeftOpen:P2,PanelLeftOpenIcon:P2,PanelRight:iY,PanelRightClose:nY,PanelRightCloseIcon:nY,PanelRightDashed:L2,PanelRightDashedIcon:L2,PanelRightIcon:iY,PanelRightInactive:L2,PanelRightInactiveIcon:L2,PanelRightOpen:aY,PanelRightOpenIcon:aY,PanelTop:cY,PanelTopClose:oY,PanelTopCloseIcon:oY,PanelTopDashed:D2,PanelTopDashedIcon:D2,PanelTopIcon:cY,PanelTopInactive:D2,PanelTopInactiveIcon:D2,PanelTopOpen:lY,PanelTopOpenIcon:lY,PanelsLeftBottom:dY,PanelsLeftBottomIcon:dY,PanelsLeftRight:Qw,PanelsLeftRightIcon:Qw,PanelsRightBottom:uY,PanelsRightBottomIcon:uY,PanelsTopBottom:B2,PanelsTopBottomIcon:B2,PanelsTopLeft:Jy,PanelsTopLeftIcon:Jy,Paperclip:Qk,PaperclipIcon:Qk,Parentheses:hY,ParenthesesIcon:hY,ParkingCircle:Rw,ParkingCircleIcon:Rw,ParkingCircleOff:Ow,ParkingCircleOffIcon:Ow,ParkingMeter:mY,ParkingMeterIcon:mY,ParkingSquare:Sj,ParkingSquareIcon:Sj,ParkingSquareOff:Nj,ParkingSquareOffIcon:Nj,PartyPopper:bd,PartyPopperIcon:bd,Pause:mp,PauseCircle:Fw,PauseCircleIcon:Fw,PauseIcon:mp,PauseOctagon:S2,PauseOctagonIcon:S2,PawPrint:pY,PawPrintIcon:pY,PcCase:fY,PcCaseIcon:fY,Pen:Cx,PenBox:Pc,PenBoxIcon:Pc,PenIcon:Cx,PenLine:Xv,PenLineIcon:Xv,PenOff:gY,PenOffIcon:gY,PenSquare:Pc,PenSquareIcon:Pc,PenTool:Jk,PenToolIcon:Jk,Pencil:Ga,PencilIcon:Ga,PencilLine:xY,PencilLineIcon:xY,PencilOff:yY,PencilOffIcon:yY,PencilRuler:vY,PencilRulerIcon:vY,Pentagon:_Y,PentagonIcon:_Y,Percent:c5,PercentCircle:zw,PercentCircleIcon:zw,PercentDiamond:e2,PercentDiamondIcon:e2,PercentIcon:c5,PercentSquare:Cj,PercentSquareIcon:Cj,PersonStanding:bY,PersonStandingIcon:bY,PhilippinePeso:wY,PhilippinePesoIcon:wY,Phone:ga,PhoneCall:jY,PhoneCallIcon:jY,PhoneForwarded:kY,PhoneForwardedIcon:kY,PhoneIcon:ga,PhoneIncoming:NY,PhoneIncomingIcon:NY,PhoneMissed:SY,PhoneMissedIcon:SY,PhoneOff:CY,PhoneOffIcon:CY,PhoneOutgoing:MY,PhoneOutgoingIcon:MY,Pi:TY,PiIcon:TY,PiSquare:Mj,PiSquareIcon:Mj,Piano:AY,PianoIcon:AY,Pickaxe:EY,PickaxeIcon:EY,PictureInPicture:IY,PictureInPicture2:PY,PictureInPicture2Icon:PY,PictureInPictureIcon:IY,PieChart:vw,PieChartIcon:vw,PiggyBank:LY,PiggyBankIcon:LY,Pilcrow:RY,PilcrowIcon:RY,PilcrowLeft:DY,PilcrowLeftIcon:DY,PilcrowRight:OY,PilcrowRightIcon:OY,PilcrowSquare:Tj,PilcrowSquareIcon:Tj,Pill:zY,PillBottle:FY,PillBottleIcon:FY,PillIcon:zY,Pin:Y1,PinIcon:Y1,PinOff:aP,PinOffIcon:aP,Pipette:BY,PipetteIcon:BY,Pizza:$Y,PizzaIcon:$Y,Plane:VY,PlaneIcon:VY,PlaneLanding:qY,PlaneLandingIcon:qY,PlaneTakeoff:UY,PlaneTakeoffIcon:UY,Play:dl,PlayCircle:mm,PlayCircleIcon:mm,PlayIcon:dl,PlaySquare:Aj,PlaySquareIcon:Aj,Plug:iP,Plug2:HY,Plug2Icon:HY,PlugIcon:iP,PlugZap:O2,PlugZap2:O2,PlugZap2Icon:O2,PlugZapIcon:O2,Plus:Ys,PlusCircle:Bw,PlusCircleIcon:Bw,PlusIcon:Ys,PlusSquare:Ej,PlusSquareIcon:Ej,Pocket:GY,PocketIcon:GY,PocketKnife:WY,PocketKnifeIcon:WY,Podcast:KY,PodcastIcon:KY,Pointer:YY,PointerIcon:YY,PointerOff:ZY,PointerOffIcon:ZY,Popcorn:XY,PopcornIcon:XY,Popsicle:QY,PopsicleIcon:QY,PoundSterling:JY,PoundSterlingIcon:JY,Power:oP,PowerCircle:$w,PowerCircleIcon:$w,PowerIcon:oP,PowerOff:eX,PowerOffIcon:eX,PowerSquare:Pj,PowerSquareIcon:Pj,Presentation:lf,PresentationIcon:lf,Printer:lP,PrinterCheck:tX,PrinterCheckIcon:tX,PrinterIcon:lP,Projector:sX,ProjectorIcon:sX,Proportions:rX,ProportionsIcon:rX,Puzzle:nX,PuzzleIcon:nX,Pyramid:aX,PyramidIcon:aX,QrCode:eN,QrCodeIcon:eN,Quote:d5,QuoteIcon:d5,Rabbit:iX,RabbitIcon:iX,Radar:oX,RadarIcon:oX,Radiation:lX,RadiationIcon:lX,Radical:cX,RadicalIcon:cX,Radio:tN,RadioIcon:tN,RadioReceiver:dX,RadioReceiverIcon:dX,RadioTower:uX,RadioTowerIcon:uX,Radius:hX,RadiusIcon:hX,RailSymbol:mX,RailSymbolIcon:mX,Rainbow:pX,RainbowIcon:pX,Rat:fX,RatIcon:fX,Ratio:gX,RatioIcon:gX,Receipt:NX,ReceiptCent:xX,ReceiptCentIcon:xX,ReceiptEuro:yX,ReceiptEuroIcon:yX,ReceiptIcon:NX,ReceiptIndianRupee:vX,ReceiptIndianRupeeIcon:vX,ReceiptJapaneseYen:_X,ReceiptJapaneseYenIcon:_X,ReceiptPoundSterling:bX,ReceiptPoundSterlingIcon:bX,ReceiptRussianRuble:wX,ReceiptRussianRubleIcon:wX,ReceiptSwissFranc:jX,ReceiptSwissFrancIcon:jX,ReceiptText:kX,ReceiptTextIcon:kX,RectangleEllipsis:R2,RectangleEllipsisIcon:R2,RectangleHorizontal:SX,RectangleHorizontalIcon:SX,RectangleVertical:CX,RectangleVerticalIcon:CX,Recycle:MX,RecycleIcon:MX,Redo:u5,Redo2:TX,Redo2Icon:TX,RedoDot:AX,RedoDotIcon:AX,RedoIcon:u5,RefreshCcw:PX,RefreshCcwDot:EX,RefreshCcwDotIcon:EX,RefreshCcwIcon:PX,RefreshCw:Ao,RefreshCwIcon:Ao,RefreshCwOff:IX,RefreshCwOffIcon:IX,Refrigerator:LX,RefrigeratorIcon:LX,Regex:DX,RegexIcon:DX,RemoveFormatting:OX,RemoveFormattingIcon:OX,Repeat:cP,Repeat1:RX,Repeat1Icon:RX,Repeat2:FX,Repeat2Icon:FX,RepeatIcon:cP,Replace:BX,ReplaceAll:zX,ReplaceAllIcon:zX,ReplaceIcon:BX,Reply:dP,ReplyAll:$X,ReplyAllIcon:$X,ReplyIcon:dP,Rewind:qX,RewindIcon:qX,Ribbon:UX,RibbonIcon:UX,Rocket:$x,RocketIcon:$x,RockingChair:VX,RockingChairIcon:VX,RollerCoaster:HX,RollerCoasterIcon:HX,Rotate3D:F2,Rotate3DIcon:F2,Rotate3d:F2,Rotate3dIcon:F2,RotateCcw:k0,RotateCcwIcon:k0,RotateCcwSquare:WX,RotateCcwSquareIcon:WX,RotateCw:uP,RotateCwIcon:uP,RotateCwSquare:GX,RotateCwSquareIcon:GX,Route:ZX,RouteIcon:ZX,RouteOff:KX,RouteOffIcon:KX,Router:YX,RouterIcon:YX,Rows:z2,Rows2:z2,Rows2Icon:z2,Rows3:B2,Rows3Icon:B2,Rows4:XX,Rows4Icon:XX,RowsIcon:z2,Rss:QX,RssIcon:QX,Ruler:JX,RulerIcon:JX,RussianRuble:eQ,RussianRubleIcon:eQ,Sailboat:tQ,SailboatIcon:tQ,Salad:sQ,SaladIcon:sQ,Sandwich:rQ,SandwichIcon:rQ,Satellite:aQ,SatelliteDish:nQ,SatelliteDishIcon:nQ,SatelliteIcon:aQ,Save:zh,SaveAll:iQ,SaveAllIcon:iQ,SaveIcon:zh,SaveOff:oQ,SaveOffIcon:oQ,Scale:lQ,Scale3D:$2,Scale3DIcon:$2,Scale3d:$2,Scale3dIcon:$2,ScaleIcon:lQ,Scaling:cQ,ScalingIcon:cQ,Scan:xQ,ScanBarcode:dQ,ScanBarcodeIcon:dQ,ScanEye:uQ,ScanEyeIcon:uQ,ScanFace:hQ,ScanFaceIcon:hQ,ScanIcon:xQ,ScanLine:mQ,ScanLineIcon:mQ,ScanQrCode:pQ,ScanQrCodeIcon:pQ,ScanSearch:fQ,ScanSearchIcon:fQ,ScanText:gQ,ScanTextIcon:gQ,ScatterChart:_w,ScatterChartIcon:_w,School:yQ,School2:Gj,School2Icon:Gj,SchoolIcon:yQ,Scissors:_Q,ScissorsIcon:_Q,ScissorsLineDashed:vQ,ScissorsLineDashedIcon:vQ,ScissorsSquare:Ij,ScissorsSquareDashedBottom:aj,ScissorsSquareDashedBottomIcon:aj,ScissorsSquareIcon:Ij,ScreenShare:wQ,ScreenShareIcon:wQ,ScreenShareOff:bQ,ScreenShareOffIcon:bQ,Scroll:kQ,ScrollIcon:kQ,ScrollText:jQ,ScrollTextIcon:jQ,Search:xn,SearchCheck:NQ,SearchCheckIcon:NQ,SearchCode:SQ,SearchCodeIcon:SQ,SearchIcon:xn,SearchSlash:CQ,SearchSlashIcon:CQ,SearchX:MQ,SearchXIcon:MQ,Section:TQ,SectionIcon:TQ,Send:Pa,SendHorizonal:q2,SendHorizonalIcon:q2,SendHorizontal:q2,SendHorizontalIcon:q2,SendIcon:Pa,SendToBack:AQ,SendToBackIcon:AQ,SeparatorHorizontal:EQ,SeparatorHorizontalIcon:EQ,SeparatorVertical:PQ,SeparatorVerticalIcon:PQ,Server:OQ,ServerCog:IQ,ServerCogIcon:IQ,ServerCrash:LQ,ServerCrashIcon:LQ,ServerIcon:OQ,ServerOff:DQ,ServerOffIcon:DQ,Settings:Pl,Settings2:hP,Settings2Icon:hP,SettingsIcon:Pl,Shapes:RQ,ShapesIcon:RQ,Share:mP,Share2:nd,Share2Icon:nd,ShareIcon:mP,Sheet:FQ,SheetIcon:FQ,Shell:zQ,ShellIcon:zQ,Shield:Xu,ShieldAlert:BQ,ShieldAlertIcon:BQ,ShieldBan:$Q,ShieldBanIcon:$Q,ShieldCheck:pP,ShieldCheckIcon:pP,ShieldClose:U2,ShieldCloseIcon:U2,ShieldEllipsis:qQ,ShieldEllipsisIcon:qQ,ShieldHalf:UQ,ShieldHalfIcon:UQ,ShieldIcon:Xu,ShieldMinus:VQ,ShieldMinusIcon:VQ,ShieldOff:HQ,ShieldOffIcon:HQ,ShieldPlus:WQ,ShieldPlusIcon:WQ,ShieldQuestion:GQ,ShieldQuestionIcon:GQ,ShieldX:U2,ShieldXIcon:U2,Ship:ZQ,ShipIcon:ZQ,ShipWheel:KQ,ShipWheelIcon:KQ,Shirt:YQ,ShirtIcon:YQ,ShoppingBag:qx,ShoppingBagIcon:qx,ShoppingBasket:XQ,ShoppingBasketIcon:XQ,ShoppingCart:vm,ShoppingCartIcon:vm,Shovel:QQ,ShovelIcon:QQ,ShowerHead:JQ,ShowerHeadIcon:JQ,Shrink:eJ,ShrinkIcon:eJ,Shrub:tJ,ShrubIcon:tJ,Shuffle:sN,ShuffleIcon:sN,Sidebar:I2,SidebarClose:A2,SidebarCloseIcon:A2,SidebarIcon:I2,SidebarOpen:P2,SidebarOpenIcon:P2,Sigma:sJ,SigmaIcon:sJ,SigmaSquare:Lj,SigmaSquareIcon:Lj,Signal:oJ,SignalHigh:rJ,SignalHighIcon:rJ,SignalIcon:oJ,SignalLow:nJ,SignalLowIcon:nJ,SignalMedium:aJ,SignalMediumIcon:aJ,SignalZero:iJ,SignalZeroIcon:iJ,Signature:lJ,SignatureIcon:lJ,Signpost:dJ,SignpostBig:cJ,SignpostBigIcon:cJ,SignpostIcon:dJ,Siren:uJ,SirenIcon:uJ,SkipBack:hJ,SkipBackIcon:hJ,SkipForward:mJ,SkipForwardIcon:mJ,Skull:pJ,SkullIcon:pJ,Slack:fJ,SlackIcon:fJ,Slash:gJ,SlashIcon:gJ,SlashSquare:Dj,SlashSquareIcon:Dj,Slice:xJ,SliceIcon:xJ,Sliders:V2,SlidersHorizontal:fP,SlidersHorizontalIcon:fP,SlidersIcon:V2,SlidersVertical:V2,SlidersVerticalIcon:V2,Smartphone:N0,SmartphoneCharging:yJ,SmartphoneChargingIcon:yJ,SmartphoneIcon:N0,SmartphoneNfc:vJ,SmartphoneNfcIcon:vJ,Smile:bJ,SmileIcon:bJ,SmilePlus:_J,SmilePlusIcon:_J,Snail:wJ,SnailIcon:wJ,Snowflake:S1,SnowflakeIcon:S1,Sofa:jJ,SofaIcon:jJ,SortAsc:ew,SortAscIcon:ew,SortDesc:Xb,SortDescIcon:Xb,Soup:kJ,SoupIcon:kJ,Space:NJ,SpaceIcon:NJ,Spade:SJ,SpadeIcon:SJ,Sparkle:CJ,SparkleIcon:CJ,Sparkles:gn,SparklesIcon:gn,Speaker:MJ,SpeakerIcon:MJ,Speech:TJ,SpeechIcon:TJ,SpellCheck:EJ,SpellCheck2:AJ,SpellCheck2Icon:AJ,SpellCheckIcon:EJ,Spline:PJ,SplineIcon:PJ,Split:IJ,SplitIcon:IJ,SplitSquareHorizontal:Oj,SplitSquareHorizontalIcon:Oj,SplitSquareVertical:Rj,SplitSquareVerticalIcon:Rj,SprayCan:LJ,SprayCanIcon:LJ,Sprout:DJ,SproutIcon:DJ,Square:Ux,SquareActivity:H2,SquareActivityIcon:H2,SquareArrowDown:K2,SquareArrowDownIcon:K2,SquareArrowDownLeft:W2,SquareArrowDownLeftIcon:W2,SquareArrowDownRight:G2,SquareArrowDownRightIcon:G2,SquareArrowLeft:Z2,SquareArrowLeftIcon:Z2,SquareArrowOutDownLeft:Y2,SquareArrowOutDownLeftIcon:Y2,SquareArrowOutDownRight:X2,SquareArrowOutDownRightIcon:X2,SquareArrowOutUpLeft:Q2,SquareArrowOutUpLeftIcon:Q2,SquareArrowOutUpRight:J2,SquareArrowOutUpRightIcon:J2,SquareArrowRight:ej,SquareArrowRightIcon:ej,SquareArrowUp:rj,SquareArrowUpIcon:rj,SquareArrowUpLeft:tj,SquareArrowUpLeftIcon:tj,SquareArrowUpRight:sj,SquareArrowUpRightIcon:sj,SquareAsterisk:nj,SquareAsteriskIcon:nj,SquareBottomDashedScissors:aj,SquareBottomDashedScissorsIcon:aj,SquareChartGantt:xx,SquareChartGanttIcon:xx,SquareCheck:ij,SquareCheckBig:e0,SquareCheckBigIcon:e0,SquareCheckIcon:ij,SquareChevronDown:oj,SquareChevronDownIcon:oj,SquareChevronLeft:lj,SquareChevronLeftIcon:lj,SquareChevronRight:cj,SquareChevronRightIcon:cj,SquareChevronUp:dj,SquareChevronUpIcon:dj,SquareCode:uj,SquareCodeIcon:uj,SquareDashed:pj,SquareDashedBottom:RJ,SquareDashedBottomCode:OJ,SquareDashedBottomCodeIcon:OJ,SquareDashedBottomIcon:RJ,SquareDashedIcon:pj,SquareDashedKanban:hj,SquareDashedKanbanIcon:hj,SquareDashedMousePointer:mj,SquareDashedMousePointerIcon:mj,SquareDivide:fj,SquareDivideIcon:fj,SquareDot:gj,SquareDotIcon:gj,SquareEqual:xj,SquareEqualIcon:xj,SquareFunction:yj,SquareFunctionIcon:yj,SquareGanttChart:xx,SquareGanttChartIcon:xx,SquareIcon:Ux,SquareKanban:vj,SquareKanbanIcon:vj,SquareLibrary:_j,SquareLibraryIcon:_j,SquareM:bj,SquareMIcon:bj,SquareMenu:wj,SquareMenuIcon:wj,SquareMinus:jj,SquareMinusIcon:jj,SquareMousePointer:kj,SquareMousePointerIcon:kj,SquareParking:Sj,SquareParkingIcon:Sj,SquareParkingOff:Nj,SquareParkingOffIcon:Nj,SquarePen:Pc,SquarePenIcon:Pc,SquarePercent:Cj,SquarePercentIcon:Cj,SquarePi:Mj,SquarePiIcon:Mj,SquarePilcrow:Tj,SquarePilcrowIcon:Tj,SquarePlay:Aj,SquarePlayIcon:Aj,SquarePlus:Ej,SquarePlusIcon:Ej,SquarePower:Pj,SquarePowerIcon:Pj,SquareRadical:FJ,SquareRadicalIcon:FJ,SquareScissors:Ij,SquareScissorsIcon:Ij,SquareSigma:Lj,SquareSigmaIcon:Lj,SquareSlash:Dj,SquareSlashIcon:Dj,SquareSplitHorizontal:Oj,SquareSplitHorizontalIcon:Oj,SquareSplitVertical:Rj,SquareSplitVerticalIcon:Rj,SquareSquare:zJ,SquareSquareIcon:zJ,SquareStack:BJ,SquareStackIcon:BJ,SquareTerminal:Fj,SquareTerminalIcon:Fj,SquareUser:Bj,SquareUserIcon:Bj,SquareUserRound:zj,SquareUserRoundIcon:zj,SquareX:$j,SquareXIcon:$j,Squircle:$J,SquircleIcon:$J,Squirrel:qJ,SquirrelIcon:qJ,Stamp:UJ,StampIcon:UJ,Star:Gn,StarHalf:VJ,StarHalfIcon:VJ,StarIcon:Gn,StarOff:HJ,StarOffIcon:HJ,Stars:gn,StarsIcon:gn,StepBack:WJ,StepBackIcon:WJ,StepForward:GJ,StepForwardIcon:GJ,Stethoscope:KJ,StethoscopeIcon:KJ,Sticker:ZJ,StickerIcon:ZJ,StickyNote:YJ,StickyNoteIcon:YJ,StopCircle:Uw,StopCircleIcon:Uw,Store:XJ,StoreIcon:XJ,StretchHorizontal:QJ,StretchHorizontalIcon:QJ,StretchVertical:JJ,StretchVerticalIcon:JJ,Strikethrough:eee,StrikethroughIcon:eee,Subscript:tee,SubscriptIcon:tee,Subtitles:lw,SubtitlesIcon:lw,Sun:X1,SunDim:see,SunDimIcon:see,SunIcon:X1,SunMedium:ree,SunMediumIcon:ree,SunMoon:nee,SunMoonIcon:nee,SunSnow:aee,SunSnowIcon:aee,Sunrise:iee,SunriseIcon:iee,Sunset:oee,SunsetIcon:oee,Superscript:lee,SuperscriptIcon:lee,SwatchBook:cee,SwatchBookIcon:cee,SwissFranc:dee,SwissFrancIcon:dee,SwitchCamera:uee,SwitchCameraIcon:uee,Sword:hee,SwordIcon:hee,Swords:mee,SwordsIcon:mee,Syringe:pee,SyringeIcon:pee,Table:gP,Table2:h5,Table2Icon:h5,TableCellsMerge:fee,TableCellsMergeIcon:fee,TableCellsSplit:gee,TableCellsSplitIcon:gee,TableColumnsSplit:xee,TableColumnsSplitIcon:xee,TableIcon:gP,TableOfContents:yee,TableOfContentsIcon:yee,TableProperties:vee,TablePropertiesIcon:vee,TableRowsSplit:_ee,TableRowsSplitIcon:_ee,Tablet:wee,TabletIcon:wee,TabletSmartphone:bee,TabletSmartphoneIcon:bee,Tablets:jee,TabletsIcon:jee,Tag:pp,TagIcon:pp,Tags:kee,TagsIcon:kee,Tally1:Nee,Tally1Icon:Nee,Tally2:See,Tally2Icon:See,Tally3:Cee,Tally3Icon:Cee,Tally4:Mee,Tally4Icon:Mee,Tally5:Tee,Tally5Icon:Tee,Tangent:Aee,TangentIcon:Aee,Target:Mm,TargetIcon:Mm,Telescope:Eee,TelescopeIcon:Eee,Tent:Iee,TentIcon:Iee,TentTree:Pee,TentTreeIcon:Pee,Terminal:Lee,TerminalIcon:Lee,TerminalSquare:Fj,TerminalSquareIcon:Fj,TestTube:Dee,TestTube2:qj,TestTube2Icon:qj,TestTubeDiagonal:qj,TestTubeDiagonalIcon:qj,TestTubeIcon:Dee,TestTubes:Oee,TestTubesIcon:Oee,Text:$ee,TextCursor:Fee,TextCursorIcon:Fee,TextCursorInput:Ree,TextCursorInputIcon:Ree,TextIcon:$ee,TextQuote:zee,TextQuoteIcon:zee,TextSearch:Bee,TextSearchIcon:Bee,TextSelect:Uj,TextSelectIcon:Uj,TextSelection:Uj,TextSelectionIcon:Uj,Theater:qee,TheaterIcon:qee,Thermometer:Hee,ThermometerIcon:Hee,ThermometerSnowflake:Uee,ThermometerSnowflakeIcon:Uee,ThermometerSun:Vee,ThermometerSunIcon:Vee,ThumbsDown:xP,ThumbsDownIcon:xP,ThumbsUp:lu,ThumbsUpIcon:lu,Ticket:yP,TicketCheck:Wee,TicketCheckIcon:Wee,TicketIcon:yP,TicketMinus:Gee,TicketMinusIcon:Gee,TicketPercent:Kee,TicketPercentIcon:Kee,TicketPlus:Zee,TicketPlusIcon:Zee,TicketSlash:Yee,TicketSlashIcon:Yee,TicketX:Xee,TicketXIcon:Xee,Tickets:Jee,TicketsIcon:Jee,TicketsPlane:Qee,TicketsPlaneIcon:Qee,Timer:ste,TimerIcon:ste,TimerOff:ete,TimerOffIcon:ete,TimerReset:tte,TimerResetIcon:tte,ToggleLeft:rte,ToggleLeftIcon:rte,ToggleRight:nte,ToggleRightIcon:nte,Toilet:ate,ToiletIcon:ate,Tornado:ite,TornadoIcon:ite,Torus:ote,TorusIcon:ote,Touchpad:cte,TouchpadIcon:cte,TouchpadOff:lte,TouchpadOffIcon:lte,TowerControl:dte,TowerControlIcon:dte,ToyBrick:ute,ToyBrickIcon:ute,Tractor:hte,TractorIcon:hte,TrafficCone:mte,TrafficConeIcon:mte,Train:Vj,TrainFront:fte,TrainFrontIcon:fte,TrainFrontTunnel:pte,TrainFrontTunnelIcon:pte,TrainIcon:Vj,TrainTrack:gte,TrainTrackIcon:gte,TramFront:Vj,TramFrontIcon:Vj,Trash:xte,Trash2:Cr,Trash2Icon:Cr,TrashIcon:xte,TreeDeciduous:yte,TreeDeciduousIcon:yte,TreePalm:Hj,TreePalmIcon:Hj,TreePine:Q1,TreePineIcon:Q1,Trees:vte,TreesIcon:vte,Trello:_te,TrelloIcon:_te,TrendingDown:rN,TrendingDownIcon:rN,TrendingUp:Vc,TrendingUpDown:bte,TrendingUpDownIcon:bte,TrendingUpIcon:Vc,Triangle:jte,TriangleAlert:jh,TriangleAlertIcon:jh,TriangleIcon:jte,TriangleRight:wte,TriangleRightIcon:wte,Trophy:so,TrophyIcon:so,Truck:vP,TruckIcon:vP,Turtle:kte,TurtleIcon:kte,Tv:Ste,Tv2:Wj,Tv2Icon:Wj,TvIcon:Ste,TvMinimal:Wj,TvMinimalIcon:Wj,TvMinimalPlay:Nte,TvMinimalPlayIcon:Nte,Twitch:Cte,TwitchIcon:Cte,Twitter:Mte,TwitterIcon:Mte,Type:Ate,TypeIcon:Ate,TypeOutline:Tte,TypeOutlineIcon:Tte,Umbrella:Pte,UmbrellaIcon:Pte,UmbrellaOff:Ete,UmbrellaOffIcon:Ete,Underline:Ite,UnderlineIcon:Ite,Undo:m5,Undo2:Lte,Undo2Icon:Lte,UndoDot:Dte,UndoDotIcon:Dte,UndoIcon:m5,UnfoldHorizontal:Ote,UnfoldHorizontalIcon:Ote,UnfoldVertical:Rte,UnfoldVerticalIcon:Rte,Ungroup:Fte,UngroupIcon:Fte,University:Gj,UniversityIcon:Gj,Unlink:nN,Unlink2:zte,Unlink2Icon:zte,UnlinkIcon:nN,Unlock:w2,UnlockIcon:w2,UnlockKeyhole:b2,UnlockKeyholeIcon:b2,Unplug:Bte,UnplugIcon:Bte,Upload:xi,UploadCloud:Zw,UploadCloudIcon:Zw,UploadIcon:xi,Usb:$te,UsbIcon:$te,User:mo,User2:Jj,User2Icon:Jj,UserCheck:J1,UserCheck2:Kj,UserCheck2Icon:Kj,UserCheckIcon:J1,UserCircle:Hw,UserCircle2:Vw,UserCircle2Icon:Vw,UserCircleIcon:Hw,UserCog:_P,UserCog2:Zj,UserCog2Icon:Zj,UserCogIcon:_P,UserIcon:mo,UserMinus:bP,UserMinus2:Yj,UserMinus2Icon:Yj,UserMinusIcon:bP,UserPen:qte,UserPenIcon:qte,UserPlus:pc,UserPlus2:Xj,UserPlus2Icon:Xj,UserPlusIcon:pc,UserRound:Jj,UserRoundCheck:Kj,UserRoundCheckIcon:Kj,UserRoundCog:Zj,UserRoundCogIcon:Zj,UserRoundIcon:Jj,UserRoundMinus:Yj,UserRoundMinusIcon:Yj,UserRoundPen:Ute,UserRoundPenIcon:Ute,UserRoundPlus:Xj,UserRoundPlusIcon:Xj,UserRoundSearch:Vte,UserRoundSearchIcon:Vte,UserRoundX:Qj,UserRoundXIcon:Qj,UserSearch:Hte,UserSearchIcon:Hte,UserSquare:Bj,UserSquare2:zj,UserSquare2Icon:zj,UserSquareIcon:Bj,UserX:Wte,UserX2:Qj,UserX2Icon:Qj,UserXIcon:Wte,Users:xr,Users2:ek,Users2Icon:ek,UsersIcon:xr,UsersRound:ek,UsersRoundIcon:ek,Utensils:sk,UtensilsCrossed:tk,UtensilsCrossedIcon:tk,UtensilsIcon:sk,UtilityPole:Gte,UtilityPoleIcon:Gte,Variable:wP,VariableIcon:wP,Vault:Kte,VaultIcon:Kte,Vegan:Zte,VeganIcon:Zte,VenetianMask:Yte,VenetianMaskIcon:Yte,Verified:rw,VerifiedIcon:rw,Vibrate:Qte,VibrateIcon:Qte,VibrateOff:Xte,VibrateOffIcon:Xte,Video:Cn,VideoIcon:Cn,VideoOff:Jte,VideoOffIcon:Jte,Videotape:ese,VideotapeIcon:ese,View:tse,ViewIcon:tse,Voicemail:sse,VoicemailIcon:sse,Volleyball:rse,VolleyballIcon:rse,Volume:lse,Volume1:nse,Volume1Icon:nse,Volume2:ase,Volume2Icon:ase,VolumeIcon:lse,VolumeOff:ise,VolumeOffIcon:ise,VolumeX:ose,VolumeXIcon:ose,Vote:cse,VoteIcon:cse,Wallet:jP,Wallet2:rk,Wallet2Icon:rk,WalletCards:dse,WalletCardsIcon:dse,WalletIcon:jP,WalletMinimal:rk,WalletMinimalIcon:rk,Wallpaper:use,WallpaperIcon:use,Wand:hse,Wand2:t0,Wand2Icon:t0,WandIcon:hse,WandSparkles:t0,WandSparklesIcon:t0,Warehouse:mse,WarehouseIcon:mse,WashingMachine:pse,WashingMachineIcon:pse,Watch:fse,WatchIcon:fse,Waves:gse,WavesIcon:gse,Waypoints:xse,WaypointsIcon:xse,Webcam:yse,WebcamIcon:yse,Webhook:_se,WebhookIcon:_se,WebhookOff:vse,WebhookOffIcon:vse,Weight:bse,WeightIcon:bse,Wheat:jse,WheatIcon:jse,WheatOff:wse,WheatOffIcon:wse,WholeWord:kse,WholeWordIcon:kse,Wifi:Tse,WifiHigh:Nse,WifiHighIcon:Nse,WifiIcon:Tse,WifiLow:Sse,WifiLowIcon:Sse,WifiOff:Cse,WifiOffIcon:Cse,WifiZero:Mse,WifiZeroIcon:Mse,Wind:Ese,WindArrowDown:Ase,WindArrowDownIcon:Ase,WindIcon:Ese,Wine:Ise,WineIcon:Ise,WineOff:Pse,WineOffIcon:Pse,Workflow:Lse,WorkflowIcon:Lse,Worm:Dse,WormIcon:Dse,WrapText:Ose,WrapTextIcon:Ose,Wrench:Vx,WrenchIcon:Vx,X:Vr,XCircle:bc,XCircleIcon:bc,XIcon:Vr,XOctagon:C2,XOctagonIcon:C2,XSquare:$j,XSquareIcon:$j,Youtube:Rse,YoutubeIcon:Rse,Zap:Tm,ZapIcon:Tm,ZapOff:Fse,ZapOffIcon:Fse,ZoomIn:p5,ZoomInIcon:p5,ZoomOut:f5,ZoomOutIcon:f5,createLucideIcon:G,icons:uot},Symbol.toStringTag,{value:"Module"})),$ve="-",hot=t=>{const s=pot(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split($ve);return i[0]===""&&i.length!==1&&i.shift(),G8e(i,s)||mot(l)},getConflictingClassGroupIds:(l,i)=>{const d=r[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},G8e=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?G8e(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join($ve);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},$Ce=/^\[(.+)\]$/,mot=t=>{if($Ce.test(t)){const s=$Ce.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},pot=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return got(Object.entries(t.classGroups),r).forEach(([o,l])=>{bfe(l,n,o,s)}),n},bfe=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:qCe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(fot(a)){bfe(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{bfe(l,qCe(s,o),r,n)})})},qCe=(t,s)=>{let r=t;return s.split($ve).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},fot=t=>t.isThemeGetter,got=(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,xot=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)}}},K8e="!",yot=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const d=[];let u=0,f=0,g;for(let j=0;jf?g-f:void 0;return{modifiers:d,hasImportantModifier:_,baseClassName:b,maybePostfixModifierPosition:w}};return r?i=>r({className:i,parseClassName:l}):l},vot=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},_ot=t=>({cache:xot(t.cacheSize),parseClassName:yot(t),...hot(t)}),bot=/\s+/,wot=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(bot);let i="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{modifiers:f,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:_}=r(u);let b=!!_,w=n(b?v.substring(0,_):v);if(!w){if(!b){i=u+(i.length>0?" "+i:i);continue}if(w=n(v),!w){i=u+(i.length>0?" "+i:i);continue}b=!1}const j=vot(f).join(":"),N=g?j+K8e:j,S=N+w;if(o.includes(S))continue;o.push(S);const A=a(w,b);for(let I=0;I0?" "+i:i)}return i};function jot(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;ng(f),t());return r=_ot(u),n=r.cache.get,a=r.cache.set,o=i,i(d)}function i(d){const u=n(d);if(u)return u;const f=wot(d,r);return a(d,f),f}return function(){return o(jot.apply(null,arguments))}}const zl=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},Y8e=/^\[(?:([a-z-]+):)?(.+)\]$/i,Not=/^\d+\/\d+$/,Sot=new Set(["px","full","screen"]),Cot=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Mot=/\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$/,Tot=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Aot=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Eot=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ry=t=>g5(t)||Sot.has(t)||Not.test(t),Rv=t=>Y3(t,"length",zot),g5=t=>!!t&&!Number.isNaN(Number(t)),Yue=t=>Y3(t,"number",g5),IA=t=>!!t&&Number.isInteger(Number(t)),Pot=t=>t.endsWith("%")&&g5(t.slice(0,-1)),Di=t=>Y8e.test(t),Fv=t=>Cot.test(t),Iot=new Set(["length","size","percentage"]),Lot=t=>Y3(t,Iot,X8e),Dot=t=>Y3(t,"position",X8e),Oot=new Set(["image","url"]),Rot=t=>Y3(t,Oot,$ot),Fot=t=>Y3(t,"",Bot),LA=()=>!0,Y3=(t,s,r)=>{const n=Y8e.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},zot=t=>Mot.test(t)&&!Tot.test(t),X8e=()=>!1,Bot=t=>Aot.test(t),$ot=t=>Eot.test(t),qot=()=>{const t=zl("colors"),s=zl("spacing"),r=zl("blur"),n=zl("brightness"),a=zl("borderColor"),o=zl("borderRadius"),l=zl("borderSpacing"),i=zl("borderWidth"),d=zl("contrast"),u=zl("grayscale"),f=zl("hueRotate"),g=zl("invert"),v=zl("gap"),_=zl("gradientColorStops"),b=zl("gradientColorStopPositions"),w=zl("inset"),j=zl("margin"),N=zl("opacity"),S=zl("padding"),A=zl("saturate"),I=zl("scale"),L=zl("sepia"),F=zl("skew"),$=zl("space"),q=zl("translate"),H=()=>["auto","contain","none"],U=()=>["auto","hidden","clip","visible","scroll"],Q=()=>["auto",Di,s],se=()=>[Di,s],te=()=>["",Ry,Rv],Y=()=>["auto",g5,Di],ce=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],oe=()=>["solid","dashed","dotted","double","none"],le=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>["start","end","center","between","around","evenly","stretch"],xe=()=>["","0",Di],be=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ye=()=>[g5,Di];return{cacheSize:500,separator:":",theme:{colors:[LA],spacing:[Ry,Rv],blur:["none","",Fv,Di],brightness:ye(),borderColor:[t],borderRadius:["none","","full",Fv,Di],borderSpacing:se(),borderWidth:te(),contrast:ye(),grayscale:xe(),hueRotate:ye(),invert:xe(),gap:se(),gradientColorStops:[t],gradientColorStopPositions:[Pot,Rv],inset:Q(),margin:Q(),opacity:ye(),padding:se(),saturate:ye(),scale:ye(),sepia:xe(),skew:ye(),space:se(),translate:se()},classGroups:{aspect:[{aspect:["auto","square","video",Di]}],container:["container"],columns:[{columns:[Fv]}],"break-after":[{"break-after":be()}],"break-before":[{"break-before":be()}],"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(),Di]}],overflow:[{overflow:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],overscroll:[{overscroll:H()}],"overscroll-x":[{"overscroll-x":H()}],"overscroll-y":[{"overscroll-y":H()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",IA,Di]}],basis:[{basis:Q()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Di]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",IA,Di]}],"grid-cols":[{"grid-cols":[LA]}],"col-start-end":[{col:["auto",{span:["full",IA,Di]},Di]}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":[LA]}],"row-start-end":[{row:["auto",{span:[IA,Di]},Di]}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Di]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Di]}],gap:[{gap:[v]}],"gap-x":[{"gap-x":[v]}],"gap-y":[{"gap-y":[v]}],"justify-content":[{justify:["normal",...de()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...de(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...de(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Di,s]}],"min-w":[{"min-w":[Di,s,"min","max","fit"]}],"max-w":[{"max-w":[Di,s,"none","full","min","max","fit","prose",{screen:[Fv]},Fv]}],h:[{h:[Di,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Di,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Di,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Di,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Fv,Rv]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Yue]}],"font-family":[{font:[LA]}],"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",Di]}],"line-clamp":[{"line-clamp":["none",g5,Yue]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ry,Di]}],"list-image":[{"list-image":["none",Di]}],"list-style-type":[{list:["none","disc","decimal",Di]}],"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:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ry,Rv]}],"underline-offset":[{"underline-offset":["auto",Ry,Di]}],"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:se()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Di]}],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",Di]}],"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(),Dot]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Lot]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Rot]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[_]}],"gradient-via":[{via:[_]}],"gradient-to":[{to:[_]}],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:[...oe(),"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:oe()}],"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:["",...oe()]}],"outline-offset":[{"outline-offset":[Ry,Di]}],"outline-w":[{outline:[Ry,Rv]}],"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":[Ry,Rv]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Fv,Fot]}],"shadow-color":[{shadow:[LA]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...le(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":le()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",Fv,Di]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[g]}],saturate:[{saturate:[A]}],sepia:[{sepia:[L]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[A]}],"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",Di]}],duration:[{duration:ye()}],ease:[{ease:["linear","in","out","in-out",Di]}],delay:[{delay:ye()}],animate:[{animate:["none","spin","ping","pulse","bounce",Di]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[IA,Di]}],"translate-x":[{"translate-x":[q]}],"translate-y":[{"translate-y":[q]}],"skew-x":[{"skew-x":[F]}],"skew-y":[{"skew-y":[F]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Di]}],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",Di]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":se()}],"scroll-mx":[{"scroll-mx":se()}],"scroll-my":[{"scroll-my":se()}],"scroll-ms":[{"scroll-ms":se()}],"scroll-me":[{"scroll-me":se()}],"scroll-mt":[{"scroll-mt":se()}],"scroll-mr":[{"scroll-mr":se()}],"scroll-mb":[{"scroll-mb":se()}],"scroll-ml":[{"scroll-ml":se()}],"scroll-p":[{"scroll-p":se()}],"scroll-px":[{"scroll-px":se()}],"scroll-py":[{"scroll-py":se()}],"scroll-ps":[{"scroll-ps":se()}],"scroll-pe":[{"scroll-pe":se()}],"scroll-pt":[{"scroll-pt":se()}],"scroll-pr":[{"scroll-pr":se()}],"scroll-pb":[{"scroll-pb":se()}],"scroll-pl":[{"scroll-pl":se()}],"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",Di]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Ry,Rv,Yue]}],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"]}}},Uot=kot(qot);function It(...t){return Uot(Ri(t))}function Sl(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 UCe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function $ie(t){return t?t.replace(/<[^>]*>/g,""):""}const Vot=lot,Q8e=M.forwardRef(({className:t,...s},r)=>e.jsx(F8e,{ref:r,className:It("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));Q8e.displayName=F8e.displayName;const Hot=VN("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"}}),J8e=M.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(z8e,{ref:n,className:It(Hot({variant:s}),t),...r}));J8e.displayName=z8e.displayName;const Wot=M.forwardRef(({className:t,...s},r)=>e.jsx(q8e,{ref:r,className:It("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...s}));Wot.displayName=q8e.displayName;const eRe=M.forwardRef(({className:t,...s},r)=>e.jsx(U8e,{ref:r,className:It("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Vr,{className:"h-4 w-4"})}));eRe.displayName=U8e.displayName;const tRe=M.forwardRef(({className:t,...s},r)=>e.jsx(B8e,{ref:r,className:It("text-sm font-semibold",t),...s}));tRe.displayName=B8e.displayName;const sRe=M.forwardRef(({className:t,...s},r)=>e.jsx($8e,{ref:r,className:It("text-sm opacity-90",t),...s}));sRe.displayName=$8e.displayName;function Got(){const{toasts:t}=La();return e.jsxs(Vot,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(J8e,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(tRe,{children:r}),n&&e.jsx(sRe,{children:n})]}),a,e.jsx(eRe,{})]},s)}),e.jsx(Q8e,{})]})}var VCe=["light","dark"],Kot="(prefers-color-scheme: dark)",Zot=M.createContext(void 0),Yot={setTheme:t=>{},themes:[]},Xot=()=>{var t;return(t=M.useContext(Zot))!=null?t:Yot};M.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:d})=>{let u=o==="system",f=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(b=>`'${b}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,g=a?VCe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",v=(b,w=!1,j=!0)=>{let N=l?l[b]:b,S=w?b+"|| ''":`'${N}'`,A="";return a&&j&&!w&&VCe.includes(b)&&(A+=`d.style.colorScheme = '${b}';`),r==="class"?w||N?A+=`c.add(${S})`:A+="null":N&&(A+=`d[s](n,${S})`),A},_=t?`!function(){${f}${v(t)}}()`:n?`!function(){try{${f}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${Kot}',m=window.matchMedia(t);if(m.media!==t||m.matches){${v("dark")}}else{${v("light")}}}else if(e){${l?`var x=${JSON.stringify(l)};`:""}${v(l?"x[e]":"e",!0)}}${u?"":"else{"+v(o,!1,!1)+"}"}${g}}catch(e){}}()`:`!function(){try{${f}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${v(l?"x[e]":"e",!0)}}else{${v(o,!1,!1)};}${g}}catch(t){}}();`;return M.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var Qot=t=>{switch(t){case"success":return tlt;case"info":return rlt;case"warning":return slt;case"error":return nlt;default:return null}},Jot=Array(12).fill(0),elt=({visible:t,className:s})=>ut.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ut.createElement("div",{className:"sonner-spinner"},Jot.map((r,n)=>ut.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),tlt=ut.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ut.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"})),slt=ut.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ut.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"})),rlt=ut.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ut.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"})),nlt=ut.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ut.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"})),alt=ut.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"},ut.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ut.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ilt=()=>{let[t,s]=ut.useState(document.hidden);return ut.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},wfe=1,olt=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let s=this.subscribers.indexOf(t);this.subscribers.splice(s,1)}),this.publish=t=>{this.subscribers.forEach(s=>s(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var s;let{message:r,...n}=t,a=typeof(t==null?void 0:t.id)=="number"||((s=t.id)==null?void 0:s.length)>0?t.id:wfe++,o=this.toasts.find(i=>i.id===a),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),o?this.toasts=this.toasts.map(i=>i.id===a?(this.publish({...i,...t,id:a,title:r}),{...i,...t,id:a,dismissible:l,title:r}):i):this.addToast({title:r,...n,dismissible:l,id:a}),a},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(s=>{this.subscribers.forEach(r=>r({id:s.id,dismiss:!0}))}),this.subscribers.forEach(s=>s({id:t,dismiss:!0})),t),this.message=(t,s)=>this.create({...s,message:t}),this.error=(t,s)=>this.create({...s,message:t,type:"error"}),this.success=(t,s)=>this.create({...s,type:"success",message:t}),this.info=(t,s)=>this.create({...s,type:"info",message:t}),this.warning=(t,s)=>this.create({...s,type:"warning",message:t}),this.loading=(t,s)=>this.create({...s,type:"loading",message:t}),this.promise=(t,s)=>{if(!s)return;let r;s.loading!==void 0&&(r=this.create({...s,promise:t,type:"loading",message:s.loading,description:typeof s.description!="function"?s.description:void 0}));let n=t instanceof Promise?t:t(),a=r!==void 0,o,l=n.then(async d=>{if(o=["resolve",d],ut.isValidElement(d))a=!1,this.create({id:r,type:"default",message:d});else if(clt(d)&&!d.ok){a=!1;let u=typeof s.error=="function"?await s.error(`HTTP error! status: ${d.status}`):s.error,f=typeof s.description=="function"?await s.description(`HTTP error! status: ${d.status}`):s.description;this.create({id:r,type:"error",message:u,description:f})}else if(s.success!==void 0){a=!1;let u=typeof s.success=="function"?await s.success(d):s.success,f=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"success",message:u,description:f})}}).catch(async d=>{if(o=["reject",d],s.error!==void 0){a=!1;let u=typeof s.error=="function"?await s.error(d):s.error,f=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"error",message:u,description:f})}}).finally(()=>{var d;a&&(this.dismiss(r),r=void 0),(d=s.finally)==null||d.call(s)}),i=()=>new Promise((d,u)=>l.then(()=>o[0]==="reject"?u(o[1]):d(o[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:i}:Object.assign(r,{unwrap:i})},this.custom=(t,s)=>{let r=(s==null?void 0:s.id)||wfe++;return this.create({jsx:t(r),id:r,...s}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},um=new olt,llt=(t,s)=>{let r=(s==null?void 0:s.id)||wfe++;return um.addToast({title:t,...s,id:r}),r},clt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",dlt=llt,ult=()=>um.toasts,hlt=()=>um.getActiveToasts(),ge=Object.assign(dlt,{success:um.success,info:um.info,warning:um.warning,error:um.error,custom:um.custom,message:um.message,promise:um.promise,dismiss:um.dismiss,loading:um.loading},{getHistory:ult,getToasts:hlt});function mlt(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))}mlt(`: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 s8(t){return t.label!==void 0}var plt=3,flt="32px",glt="16px",HCe=4e3,xlt=356,ylt=14,vlt=20,_lt=200;function eg(...t){return t.filter(Boolean).join(" ")}function blt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var wlt=t=>{var s,r,n,a,o,l,i,d,u,f,g;let{invert:v,toast:_,unstyled:b,interacting:w,setHeights:j,visibleToasts:N,heights:S,index:A,toasts:I,expanded:L,removeToast:F,defaultRichColors:$,closeButton:q,style:H,cancelButtonStyle:U,actionButtonStyle:Q,className:se="",descriptionClassName:te="",duration:Y,position:ce,gap:oe,loadingIcon:le,expandByDefault:de,classNames:xe,icons:be,closeButtonAriaLabel:ye="Close toast",pauseWhenPageIsHidden:ve}=t,[ke,Ge]=ut.useState(null),[Ne,Ae]=ut.useState(null),[Pe,Fe]=ut.useState(!1),[Ie,Ve]=ut.useState(!1),[dt,Le]=ut.useState(!1),[Rt,fe]=ut.useState(!1),[Qe,at]=ut.useState(!1),[rt,je]=ut.useState(0),[mt,He]=ut.useState(0),ct=ut.useRef(_.duration||Y||HCe),We=ut.useRef(null),Ze=ut.useRef(null),ht=A===0,Ke=A+1<=N,qe=_.type,Je=_.dismissible!==!1,Lt=_.className||"",zt=_.descriptionClassName||"",is=ut.useMemo(()=>S.findIndex(Zt=>Zt.toastId===_.id)||0,[S,_.id]),Kt=ut.useMemo(()=>{var Zt;return(Zt=_.closeButton)!=null?Zt:q},[_.closeButton,q]),Qt=ut.useMemo(()=>_.duration||Y||HCe,[_.duration,Y]),fs=ut.useRef(0),dr=ut.useRef(0),bt=ut.useRef(0),ws=ut.useRef(null),[ir,Rr]=ce.split("-"),oa=ut.useMemo(()=>S.reduce((Zt,yr,Gr)=>Gr>=is?Zt:Zt+yr.height,0),[S,is]),ri=ilt(),no=_.invert||v,Da=qe==="loading";dr.current=ut.useMemo(()=>is*oe+oa,[is,oa]),ut.useEffect(()=>{ct.current=Qt},[Qt]),ut.useEffect(()=>{Fe(!0)},[]),ut.useEffect(()=>{let Zt=Ze.current;if(Zt){let yr=Zt.getBoundingClientRect().height;return He(yr),j(Gr=>[{toastId:_.id,height:yr,position:_.position},...Gr]),()=>j(Gr=>Gr.filter(Dn=>Dn.toastId!==_.id))}},[j,_.id]),ut.useLayoutEffect(()=>{if(!Pe)return;let Zt=Ze.current,yr=Zt.style.height;Zt.style.height="auto";let Gr=Zt.getBoundingClientRect().height;Zt.style.height=yr,He(Gr),j(Dn=>Dn.find(rs=>rs.toastId===_.id)?Dn.map(rs=>rs.toastId===_.id?{...rs,height:Gr}:rs):[{toastId:_.id,height:Gr,position:_.position},...Dn])},[Pe,_.title,_.description,j,_.id]);let yn=ut.useCallback(()=>{Ve(!0),je(dr.current),j(Zt=>Zt.filter(yr=>yr.toastId!==_.id)),setTimeout(()=>{F(_)},_lt)},[_,F,j,dr]);ut.useEffect(()=>{if(_.promise&&qe==="loading"||_.duration===1/0||_.type==="loading")return;let Zt;return L||w||ve&&ri?(()=>{if(bt.current{var yr;(yr=_.onAutoClose)==null||yr.call(_,_),yn()},ct.current)),()=>clearTimeout(Zt)},[L,w,_,qe,ve,ri,yn]),ut.useEffect(()=>{_.delete&&yn()},[yn,_.delete]);function ea(){var Zt,yr,Gr;return be!=null&&be.loading?ut.createElement("div",{className:eg(xe==null?void 0:xe.loader,(Zt=_==null?void 0:_.classNames)==null?void 0:Zt.loader,"sonner-loader"),"data-visible":qe==="loading"},be.loading):le?ut.createElement("div",{className:eg(xe==null?void 0:xe.loader,(yr=_==null?void 0:_.classNames)==null?void 0:yr.loader,"sonner-loader"),"data-visible":qe==="loading"},le):ut.createElement(elt,{className:eg(xe==null?void 0:xe.loader,(Gr=_==null?void 0:_.classNames)==null?void 0:Gr.loader),visible:qe==="loading"})}return ut.createElement("li",{tabIndex:0,ref:Ze,className:eg(se,Lt,xe==null?void 0:xe.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,xe==null?void 0:xe.default,xe==null?void 0:xe[qe],(r=_==null?void 0:_.classNames)==null?void 0:r[qe]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:$,"data-styled":!(_.jsx||_.unstyled||b),"data-mounted":Pe,"data-promise":!!_.promise,"data-swiped":Qe,"data-removed":Ie,"data-visible":Ke,"data-y-position":ir,"data-x-position":Rr,"data-index":A,"data-front":ht,"data-swiping":dt,"data-dismissible":Je,"data-type":qe,"data-invert":no,"data-swipe-out":Rt,"data-swipe-direction":Ne,"data-expanded":!!(L||de&&Pe),style:{"--index":A,"--toasts-before":A,"--z-index":I.length-A,"--offset":`${Ie?rt:dr.current}px`,"--initial-height":de?"auto":`${mt}px`,...H,..._.style},onDragEnd:()=>{Le(!1),Ge(null),ws.current=null},onPointerDown:Zt=>{Da||!Je||(We.current=new Date,je(dr.current),Zt.target.setPointerCapture(Zt.pointerId),Zt.target.tagName!=="BUTTON"&&(Le(!0),ws.current={x:Zt.clientX,y:Zt.clientY}))},onPointerUp:()=>{var Zt,yr,Gr,Dn;if(Rt||!Je)return;ws.current=null;let rs=Number(((Zt=Ze.current)==null?void 0:Zt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),An=Number(((yr=Ze.current)==null?void 0:yr.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),la=new Date().getTime()-((Gr=We.current)==null?void 0:Gr.getTime()),qa=ke==="x"?rs:An,Jr=Math.abs(qa)/la;if(Math.abs(qa)>=vlt||Jr>.11){je(dr.current),(Dn=_.onDismiss)==null||Dn.call(_,_),Ae(ke==="x"?rs>0?"right":"left":An>0?"down":"up"),yn(),fe(!0),at(!1);return}Le(!1),Ge(null)},onPointerMove:Zt=>{var yr,Gr,Dn,rs;if(!ws.current||!Je||((yr=window.getSelection())==null?void 0:yr.toString().length)>0)return;let An=Zt.clientY-ws.current.y,la=Zt.clientX-ws.current.x,qa=(Gr=t.swipeDirections)!=null?Gr:blt(ce);!ke&&(Math.abs(la)>1||Math.abs(An)>1)&&Ge(Math.abs(la)>Math.abs(An)?"x":"y");let Jr={x:0,y:0};ke==="y"?(qa.includes("top")||qa.includes("bottom"))&&(qa.includes("top")&&An<0||qa.includes("bottom")&&An>0)&&(Jr.y=An):ke==="x"&&(qa.includes("left")||qa.includes("right"))&&(qa.includes("left")&&la<0||qa.includes("right")&&la>0)&&(Jr.x=la),(Math.abs(Jr.x)>0||Math.abs(Jr.y)>0)&&at(!0),(Dn=Ze.current)==null||Dn.style.setProperty("--swipe-amount-x",`${Jr.x}px`),(rs=Ze.current)==null||rs.style.setProperty("--swipe-amount-y",`${Jr.y}px`)}},Kt&&!_.jsx?ut.createElement("button",{"aria-label":ye,"data-disabled":Da,"data-close-button":!0,onClick:Da||!Je?()=>{}:()=>{var Zt;yn(),(Zt=_.onDismiss)==null||Zt.call(_,_)},className:eg(xe==null?void 0:xe.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=be==null?void 0:be.close)!=null?o:alt):null,_.jsx||M.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:ut.createElement(ut.Fragment,null,qe||_.icon||_.promise?ut.createElement("div",{"data-icon":"",className:eg(xe==null?void 0:xe.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||ea():null,_.type!=="loading"?_.icon||(be==null?void 0:be[qe])||Qot(qe):null):null,ut.createElement("div",{"data-content":"",className:eg(xe==null?void 0:xe.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},ut.createElement("div",{"data-title":"",className:eg(xe==null?void 0:xe.title,(d=_==null?void 0:_.classNames)==null?void 0:d.title)},typeof _.title=="function"?_.title():_.title),_.description?ut.createElement("div",{"data-description":"",className:eg(te,zt,xe==null?void 0:xe.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),M.isValidElement(_.cancel)?_.cancel:_.cancel&&s8(_.cancel)?ut.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||U,onClick:Zt=>{var yr,Gr;s8(_.cancel)&&Je&&((Gr=(yr=_.cancel).onClick)==null||Gr.call(yr,Zt),yn())},className:eg(xe==null?void 0:xe.cancelButton,(f=_==null?void 0:_.classNames)==null?void 0:f.cancelButton)},_.cancel.label):null,M.isValidElement(_.action)?_.action:_.action&&s8(_.action)?ut.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||Q,onClick:Zt=>{var yr,Gr;s8(_.action)&&((Gr=(yr=_.action).onClick)==null||Gr.call(yr,Zt),!Zt.defaultPrevented&&yn())},className:eg(xe==null?void 0:xe.actionButton,(g=_==null?void 0:_.classNames)==null?void 0:g.actionButton)},_.action.label):null))};function WCe(){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 jlt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?glt:flt;function d(u){["top","right","bottom","left"].forEach(f=>{r[`${l}-${f}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?d(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]}):d(i)}),r}var klt=M.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:d,mobileOffset:u,theme:f="light",richColors:g,duration:v,style:_,visibleToasts:b=plt,toastOptions:w,dir:j=WCe(),gap:N=ylt,loadingIcon:S,icons:A,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:L}=t,[F,$]=ut.useState([]),q=ut.useMemo(()=>Array.from(new Set([n].concat(F.filter(ve=>ve.position).map(ve=>ve.position)))),[F,n]),[H,U]=ut.useState([]),[Q,se]=ut.useState(!1),[te,Y]=ut.useState(!1),[ce,oe]=ut.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),le=ut.useRef(null),de=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),xe=ut.useRef(null),be=ut.useRef(!1),ye=ut.useCallback(ve=>{$(ke=>{var Ge;return(Ge=ke.find(Ne=>Ne.id===ve.id))!=null&&Ge.delete||um.dismiss(ve.id),ke.filter(({id:Ne})=>Ne!==ve.id)})},[]);return ut.useEffect(()=>um.subscribe(ve=>{if(ve.dismiss){$(ke=>ke.map(Ge=>Ge.id===ve.id?{...Ge,delete:!0}:Ge));return}setTimeout(()=>{Lve.flushSync(()=>{$(ke=>{let Ge=ke.findIndex(Ne=>Ne.id===ve.id);return Ge!==-1?[...ke.slice(0,Ge),{...ke[Ge],...ve},...ke.slice(Ge+1)]:[ve,...ke]})})})}),[]),ut.useEffect(()=>{if(f!=="system"){oe(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?oe("dark"):oe("light")),typeof window>"u")return;let ve=window.matchMedia("(prefers-color-scheme: dark)");try{ve.addEventListener("change",({matches:ke})=>{oe(ke?"dark":"light")})}catch{ve.addListener(({matches:Ge})=>{try{oe(Ge?"dark":"light")}catch(Ne){console.error(Ne)}})}},[f]),ut.useEffect(()=>{F.length<=1&&se(!1)},[F]),ut.useEffect(()=>{let ve=ke=>{var Ge,Ne;a.every(Ae=>ke[Ae]||ke.code===Ae)&&(se(!0),(Ge=le.current)==null||Ge.focus()),ke.code==="Escape"&&(document.activeElement===le.current||(Ne=le.current)!=null&&Ne.contains(document.activeElement))&&se(!1)};return document.addEventListener("keydown",ve),()=>document.removeEventListener("keydown",ve)},[a]),ut.useEffect(()=>{if(le.current)return()=>{xe.current&&(xe.current.focus({preventScroll:!0}),xe.current=null,be.current=!1)}},[le.current]),ut.createElement("section",{ref:s,"aria-label":`${I} ${de}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((ve,ke)=>{var Ge;let[Ne,Ae]=ve.split("-");return F.length?ut.createElement("ol",{key:ve,dir:j==="auto"?WCe():j,tabIndex:-1,ref:le,className:i,"data-sonner-toaster":!0,"data-theme":ce,"data-y-position":Ne,"data-lifted":Q&&F.length>1&&!o,"data-x-position":Ae,style:{"--front-toast-height":`${((Ge=H[0])==null?void 0:Ge.height)||0}px`,"--width":`${xlt}px`,"--gap":`${N}px`,..._,...jlt(d,u)},onBlur:Pe=>{be.current&&!Pe.currentTarget.contains(Pe.relatedTarget)&&(be.current=!1,xe.current&&(xe.current.focus({preventScroll:!0}),xe.current=null))},onFocus:Pe=>{Pe.target instanceof HTMLElement&&Pe.target.dataset.dismissible==="false"||be.current||(be.current=!0,xe.current=Pe.relatedTarget)},onMouseEnter:()=>se(!0),onMouseMove:()=>se(!0),onMouseLeave:()=>{te||se(!1)},onDragEnd:()=>se(!1),onPointerDown:Pe=>{Pe.target instanceof HTMLElement&&Pe.target.dataset.dismissible==="false"||Y(!0)},onPointerUp:()=>Y(!1)},F.filter(Pe=>!Pe.position&&ke===0||Pe.position===ve).map((Pe,Fe)=>{var Ie,Ve;return ut.createElement(wlt,{key:Pe.id,icons:A,index:Fe,toast:Pe,defaultRichColors:g,duration:(Ie=w==null?void 0:w.duration)!=null?Ie:v,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:r,visibleToasts:b,closeButton:(Ve=w==null?void 0:w.closeButton)!=null?Ve:l,interacting:te,position:ve,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:ye,toasts:F.filter(dt=>dt.position==Pe.position),heights:H.filter(dt=>dt.position==Pe.position),setHeights:U,expandByDefault:o,gap:N,loadingIcon:S,expanded:Q,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const Nlt=({...t})=>{const{theme:s="system"}=Xot();return e.jsx(klt,{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 Slt=U0e[" useId ".trim().toString()]||(()=>{}),Clt=0;function Bd(t){const[s,r]=M.useState(Slt());return Hc(()=>{r(n=>n??String(Clt++))},[t]),s?`radix-${s}`:""}const Mlt=["top","right","bottom","left"],p_=Math.min,ep=Math.max,Rre=Math.round,r8=Math.floor,Hx=t=>({x:t,y:t}),Tlt={left:"right",right:"left",bottom:"top",top:"bottom"},Alt={start:"end",end:"start"};function jfe(t,s,r){return ep(t,p_(s,r))}function R0(t,s){return typeof t=="function"?t(s):t}function F0(t){return t.split("-")[0]}function X3(t){return t.split("-")[1]}function qve(t){return t==="x"?"y":"x"}function Uve(t){return t==="y"?"height":"width"}const Elt=new Set(["top","bottom"]);function Px(t){return Elt.has(F0(t))?"y":"x"}function Vve(t){return qve(Px(t))}function Plt(t,s,r){r===void 0&&(r=!1);const n=X3(t),a=Vve(t),o=Uve(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=Fre(l)),[l,Fre(l)]}function Ilt(t){const s=Fre(t);return[kfe(t),s,kfe(s)]}function kfe(t){return t.replace(/start|end/g,s=>Alt[s])}const GCe=["left","right"],KCe=["right","left"],Llt=["top","bottom"],Dlt=["bottom","top"];function Olt(t,s,r){switch(t){case"top":case"bottom":return r?s?KCe:GCe:s?GCe:KCe;case"left":case"right":return s?Llt:Dlt;default:return[]}}function Rlt(t,s,r,n){const a=X3(t);let o=Olt(F0(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(kfe)))),o}function Fre(t){return t.replace(/left|right|bottom|top/g,s=>Tlt[s])}function Flt(t){return{top:0,right:0,bottom:0,left:0,...t}}function rRe(t){return typeof t!="number"?Flt(t):{top:t,right:t,bottom:t,left:t}}function zre(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 ZCe(t,s,r){let{reference:n,floating:a}=t;const o=Px(s),l=Vve(s),i=Uve(l),d=F0(s),u=o==="y",f=n.x+n.width/2-a.width/2,g=n.y+n.height/2-a.height/2,v=n[i]/2-a[i]/2;let _;switch(d){case"top":_={x:f,y:n.y-a.height};break;case"bottom":_={x:f,y:n.y+n.height};break;case"right":_={x:n.x+n.width,y:g};break;case"left":_={x:n.x-a.width,y:g};break;default:_={x:n.x,y:n.y}}switch(X3(s)){case"start":_[l]-=v*(r&&u?-1:1);break;case"end":_[l]+=v*(r&&u?-1:1);break}return _}const zlt=async(t,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=r,i=o.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(s));let u=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:f,y:g}=ZCe(u,n,d),v=n,_={},b=0;for(let w=0;w({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:d}=s,{element:u,padding:f=0}=R0(t,s)||{};if(u==null)return{};const g=rRe(f),v={x:r,y:n},_=Vve(a),b=Uve(_),w=await l.getDimensions(u),j=_==="y",N=j?"top":"left",S=j?"bottom":"right",A=j?"clientHeight":"clientWidth",I=o.reference[b]+o.reference[_]-v[_]-o.floating[b],L=v[_]-o.reference[_],F=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let $=F?F[A]:0;(!$||!await(l.isElement==null?void 0:l.isElement(F)))&&($=i.floating[A]||o.floating[b]);const q=I/2-L/2,H=$/2-w[b]/2-1,U=p_(g[N],H),Q=p_(g[S],H),se=U,te=$-w[b]-Q,Y=$/2-w[b]/2+q,ce=jfe(se,Y,te),oe=!d.arrow&&X3(a)!=null&&Y!==ce&&o.reference[b]/2-(YY<=0)){var Q,se;const Y=(((Q=o.flip)==null?void 0:Q.index)||0)+1,ce=$[Y];if(ce&&(!(g==="alignment"?S!==Px(ce):!1)||U.every(de=>de.overflows[0]>0&&Px(de.placement)===S)))return{data:{index:Y,overflows:U},reset:{placement:ce}};let oe=(se=U.filter(le=>le.overflows[0]<=0).sort((le,de)=>le.overflows[1]-de.overflows[1])[0])==null?void 0:se.placement;if(!oe)switch(_){case"bestFit":{var te;const le=(te=U.filter(de=>{if(F){const xe=Px(de.placement);return xe===S||xe==="y"}return!0}).map(de=>[de.placement,de.overflows.filter(xe=>xe>0).reduce((xe,be)=>xe+be,0)]).sort((de,xe)=>de[1]-xe[1])[0])==null?void 0:te[0];le&&(oe=le);break}case"initialPlacement":oe=i;break}if(a!==oe)return{reset:{placement:oe}}}return{}}}};function YCe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function XCe(t){return Mlt.some(s=>t[s]>=0)}const qlt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=R0(t,s);switch(n){case"referenceHidden":{const o=await _I(s,{...a,elementContext:"reference"}),l=YCe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:XCe(l)}}}case"escaped":{const o=await _I(s,{...a,altBoundary:!0}),l=YCe(o,r.floating);return{data:{escapedOffsets:l,escaped:XCe(l)}}}default:return{}}}}},nRe=new Set(["left","top"]);async function Ult(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=F0(r),i=X3(r),d=Px(r)==="y",u=nRe.has(l)?-1:1,f=o&&d?-1:1,g=R0(s,t);let{mainAxis:v,crossAxis:_,alignmentAxis:b}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return i&&typeof b=="number"&&(_=i==="end"?b*-1:b),d?{x:_*f,y:v*u}:{x:v*u,y:_*f}}const Vlt=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,d=await Ult(s,t);return l===((r=i.offset)==null?void 0:r.placement)&&(n=i.arrow)!=null&&n.alignmentOffset?{}:{x:a+d.x,y:o+d.y,data:{...d,placement:l}}}}},Hlt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:j=>{let{x:N,y:S}=j;return{x:N,y:S}}},...d}=R0(t,s),u={x:r,y:n},f=await _I(s,d),g=Px(F0(a)),v=qve(g);let _=u[v],b=u[g];if(o){const j=v==="y"?"top":"left",N=v==="y"?"bottom":"right",S=_+f[j],A=_-f[N];_=jfe(S,_,A)}if(l){const j=g==="y"?"top":"left",N=g==="y"?"bottom":"right",S=b+f[j],A=b-f[N];b=jfe(S,b,A)}const w=i.fn({...s,[v]:_,[g]:b});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[v]:o,[g]:l}}}}}},Wlt=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:d=!0,crossAxis:u=!0}=R0(t,s),f={x:r,y:n},g=Px(a),v=qve(g);let _=f[v],b=f[g];const w=R0(i,s),j=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const A=v==="y"?"height":"width",I=o.reference[v]-o.floating[A]+j.mainAxis,L=o.reference[v]+o.reference[A]-j.mainAxis;_L&&(_=L)}if(u){var N,S;const A=v==="y"?"width":"height",I=nRe.has(F0(a)),L=o.reference[g]-o.floating[A]+(I&&((N=l.offset)==null?void 0:N[g])||0)+(I?0:j.crossAxis),F=o.reference[g]+o.reference[A]+(I?0:((S=l.offset)==null?void 0:S[g])||0)-(I?j.crossAxis:0);bF&&(b=F)}return{[v]:_,[g]:b}}}},Glt=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:d=()=>{},...u}=R0(t,s),f=await _I(s,u),g=F0(a),v=X3(a),_=Px(a)==="y",{width:b,height:w}=o.floating;let j,N;g==="top"||g==="bottom"?(j=g,N=v===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(N=g,j=v==="end"?"top":"bottom");const S=w-f.top-f.bottom,A=b-f.left-f.right,I=p_(w-f[j],S),L=p_(b-f[N],A),F=!s.middlewareData.shift;let $=I,q=L;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(q=A),(n=s.middlewareData.shift)!=null&&n.enabled.y&&($=S),F&&!v){const U=ep(f.left,0),Q=ep(f.right,0),se=ep(f.top,0),te=ep(f.bottom,0);_?q=b-2*(U!==0||Q!==0?U+Q:ep(f.left,f.right)):$=w-2*(se!==0||te!==0?se+te:ep(f.top,f.bottom))}await d({...s,availableWidth:q,availableHeight:$});const H=await l.getDimensions(i.floating);return b!==H.width||w!==H.height?{reset:{rects:!0}}:{}}}};function qie(){return typeof window<"u"}function Q3(t){return aRe(t)?(t.nodeName||"").toLowerCase():"#document"}function fp(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function ay(t){var s;return(s=(aRe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function aRe(t){return qie()?t instanceof Node||t instanceof fp(t).Node:!1}function Rg(t){return qie()?t instanceof Element||t instanceof fp(t).Element:!1}function Xx(t){return qie()?t instanceof HTMLElement||t instanceof fp(t).HTMLElement:!1}function QCe(t){return!qie()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof fp(t).ShadowRoot}const Klt=new Set(["inline","contents"]);function K6(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=Fg(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!Klt.has(a)}const Zlt=new Set(["table","td","th"]);function Ylt(t){return Zlt.has(Q3(t))}const Xlt=[":popover-open",":modal"];function Uie(t){return Xlt.some(s=>{try{return t.matches(s)}catch{return!1}})}const Qlt=["transform","translate","scale","rotate","perspective"],Jlt=["transform","translate","scale","rotate","perspective","filter"],ect=["paint","layout","strict","content"];function Hve(t){const s=Wve(),r=Rg(t)?Fg(t):t;return Qlt.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)||Jlt.some(n=>(r.willChange||"").includes(n))||ect.some(n=>(r.contain||"").includes(n))}function tct(t){let s=f_(t);for(;Xx(s)&&!Q5(s);){if(Hve(s))return s;if(Uie(s))return null;s=f_(s)}return null}function Wve(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const sct=new Set(["html","body","#document"]);function Q5(t){return sct.has(Q3(t))}function Fg(t){return fp(t).getComputedStyle(t)}function Vie(t){return Rg(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function f_(t){if(Q3(t)==="html")return t;const s=t.assignedSlot||t.parentNode||QCe(t)&&t.host||ay(t);return QCe(s)?s.host:s}function iRe(t){const s=f_(t);return Q5(s)?t.ownerDocument?t.ownerDocument.body:t.body:Xx(s)&&K6(s)?s:iRe(s)}function bI(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=iRe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=fp(a);if(o){const i=Nfe(l);return s.concat(l,l.visualViewport||[],K6(a)?a:[],i&&r?bI(i):[])}return s.concat(a,bI(a,[],r))}function Nfe(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function oRe(t){const s=Fg(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=Xx(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=Rre(r)!==o||Rre(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function Gve(t){return Rg(t)?t:t.contextElement}function x5(t){const s=Gve(t);if(!Xx(s))return Hx(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=oRe(s);let l=(o?Rre(r.width):r.width)/n,i=(o?Rre(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const rct=Hx(0);function lRe(t){const s=fp(t);return!Wve()||!s.visualViewport?rct:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function nct(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==fp(t)?!1:s}function vN(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=Gve(t);let l=Hx(1);s&&(n?Rg(n)&&(l=x5(n)):l=x5(t));const i=nct(o,r,n)?lRe(o):Hx(0);let d=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,f=a.width/l.x,g=a.height/l.y;if(o){const v=fp(o),_=n&&Rg(n)?fp(n):n;let b=v,w=Nfe(b);for(;w&&n&&_!==b;){const j=x5(w),N=w.getBoundingClientRect(),S=Fg(w),A=N.left+(w.clientLeft+parseFloat(S.paddingLeft))*j.x,I=N.top+(w.clientTop+parseFloat(S.paddingTop))*j.y;d*=j.x,u*=j.y,f*=j.x,g*=j.y,d+=A,u+=I,b=fp(w),w=Nfe(b)}}return zre({width:f,height:g,x:d,y:u})}function Kve(t,s){const r=Vie(t).scrollLeft;return s?s.left+r:vN(ay(t)).left+r}function cRe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:Kve(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function act(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=ay(n),i=s?Uie(s.floating):!1;if(n===l||i&&o)return r;let d={scrollLeft:0,scrollTop:0},u=Hx(1);const f=Hx(0),g=Xx(n);if((g||!g&&!o)&&((Q3(n)!=="body"||K6(l))&&(d=Vie(n)),Xx(n))){const _=vN(n);u=x5(n),f.x=_.x+n.clientLeft,f.y=_.y+n.clientTop}const v=l&&!g&&!o?cRe(l,d,!0):Hx(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+f.x+v.x,y:r.y*u.y-d.scrollTop*u.y+f.y+v.y}}function ict(t){return Array.from(t.getClientRects())}function oct(t){const s=ay(t),r=Vie(t),n=t.ownerDocument.body,a=ep(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=ep(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+Kve(t);const i=-r.scrollTop;return Fg(n).direction==="rtl"&&(l+=ep(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function lct(t,s){const r=fp(t),n=ay(t),a=r.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,d=0;if(a){o=a.width,l=a.height;const u=Wve();(!u||u&&s==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}return{width:o,height:l,x:i,y:d}}const cct=new Set(["absolute","fixed"]);function dct(t,s){const r=vN(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=Xx(t)?x5(t):Hx(1),l=t.clientWidth*o.x,i=t.clientHeight*o.y,d=a*o.x,u=n*o.y;return{width:l,height:i,x:d,y:u}}function JCe(t,s,r){let n;if(s==="viewport")n=lct(t,r);else if(s==="document")n=oct(ay(t));else if(Rg(s))n=dct(s,r);else{const a=lRe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return zre(n)}function dRe(t,s){const r=f_(t);return r===s||!Rg(r)||Q5(r)?!1:Fg(r).position==="fixed"||dRe(r,s)}function uct(t,s){const r=s.get(t);if(r)return r;let n=bI(t,[],!1).filter(i=>Rg(i)&&Q3(i)!=="body"),a=null;const o=Fg(t).position==="fixed";let l=o?f_(t):t;for(;Rg(l)&&!Q5(l);){const i=Fg(l),d=Hve(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&cct.has(a.position)||K6(l)&&!d&&dRe(t,l))?n=n.filter(f=>f!==l):a=i,l=f_(l)}return s.set(t,n),n}function hct(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?Uie(s)?[]:uct(s,this._c):[].concat(r),n],i=l[0],d=l.reduce((u,f)=>{const g=JCe(s,f,a);return u.top=ep(g.top,u.top),u.right=p_(g.right,u.right),u.bottom=p_(g.bottom,u.bottom),u.left=ep(g.left,u.left),u},JCe(s,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function mct(t){const{width:s,height:r}=oRe(t);return{width:s,height:r}}function pct(t,s,r){const n=Xx(s),a=ay(s),o=r==="fixed",l=vN(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const d=Hx(0);function u(){d.x=Kve(a)}if(n||!n&&!o)if((Q3(s)!=="body"||K6(a))&&(i=Vie(s)),n){const _=vN(s,!0,o,s);d.x=_.x+s.clientLeft,d.y=_.y+s.clientTop}else a&&u();o&&!n&&a&&u();const f=a&&!n&&!o?cRe(a,i):Hx(0),g=l.left+i.scrollLeft-d.x-f.x,v=l.top+i.scrollTop-d.y-f.y;return{x:g,y:v,width:l.width,height:l.height}}function Xue(t){return Fg(t).position==="static"}function e4e(t,s){if(!Xx(t)||Fg(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return ay(t)===r&&(r=r.ownerDocument.body),r}function uRe(t,s){const r=fp(t);if(Uie(t))return r;if(!Xx(t)){let a=f_(t);for(;a&&!Q5(a);){if(Rg(a)&&!Xue(a))return a;a=f_(a)}return r}let n=e4e(t,s);for(;n&&Ylt(n)&&Xue(n);)n=e4e(n,s);return n&&Q5(n)&&Xue(n)&&!Hve(n)?r:n||tct(t)||r}const fct=async function(t){const s=this.getOffsetParent||uRe,r=this.getDimensions,n=await r(t.floating);return{reference:pct(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function gct(t){return Fg(t).direction==="rtl"}const xct={convertOffsetParentRelativeRectToViewportRelativeRect:act,getDocumentElement:ay,getClippingRect:hct,getOffsetParent:uRe,getElementRects:fct,getClientRects:ict,getDimensions:mct,getScale:x5,isElement:Rg,isRTL:gct};function hRe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function yct(t,s){let r=null,n;const a=ay(t);function o(){var i;clearTimeout(n),(i=r)==null||i.disconnect(),r=null}function l(i,d){i===void 0&&(i=!1),d===void 0&&(d=1),o();const u=t.getBoundingClientRect(),{left:f,top:g,width:v,height:_}=u;if(i||s(),!v||!_)return;const b=r8(g),w=r8(a.clientWidth-(f+v)),j=r8(a.clientHeight-(g+_)),N=r8(f),A={rootMargin:-b+"px "+-w+"px "+-j+"px "+-N+"px",threshold:ep(0,p_(1,d))||1};let I=!0;function L(F){const $=F[0].intersectionRatio;if($!==d){if(!I)return l();$?l(!1,$):n=setTimeout(()=>{l(!1,1e-7)},1e3)}$===1&&!hRe(u,t.getBoundingClientRect())&&l(),I=!1}try{r=new IntersectionObserver(L,{...A,root:a.ownerDocument})}catch{r=new IntersectionObserver(L,A)}r.observe(t)}return l(!0),o}function vct(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:d=!1}=n,u=Gve(t),f=a||o?[...u?bI(u):[],...bI(s)]:[];f.forEach(N=>{a&&N.addEventListener("scroll",r,{passive:!0}),o&&N.addEventListener("resize",r)});const g=u&&i?yct(u,r):null;let v=-1,_=null;l&&(_=new ResizeObserver(N=>{let[S]=N;S&&S.target===u&&_&&(_.unobserve(s),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var A;(A=_)==null||A.observe(s)})),r()}),u&&!d&&_.observe(u),_.observe(s));let b,w=d?vN(t):null;d&&j();function j(){const N=vN(t);w&&!hRe(w,N)&&r(),w=N,b=requestAnimationFrame(j)}return r(),()=>{var N;f.forEach(S=>{a&&S.removeEventListener("scroll",r),o&&S.removeEventListener("resize",r)}),g==null||g(),(N=_)==null||N.disconnect(),_=null,d&&cancelAnimationFrame(b)}}const _ct=Vlt,bct=Hlt,wct=$lt,jct=Glt,kct=qlt,t4e=Blt,Nct=Wlt,Sct=(t,s,r)=>{const n=new Map,a={platform:xct,...r},o={...a.platform,_c:n};return zlt(t,s,{...a,platform:o})};var Cct=typeof document<"u",Mct=function(){},zse=Cct?M.useLayoutEffect:Mct;function Bre(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(!Bre(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)&&!Bre(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function mRe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function s4e(t,s){const r=mRe(t);return Math.round(s*r)/r}function Que(t){const s=M.useRef(t);return zse(()=>{s.current=t}),s}function Tct(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:d,open:u}=t,[f,g]=M.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[v,_]=M.useState(n);Bre(v,n)||_(n);const[b,w]=M.useState(null),[j,N]=M.useState(null),S=M.useCallback(de=>{de!==F.current&&(F.current=de,w(de))},[]),A=M.useCallback(de=>{de!==$.current&&($.current=de,N(de))},[]),I=o||b,L=l||j,F=M.useRef(null),$=M.useRef(null),q=M.useRef(f),H=d!=null,U=Que(d),Q=Que(a),se=Que(u),te=M.useCallback(()=>{if(!F.current||!$.current)return;const de={placement:s,strategy:r,middleware:v};Q.current&&(de.platform=Q.current),Sct(F.current,$.current,de).then(xe=>{const be={...xe,isPositioned:se.current!==!1};Y.current&&!Bre(q.current,be)&&(q.current=be,xm.flushSync(()=>{g(be)}))})},[v,s,r,Q,se]);zse(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,g(de=>({...de,isPositioned:!1})))},[u]);const Y=M.useRef(!1);zse(()=>(Y.current=!0,()=>{Y.current=!1}),[]),zse(()=>{if(I&&(F.current=I),L&&($.current=L),I&&L){if(U.current)return U.current(I,L,te);te()}},[I,L,te,U,H]);const ce=M.useMemo(()=>({reference:F,floating:$,setReference:S,setFloating:A}),[S,A]),oe=M.useMemo(()=>({reference:I,floating:L}),[I,L]),le=M.useMemo(()=>{const de={position:r,left:0,top:0};if(!oe.floating)return de;const xe=s4e(oe.floating,f.x),be=s4e(oe.floating,f.y);return i?{...de,transform:"translate("+xe+"px, "+be+"px)",...mRe(oe.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:xe,top:be}},[r,i,oe.floating,f.x,f.y]);return M.useMemo(()=>({...f,update:te,refs:ce,elements:oe,floatingStyles:le}),[f,te,ce,oe,le])}const Act=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?t4e({element:n.current,padding:a}).fn(r):{}:n?t4e({element:n,padding:a}).fn(r):{}}}},Ect=(t,s)=>({..._ct(t),options:[t,s]}),Pct=(t,s)=>({...bct(t),options:[t,s]}),Ict=(t,s)=>({...Nct(t),options:[t,s]}),Lct=(t,s)=>({...wct(t),options:[t,s]}),Dct=(t,s)=>({...jct(t),options:[t,s]}),Oct=(t,s)=>({...kct(t),options:[t,s]}),Rct=(t,s)=>({...Act(t),options:[t,s]});var Fct="Arrow",pRe=M.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(Qr.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"})})});pRe.displayName=Fct;var zct=pRe;function Z6(t){const[s,r]=M.useState(void 0);return Hc(()=>{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 d=o.borderBoxSize,u=Array.isArray(d)?d[0]:d;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 Zve="Popper",[fRe,iy]=Cc(Zve),[Bct,gRe]=fRe(Zve),xRe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=M.useState(null);return e.jsx(Bct,{scope:s,anchor:n,onAnchorChange:a,children:r})};xRe.displayName=Zve;var yRe="PopperAnchor",vRe=M.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=gRe(yRe,r),l=M.useRef(null),i=Sa(s,l);return M.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(Qr.div,{...a,ref:i})});vRe.displayName=yRe;var Yve="PopperContent",[$ct,qct]=fRe(Yve),_Re=M.forwardRef((t,s)=>{var Pe,Fe,Ie,Ve,dt,Le;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:g="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:b,...w}=t,j=gRe(Yve,r),[N,S]=M.useState(null),A=Sa(s,Rt=>S(Rt)),[I,L]=M.useState(null),F=Z6(I),$=(F==null?void 0:F.width)??0,q=(F==null?void 0:F.height)??0,H=n+(o!=="center"?"-"+o:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},Q=Array.isArray(u)?u:[u],se=Q.length>0,te={padding:U,boundary:Q.filter(Vct),altBoundary:se},{refs:Y,floatingStyles:ce,placement:oe,isPositioned:le,middlewareData:de}=Tct({strategy:"fixed",placement:H,whileElementsMounted:(...Rt)=>vct(...Rt,{animationFrame:_==="always"}),elements:{reference:j.anchor},middleware:[Ect({mainAxis:a+q,alignmentAxis:l}),d&&Pct({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?Ict():void 0,...te}),d&&Lct({...te}),Dct({...te,apply:({elements:Rt,rects:fe,availableWidth:Qe,availableHeight:at})=>{const{width:rt,height:je}=fe.reference,mt=Rt.floating.style;mt.setProperty("--radix-popper-available-width",`${Qe}px`),mt.setProperty("--radix-popper-available-height",`${at}px`),mt.setProperty("--radix-popper-anchor-width",`${rt}px`),mt.setProperty("--radix-popper-anchor-height",`${je}px`)}}),I&&Rct({element:I,padding:i}),Hct({arrowWidth:$,arrowHeight:q}),v&&Oct({strategy:"referenceHidden",...te})]}),[xe,be]=jRe(oe),ye=Bc(b);Hc(()=>{le&&(ye==null||ye())},[le,ye]);const ve=(Pe=de.arrow)==null?void 0:Pe.x,ke=(Fe=de.arrow)==null?void 0:Fe.y,Ge=((Ie=de.arrow)==null?void 0:Ie.centerOffset)!==0,[Ne,Ae]=M.useState();return Hc(()=>{N&&Ae(window.getComputedStyle(N).zIndex)},[N]),e.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:le?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ne,"--radix-popper-transform-origin":[(Ve=de.transformOrigin)==null?void 0:Ve.x,(dt=de.transformOrigin)==null?void 0:dt.y].join(" "),...((Le=de.hide)==null?void 0:Le.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx($ct,{scope:r,placedSide:xe,onArrowChange:L,arrowX:ve,arrowY:ke,shouldHideArrow:Ge,children:e.jsx(Qr.div,{"data-side":xe,"data-align":be,...w,ref:A,style:{...w.style,animation:le?void 0:"none"}})})})});_Re.displayName=Yve;var bRe="PopperArrow",Uct={top:"bottom",right:"left",bottom:"top",left:"right"},wRe=M.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=qct(bRe,n),l=Uct[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(zct,{...a,ref:r,style:{...a.style,display:"block"}})})});wRe.displayName=bRe;function Vct(t){return t!==null}var Hct=t=>({name:"transformOrigin",options:t,fn(s){var j,N,S;const{placement:r,rects:n,middlewareData:a}=s,l=((j=a.arrow)==null?void 0:j.centerOffset)!==0,i=l?0:t.arrowWidth,d=l?0:t.arrowHeight,[u,f]=jRe(r),g={start:"0%",center:"50%",end:"100%"}[f],v=(((N=a.arrow)==null?void 0:N.x)??0)+i/2,_=(((S=a.arrow)==null?void 0:S.y)??0)+d/2;let b="",w="";return u==="bottom"?(b=l?g:`${v}px`,w=`${-d}px`):u==="top"?(b=l?g:`${v}px`,w=`${n.floating.height+d}px`):u==="right"?(b=`${-d}px`,w=l?g:`${_}px`):u==="left"&&(b=`${n.floating.width+d}px`,w=l?g:`${_}px`),{data:{x:b,y:w}}}});function jRe(t){const[s,r="center"]=t.split("-");return[s,r]}var Y6=xRe,J3=vRe,X6=_Re,Q6=wRe,[Hie]=Cc("Tooltip",[iy]),Wie=iy(),kRe="TooltipProvider",Wct=700,Sfe="tooltip.open",[Gct,Xve]=Hie(kRe),NRe=t=>{const{__scopeTooltip:s,delayDuration:r=Wct,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=M.useRef(!0),i=M.useRef(!1),d=M.useRef(0);return M.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),e.jsx(Gct,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:M.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:M.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:M.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};NRe.displayName=kRe;var wI="Tooltip",[Kct,Gie]=Hie(wI),SRe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,d=Xve(wI,t.__scopeTooltip),u=Wie(s),[f,g]=M.useState(null),v=Bd(),_=M.useRef(0),b=l??d.disableHoverableContent,w=i??d.delayDuration,j=M.useRef(!1),[N,S]=uu({prop:n,defaultProp:a??!1,onChange:$=>{$?(d.onOpen(),document.dispatchEvent(new CustomEvent(Sfe))):d.onClose(),o==null||o($)},caller:wI}),A=M.useMemo(()=>N?j.current?"delayed-open":"instant-open":"closed",[N]),I=M.useCallback(()=>{window.clearTimeout(_.current),_.current=0,j.current=!1,S(!0)},[S]),L=M.useCallback(()=>{window.clearTimeout(_.current),_.current=0,S(!1)},[S]),F=M.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{j.current=!0,S(!0),_.current=0},w)},[w,S]);return M.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(Y6,{...u,children:e.jsx(Kct,{scope:s,contentId:v,open:N,stateAttribute:A,trigger:f,onTriggerChange:g,onTriggerEnter:M.useCallback(()=>{d.isOpenDelayedRef.current?F():I()},[d.isOpenDelayedRef,F,I]),onTriggerLeave:M.useCallback(()=>{b?L():(window.clearTimeout(_.current),_.current=0)},[L,b]),onOpen:I,onClose:L,disableHoverableContent:b,children:r})})};SRe.displayName=wI;var Cfe="TooltipTrigger",CRe=M.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Gie(Cfe,r),o=Xve(Cfe,r),l=Wie(r),i=M.useRef(null),d=Sa(s,i,a.onTriggerChange),u=M.useRef(!1),f=M.useRef(!1),g=M.useCallback(()=>u.current=!1,[]);return M.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),e.jsx(J3,{asChild:!0,...l,children:e.jsx(Qr.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:Sr(t.onPointerMove,v=>{v.pointerType!=="touch"&&!f.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),f.current=!0)}),onPointerLeave:Sr(t.onPointerLeave,()=>{a.onTriggerLeave(),f.current=!1}),onPointerDown:Sr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Sr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Sr(t.onBlur,a.onClose),onClick:Sr(t.onClick,a.onClose)})})});CRe.displayName=Cfe;var Zct="TooltipPortal",[Pvs,Yct]=Hie(Zct,{forceMount:void 0}),J5="TooltipContent",MRe=M.forwardRef((t,s)=>{const r=Yct(J5,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=Gie(J5,t.__scopeTooltip);return e.jsx(od,{present:n||l.open,children:l.disableHoverableContent?e.jsx(TRe,{side:a,...o,ref:s}):e.jsx(Xct,{side:a,...o,ref:s})})}),Xct=M.forwardRef((t,s)=>{const r=Gie(J5,t.__scopeTooltip),n=Xve(J5,t.__scopeTooltip),a=M.useRef(null),o=Sa(s,a),[l,i]=M.useState(null),{trigger:d,onClose:u}=r,f=a.current,{onPointerInTransitChange:g}=n,v=M.useCallback(()=>{i(null),g(!1)},[g]),_=M.useCallback((b,w)=>{const j=b.currentTarget,N={x:b.clientX,y:b.clientY},S=sdt(N,j.getBoundingClientRect()),A=rdt(N,S),I=ndt(w.getBoundingClientRect()),L=idt([...A,...I]);i(L),g(!0)},[g]);return M.useEffect(()=>()=>v(),[v]),M.useEffect(()=>{if(d&&f){const b=j=>_(j,f),w=j=>_(j,d);return d.addEventListener("pointerleave",b),f.addEventListener("pointerleave",w),()=>{d.removeEventListener("pointerleave",b),f.removeEventListener("pointerleave",w)}}},[d,f,_,v]),M.useEffect(()=>{if(l){const b=w=>{const j=w.target,N={x:w.clientX,y:w.clientY},S=(d==null?void 0:d.contains(j))||(f==null?void 0:f.contains(j)),A=!adt(N,l);S?v():A&&(v(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[d,f,l,u,v]),e.jsx(TRe,{...t,ref:o})}),[Qct,Jct]=Hie(wI,{isInside:!1}),edt=_8e("TooltipContent"),TRe=M.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=Gie(J5,r),u=Wie(r),{onClose:f}=d;return M.useEffect(()=>(document.addEventListener(Sfe,f),()=>document.removeEventListener(Sfe,f)),[f]),M.useEffect(()=>{if(d.trigger){const g=v=>{const _=v.target;_!=null&&_.contains(d.trigger)&&f()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,f]),e.jsx(C_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:e.jsxs(X6,{"data-state":d.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(edt,{children:n}),e.jsx(Qct,{scope:r,isInside:!0,children:e.jsx(Vit,{id:d.contentId,role:"tooltip",children:a||n})})]})})});MRe.displayName=J5;var ARe="TooltipArrow",tdt=M.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Wie(r);return Jct(ARe,r).isInside?null:e.jsx(Q6,{...a,...n,ref:s})});tdt.displayName=ARe;function sdt(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 rdt(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 ndt(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 adt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=v>n&&r<(g-u)*(n-f)/(v-f)+u&&(a=!a)}return a}function idt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),odt(s)}function odt(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 ldt=NRe,cdt=SRe,ddt=CRe,ERe=MRe;const HN=ldt,Mu=cdt,Tu=ddt,au=M.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(ERe,{ref:n,sideOffset:s,className:It("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));au.displayName=ERe.displayName;var eM=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(){}},_N=typeof window>"u"||"Deno"in globalThis;function bh(){}function udt(t,s){return typeof t=="function"?t(s):t}function Mfe(t){return typeof t=="number"&&t>=0&&t!==1/0}function PRe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function e_(t,s){return typeof t=="function"?t(s):t}function Wp(t,s){return typeof t=="function"?t(s):t}function r4e(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==Qve(l,s.options))return!1}else if(!jI(s.queryKey,l))return!1}if(r!=="all"){const d=s.isActive();if(r==="active"&&!d||r==="inactive"&&d)return!1}return!(typeof i=="boolean"&&s.isStale()!==i||a&&a!==s.state.fetchStatus||o&&!o(s))}function n4e(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(bN(s.options.mutationKey)!==bN(o))return!1}else if(!jI(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function Qve(t,s){return((s==null?void 0:s.queryKeyHashFn)||bN)(t)}function bN(t){return JSON.stringify(t,(s,r)=>Tfe(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function jI(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>jI(t[r],s[r])):!1}function IRe(t,s){if(t===s)return t;const r=a4e(t)&&a4e(s);if(r||Tfe(t)&&Tfe(s)){const n=r?t:Object.keys(t),a=n.length,o=r?s:Object.keys(s),l=o.length,i=r?[]:{},d=new Set(n);let u=0;for(let f=0;f{setTimeout(s,t)})}function Afe(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?IRe(t,s):s}function mdt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function pdt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var Jve=Symbol();function LRe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===Jve?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function DRe(t,s){return typeof t=="function"?t(...s):!!t}var Ek,p1,I5,ZLe,fdt=(ZLe=class extends eM{constructor(){super();za(this,Ek);za(this,p1);za(this,I5);Bn(this,I5,s=>{if(!_N&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){cs(this,p1)||this.setEventListener(cs(this,I5))}onUnsubscribe(){var s;this.hasListeners()||((s=cs(this,p1))==null||s.call(this),Bn(this,p1,void 0))}setEventListener(s){var r;Bn(this,I5,s),(r=cs(this,p1))==null||r.call(this),Bn(this,p1,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){cs(this,Ek)!==s&&(Bn(this,Ek,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof cs(this,Ek)=="boolean"?cs(this,Ek):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},Ek=new WeakMap,p1=new WeakMap,I5=new WeakMap,ZLe),e1e=new fdt,L5,f1,D5,YLe,gdt=(YLe=class extends eM{constructor(){super();za(this,L5,!0);za(this,f1);za(this,D5);Bn(this,D5,s=>{if(!_N&&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(){cs(this,f1)||this.setEventListener(cs(this,D5))}onUnsubscribe(){var s;this.hasListeners()||((s=cs(this,f1))==null||s.call(this),Bn(this,f1,void 0))}setEventListener(s){var r;Bn(this,D5,s),(r=cs(this,f1))==null||r.call(this),Bn(this,f1,s(this.setOnline.bind(this)))}setOnline(s){cs(this,L5)!==s&&(Bn(this,L5,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return cs(this,L5)}},L5=new WeakMap,f1=new WeakMap,D5=new WeakMap,YLe),qre=new gdt;function Efe(){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 xdt(t){return Math.min(1e3*2**t,3e4)}function ORe(t){return(t??"online")==="online"?qre.isOnline():!0}var RRe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Jue(t){return t instanceof RRe}function FRe(t){let s=!1,r=0,n=!1,a;const o=Efe(),l=w=>{var j;n||(v(new RRe(w)),(j=t.abort)==null||j.call(t))},i=()=>{s=!0},d=()=>{s=!1},u=()=>e1e.isFocused()&&(t.networkMode==="always"||qre.isOnline())&&t.canRun(),f=()=>ORe(t.networkMode)&&t.canRun(),g=w=>{var j;n||(n=!0,(j=t.onSuccess)==null||j.call(t,w),a==null||a(),o.resolve(w))},v=w=>{var j;n||(n=!0,(j=t.onError)==null||j.call(t,w),a==null||a(),o.reject(w))},_=()=>new Promise(w=>{var j;a=N=>{(n||u())&&w(N)},(j=t.onPause)==null||j.call(t)}).then(()=>{var w;a=void 0,n||(w=t.onContinue)==null||w.call(t)}),b=()=>{if(n)return;let w;const j=r===0?t.initialPromise:void 0;try{w=j??t.fn()}catch(N){w=Promise.reject(N)}Promise.resolve(w).then(g).catch(N=>{var F;if(n)return;const S=t.retry??(_N?0:3),A=t.retryDelay??xdt,I=typeof A=="function"?A(r,N):A,L=S===!0||typeof S=="number"&&ru()?void 0:_()).then(()=>{s?v(N):b()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:f,start:()=>(f()?b():_().then(b),o)}}var ydt=t=>setTimeout(t,0);function vdt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=ydt;const o=i=>{s?t.push(i):a(()=>{r(i)})},l=()=>{const i=t;t=[],i.length&&a(()=>{n(()=>{i.forEach(d=>{r(d)})})})};return{batch:i=>{let d;s++;try{d=i()}finally{s--,s||l()}return d},batchCalls:i=>(...d)=>{o(()=>{i(...d)})},schedule:o,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{a=i}}}var Id=vdt(),Pk,XLe,zRe=(XLe=class{constructor(){za(this,Pk)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Mfe(this.gcTime)&&Bn(this,Pk,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(_N?1/0:5*60*1e3))}clearGcTimeout(){cs(this,Pk)&&(clearTimeout(cs(this,Pk)),Bn(this,Pk,void 0))}},Pk=new WeakMap,XLe),O5,Ik,Hp,Lk,qu,R6,Dk,dg,Vy,QLe,_dt=(QLe=class extends zRe{constructor(s){super();za(this,dg);za(this,O5);za(this,Ik);za(this,Hp);za(this,Lk);za(this,qu);za(this,R6);za(this,Dk);Bn(this,Dk,!1),Bn(this,R6,s.defaultOptions),this.setOptions(s.options),this.observers=[],Bn(this,Lk,s.client),Bn(this,Hp,cs(this,Lk).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Bn(this,O5,bdt(this.options)),this.state=s.state??cs(this,O5),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=cs(this,qu))==null?void 0:s.promise}setOptions(s){this.options={...cs(this,R6),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&cs(this,Hp).remove(this)}setData(s,r){const n=Afe(this.state.data,s,this.options);return Bi(this,dg,Vy).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Bi(this,dg,Vy).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=cs(this,qu))==null?void 0:n.promise;return(a=cs(this,qu))==null||a.cancel(s),r?r.then(bh).catch(bh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(cs(this,O5))}isActive(){return this.observers.some(s=>Wp(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jve||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>e_(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:!PRe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=cs(this,qu))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=cs(this,qu))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),cs(this,Hp).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(cs(this,qu)&&(cs(this,Dk)?cs(this,qu).cancel({revert:!0}):cs(this,qu).cancelRetry()),this.scheduleGc()),cs(this,Hp).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Bi(this,dg,Vy).call(this,{type:"invalidate"})}fetch(s,r){var u,f,g;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(cs(this,qu))return cs(this,qu).continueRetry(),cs(this,qu).promise}if(s&&this.setOptions(s),!this.options.queryFn){const v=this.observers.find(_=>_.options.queryFn);v&&this.setOptions(v.options)}const n=new AbortController,a=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(Bn(this,Dk,!0),n.signal)})},o=()=>{const v=LRe(this.options,r),b=(()=>{const w={client:cs(this,Lk),queryKey:this.queryKey,meta:this.meta};return a(w),w})();return Bn(this,Dk,!1),this.options.persister?this.options.persister(v,b,this):v(b)},i=(()=>{const v={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:cs(this,Lk),state:this.state,fetchFn:o};return a(v),v})();(u=this.options.behavior)==null||u.onFetch(i,this),Bn(this,Ik,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=i.fetchOptions)==null?void 0:f.meta))&&Bi(this,dg,Vy).call(this,{type:"fetch",meta:(g=i.fetchOptions)==null?void 0:g.meta});const d=v=>{var _,b,w,j;Jue(v)&&v.silent||Bi(this,dg,Vy).call(this,{type:"error",error:v}),Jue(v)||((b=(_=cs(this,Hp).config).onError)==null||b.call(_,v,this),(j=(w=cs(this,Hp).config).onSettled)==null||j.call(w,this.state.data,v,this)),this.scheduleGc()};return Bn(this,qu,FRe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var _,b,w,j;if(v===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(v)}catch(N){d(N);return}(b=(_=cs(this,Hp).config).onSuccess)==null||b.call(_,v,this),(j=(w=cs(this,Hp).config).onSettled)==null||j.call(w,v,this.state.error,this),this.scheduleGc()},onError:d,onFail:(v,_)=>{Bi(this,dg,Vy).call(this,{type:"failed",failureCount:v,error:_})},onPause:()=>{Bi(this,dg,Vy).call(this,{type:"pause"})},onContinue:()=>{Bi(this,dg,Vy).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),cs(this,qu).start()}},O5=new WeakMap,Ik=new WeakMap,Hp=new WeakMap,Lk=new WeakMap,qu=new WeakMap,R6=new WeakMap,Dk=new WeakMap,dg=new WeakSet,Vy=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,...BRe(n.data,this.options),fetchMeta:s.meta??null};case"success":return Bn(this,Ik,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 Jue(a)&&a.revert&&cs(this,Ik)?{...cs(this,Ik),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),Id.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),cs(this,Hp).notify({query:this,type:"updated",action:s})})},QLe);function BRe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ORe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function bdt(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 kx,JLe,wdt=(JLe=class extends eM{constructor(s={}){super();za(this,kx);this.config=s,Bn(this,kx,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??Qve(a,r);let l=this.get(o);return l||(l=new _dt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){cs(this,kx).has(s.queryHash)||(cs(this,kx).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=cs(this,kx).get(s.queryHash);r&&(s.destroy(),r===s&&cs(this,kx).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){Id.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return cs(this,kx).get(s)}getAll(){return[...cs(this,kx).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>r4e(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>r4e(s,n)):r}notify(s){Id.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){Id.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){Id.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},kx=new WeakMap,JLe),Nx,yh,Ok,Sx,Uv,eDe,jdt=(eDe=class extends zRe{constructor(s){super();za(this,Sx);za(this,Nx);za(this,yh);za(this,Ok);this.mutationId=s.mutationId,Bn(this,yh,s.mutationCache),Bn(this,Nx,[]),this.state=s.state||$Re(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){cs(this,Nx).includes(s)||(cs(this,Nx).push(s),this.clearGcTimeout(),cs(this,yh).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Bn(this,Nx,cs(this,Nx).filter(r=>r!==s)),this.scheduleGc(),cs(this,yh).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){cs(this,Nx).length||(this.state.status==="pending"?this.scheduleGc():cs(this,yh).remove(this))}continue(){var s;return((s=cs(this,Ok))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,d,u,f,g,v,_,b,w,j,N,S,A,I,L,F,$,q;const r=()=>{Bi(this,Sx,Uv).call(this,{type:"continue"})};Bn(this,Ok,FRe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(H,U)=>{Bi(this,Sx,Uv).call(this,{type:"failed",failureCount:H,error:U})},onPause:()=>{Bi(this,Sx,Uv).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>cs(this,yh).canRun(this)}));const n=this.state.status==="pending",a=!cs(this,Ok).canStart();try{if(n)r();else{Bi(this,Sx,Uv).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=cs(this,yh).config).onMutate)==null?void 0:l.call(o,s,this));const U=await((d=(i=this.options).onMutate)==null?void 0:d.call(i,s));U!==this.state.context&&Bi(this,Sx,Uv).call(this,{type:"pending",context:U,variables:s,isPaused:a})}const H=await cs(this,Ok).start();return await((f=(u=cs(this,yh).config).onSuccess)==null?void 0:f.call(u,H,s,this.state.context,this)),await((v=(g=this.options).onSuccess)==null?void 0:v.call(g,H,s,this.state.context)),await((b=(_=cs(this,yh).config).onSettled)==null?void 0:b.call(_,H,null,this.state.variables,this.state.context,this)),await((j=(w=this.options).onSettled)==null?void 0:j.call(w,H,null,s,this.state.context)),Bi(this,Sx,Uv).call(this,{type:"success",data:H}),H}catch(H){try{throw await((S=(N=cs(this,yh).config).onError)==null?void 0:S.call(N,H,s,this.state.context,this)),await((I=(A=this.options).onError)==null?void 0:I.call(A,H,s,this.state.context)),await((F=(L=cs(this,yh).config).onSettled)==null?void 0:F.call(L,void 0,H,this.state.variables,this.state.context,this)),await((q=($=this.options).onSettled)==null?void 0:q.call($,void 0,H,s,this.state.context)),H}finally{Bi(this,Sx,Uv).call(this,{type:"error",error:H})}}finally{cs(this,yh).runNext(this)}}},Nx=new WeakMap,yh=new WeakMap,Ok=new WeakMap,Sx=new WeakSet,Uv=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),Id.batch(()=>{cs(this,Nx).forEach(n=>{n.onMutationUpdate(s)}),cs(this,yh).notify({mutation:this,type:"updated",action:s})})},eDe);function $Re(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var s0,ug,F6,tDe,kdt=(tDe=class extends eM{constructor(s={}){super();za(this,s0);za(this,ug);za(this,F6);this.config=s,Bn(this,s0,new Set),Bn(this,ug,new Map),Bn(this,F6,0)}build(s,r,n){const a=new jdt({mutationCache:this,mutationId:++OO(this,F6)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){cs(this,s0).add(s);const r=n8(s);if(typeof r=="string"){const n=cs(this,ug).get(r);n?n.push(s):cs(this,ug).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(cs(this,s0).delete(s)){const r=n8(s);if(typeof r=="string"){const n=cs(this,ug).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&cs(this,ug).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=n8(s);if(typeof r=="string"){const n=cs(this,ug).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=n8(s);if(typeof r=="string"){const a=(n=cs(this,ug).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(){Id.batch(()=>{cs(this,s0).forEach(s=>{this.notify({type:"removed",mutation:s})}),cs(this,s0).clear(),cs(this,ug).clear()})}getAll(){return Array.from(cs(this,s0))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>n4e(r,n))}findAll(s={}){return this.getAll().filter(r=>n4e(s,r))}notify(s){Id.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return Id.batch(()=>Promise.all(s.map(r=>r.continue().catch(bh))))}},s0=new WeakMap,ug=new WeakMap,F6=new WeakMap,tDe);function n8(t){var s;return(s=t.options.scope)==null?void 0:s.id}function Ure(t){return{onFetch:(s,r)=>{var f,g,v,_,b;const n=s.options,a=(v=(g=(f=s.fetchOptions)==null?void 0:f.meta)==null?void 0:g.fetchMore)==null?void 0:v.direction,o=((_=s.state.data)==null?void 0:_.pages)||[],l=((b=s.state.data)==null?void 0:b.pageParams)||[];let i={pages:[],pageParams:[]},d=0;const u=async()=>{let w=!1;const j=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(s.signal.aborted?w=!0:s.signal.addEventListener("abort",()=>{w=!0}),s.signal)})},N=LRe(s.options,s.fetchOptions),S=async(A,I,L)=>{if(w)return Promise.reject();if(I==null&&A.pages.length)return Promise.resolve(A);const $=(()=>{const Q={client:s.client,queryKey:s.queryKey,pageParam:I,direction:L?"backward":"forward",meta:s.options.meta};return j(Q),Q})(),q=await N($),{maxPages:H}=s.options,U=L?pdt:mdt;return{pages:U(A.pages,q,H),pageParams:U(A.pageParams,I,H)}};if(a&&o.length){const A=a==="backward",I=A?qRe:Pfe,L={pages:o,pageParams:l},F=I(n,L);i=await S(L,F,A)}else{const A=t??o.length;do{const I=d===0?l[0]??n.initialPageParam:Pfe(n,i);if(d>0&&I==null)break;i=await S(i,I),d++}while(d{var w,j;return(j=(w=s.options).persister)==null?void 0:j.call(w,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function Pfe(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 qRe(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 Ndt(t,s){return s?Pfe(t,s)!=null:!1}function Sdt(t,s){return!s||!t.getPreviousPageParam?!1:qRe(t,s)!=null}var Ec,g1,x1,R5,F5,y1,z5,B5,sDe,Cdt=(sDe=class{constructor(t={}){za(this,Ec);za(this,g1);za(this,x1);za(this,R5);za(this,F5);za(this,y1);za(this,z5);za(this,B5);Bn(this,Ec,t.queryCache||new wdt),Bn(this,g1,t.mutationCache||new kdt),Bn(this,x1,t.defaultOptions||{}),Bn(this,R5,new Map),Bn(this,F5,new Map),Bn(this,y1,0)}mount(){OO(this,y1)._++,cs(this,y1)===1&&(Bn(this,z5,e1e.subscribe(async t=>{t&&(await this.resumePausedMutations(),cs(this,Ec).onFocus())})),Bn(this,B5,qre.subscribe(async t=>{t&&(await this.resumePausedMutations(),cs(this,Ec).onOnline())})))}unmount(){var t,s;OO(this,y1)._--,cs(this,y1)===0&&((t=cs(this,z5))==null||t.call(this),Bn(this,z5,void 0),(s=cs(this,B5))==null||s.call(this),Bn(this,B5,void 0))}isFetching(t){return cs(this,Ec).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return cs(this,g1).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=cs(this,Ec).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=cs(this,Ec).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(e_(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return cs(this,Ec).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=cs(this,Ec).get(n.queryHash),o=a==null?void 0:a.state.data,l=udt(s,o);if(l!==void 0)return cs(this,Ec).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return Id.batch(()=>cs(this,Ec).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=cs(this,Ec).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=cs(this,Ec);Id.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=cs(this,Ec);return Id.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=Id.batch(()=>cs(this,Ec).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(bh).catch(bh)}invalidateQueries(t,s={}){return Id.batch(()=>(cs(this,Ec).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=Id.batch(()=>cs(this,Ec).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(bh)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(bh)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=cs(this,Ec).build(this,s);return r.isStaleByTime(e_(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(bh).catch(bh)}fetchInfiniteQuery(t){return t.behavior=Ure(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(bh).catch(bh)}ensureInfiniteQueryData(t){return t.behavior=Ure(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return qre.isOnline()?cs(this,g1).resumePausedMutations():Promise.resolve()}getQueryCache(){return cs(this,Ec)}getMutationCache(){return cs(this,g1)}getDefaultOptions(){return cs(this,x1)}setDefaultOptions(t){Bn(this,x1,t)}setQueryDefaults(t,s){cs(this,R5).set(bN(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...cs(this,R5).values()],r={};return s.forEach(n=>{jI(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){cs(this,F5).set(bN(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...cs(this,F5).values()],r={};return s.forEach(n=>{jI(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...cs(this,x1).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=Qve(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===Jve&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...cs(this,x1).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){cs(this,Ec).clear(),cs(this,g1).clear()}},Ec=new WeakMap,g1=new WeakMap,x1=new WeakMap,R5=new WeakMap,F5=new WeakMap,y1=new WeakMap,z5=new WeakMap,B5=new WeakMap,sDe),lm,go,z6,vh,Rk,$5,v1,_1,B6,q5,U5,Fk,zk,b1,V5,qo,mE,Ife,Lfe,Dfe,Ofe,Rfe,Ffe,zfe,VRe,rDe,URe=(rDe=class extends eM{constructor(s,r){super();za(this,qo);za(this,lm);za(this,go);za(this,z6);za(this,vh);za(this,Rk);za(this,$5);za(this,v1);za(this,_1);za(this,B6);za(this,q5);za(this,U5);za(this,Fk);za(this,zk);za(this,b1);za(this,V5,new Set);this.options=r,Bn(this,lm,s),Bn(this,_1,null),Bn(this,v1,Efe()),this.options.experimental_prefetchInRender||cs(this,v1).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&&(cs(this,go).addObserver(this),o4e(cs(this,go),this.options)?Bi(this,qo,mE).call(this):this.updateResult(),Bi(this,qo,Ofe).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Bfe(cs(this,go),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Bfe(cs(this,go),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Bi(this,qo,Rfe).call(this),Bi(this,qo,Ffe).call(this),cs(this,go).removeObserver(this)}setOptions(s){const r=this.options,n=cs(this,go);if(this.options=cs(this,lm).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Wp(this.options.enabled,cs(this,go))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Bi(this,qo,zfe).call(this),cs(this,go).setOptions(this.options),r._defaulted&&!$re(this.options,r)&&cs(this,lm).getQueryCache().notify({type:"observerOptionsUpdated",query:cs(this,go),observer:this});const a=this.hasListeners();a&&l4e(cs(this,go),n,this.options,r)&&Bi(this,qo,mE).call(this),this.updateResult(),a&&(cs(this,go)!==n||Wp(this.options.enabled,cs(this,go))!==Wp(r.enabled,cs(this,go))||e_(this.options.staleTime,cs(this,go))!==e_(r.staleTime,cs(this,go)))&&Bi(this,qo,Ife).call(this);const o=Bi(this,qo,Lfe).call(this);a&&(cs(this,go)!==n||Wp(this.options.enabled,cs(this,go))!==Wp(r.enabled,cs(this,go))||o!==cs(this,b1))&&Bi(this,qo,Dfe).call(this,o)}getOptimisticResult(s){const r=cs(this,lm).getQueryCache().build(cs(this,lm),s),n=this.createResult(r,s);return Tdt(this,n)&&(Bn(this,vh,n),Bn(this,$5,this.options),Bn(this,Rk,cs(this,go).state)),n}getCurrentResult(){return cs(this,vh)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){cs(this,V5).add(s)}getCurrentQuery(){return cs(this,go)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=cs(this,lm).defaultQueryOptions(s),n=cs(this,lm).getQueryCache().build(cs(this,lm),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Bi(this,qo,mE).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),cs(this,vh)))}createResult(s,r){var H;const n=cs(this,go),a=this.options,o=cs(this,vh),l=cs(this,Rk),i=cs(this,$5),u=s!==n?s.state:cs(this,z6),{state:f}=s;let g={...f},v=!1,_;if(r._optimisticResults){const U=this.hasListeners(),Q=!U&&o4e(s,r),se=U&&l4e(s,n,r,a);(Q||se)&&(g={...g,...BRe(f.data,s.options)}),r._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:b,errorUpdatedAt:w,status:j}=g;_=g.data;let N=!1;if(r.placeholderData!==void 0&&_===void 0&&j==="pending"){let U;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(U=o.data,N=!0):U=typeof r.placeholderData=="function"?r.placeholderData((H=cs(this,U5))==null?void 0:H.state.data,cs(this,U5)):r.placeholderData,U!==void 0&&(j="success",_=Afe(o==null?void 0:o.data,U,r),v=!0)}if(r.select&&_!==void 0&&!N)if(o&&_===(l==null?void 0:l.data)&&r.select===cs(this,B6))_=cs(this,q5);else try{Bn(this,B6,r.select),_=r.select(_),_=Afe(o==null?void 0:o.data,_,r),Bn(this,q5,_),Bn(this,_1,null)}catch(U){Bn(this,_1,U)}cs(this,_1)&&(b=cs(this,_1),_=cs(this,q5),w=Date.now(),j="error");const S=g.fetchStatus==="fetching",A=j==="pending",I=j==="error",L=A&&S,F=_!==void 0,q={status:j,fetchStatus:g.fetchStatus,isPending:A,isSuccess:j==="success",isError:I,isInitialLoading:L,isLoading:L,data:_,dataUpdatedAt:g.dataUpdatedAt,error:b,errorUpdatedAt:w,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>u.dataUpdateCount||g.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!A,isLoadingError:I&&!F,isPaused:g.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:I&&F,isStale:t1e(s,r),refetch:this.refetch,promise:cs(this,v1),isEnabled:Wp(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const U=te=>{q.status==="error"?te.reject(q.error):q.data!==void 0&&te.resolve(q.data)},Q=()=>{const te=Bn(this,v1,q.promise=Efe());U(te)},se=cs(this,v1);switch(se.status){case"pending":s.queryHash===n.queryHash&&U(se);break;case"fulfilled":(q.status==="error"||q.data!==se.value)&&Q();break;case"rejected":(q.status!=="error"||q.error!==se.reason)&&Q();break}}return q}updateResult(){const s=cs(this,vh),r=this.createResult(cs(this,go),this.options);if(Bn(this,Rk,cs(this,go).state),Bn(this,$5,this.options),cs(this,Rk).data!==void 0&&Bn(this,U5,cs(this,go)),$re(r,s))return;Bn(this,vh,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!cs(this,V5).size)return!0;const l=new Set(o??cs(this,V5));return this.options.throwOnError&&l.add("error"),Object.keys(cs(this,vh)).some(i=>{const d=i;return cs(this,vh)[d]!==s[d]&&l.has(d)})};Bi(this,qo,VRe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Bi(this,qo,Ofe).call(this)}},lm=new WeakMap,go=new WeakMap,z6=new WeakMap,vh=new WeakMap,Rk=new WeakMap,$5=new WeakMap,v1=new WeakMap,_1=new WeakMap,B6=new WeakMap,q5=new WeakMap,U5=new WeakMap,Fk=new WeakMap,zk=new WeakMap,b1=new WeakMap,V5=new WeakMap,qo=new WeakSet,mE=function(s){Bi(this,qo,zfe).call(this);let r=cs(this,go).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(bh)),r},Ife=function(){Bi(this,qo,Rfe).call(this);const s=e_(this.options.staleTime,cs(this,go));if(_N||cs(this,vh).isStale||!Mfe(s))return;const n=PRe(cs(this,vh).dataUpdatedAt,s)+1;Bn(this,Fk,setTimeout(()=>{cs(this,vh).isStale||this.updateResult()},n))},Lfe=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(cs(this,go)):this.options.refetchInterval)??!1},Dfe=function(s){Bi(this,qo,Ffe).call(this),Bn(this,b1,s),!(_N||Wp(this.options.enabled,cs(this,go))===!1||!Mfe(cs(this,b1))||cs(this,b1)===0)&&Bn(this,zk,setInterval(()=>{(this.options.refetchIntervalInBackground||e1e.isFocused())&&Bi(this,qo,mE).call(this)},cs(this,b1)))},Ofe=function(){Bi(this,qo,Ife).call(this),Bi(this,qo,Dfe).call(this,Bi(this,qo,Lfe).call(this))},Rfe=function(){cs(this,Fk)&&(clearTimeout(cs(this,Fk)),Bn(this,Fk,void 0))},Ffe=function(){cs(this,zk)&&(clearInterval(cs(this,zk)),Bn(this,zk,void 0))},zfe=function(){const s=cs(this,lm).getQueryCache().build(cs(this,lm),this.options);if(s===cs(this,go))return;const r=cs(this,go);Bn(this,go,s),Bn(this,z6,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},VRe=function(s){Id.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(cs(this,vh))}),cs(this,lm).getQueryCache().notify({query:cs(this,go),type:"observerResultsUpdated"})})},rDe);function Mdt(t,s){return Wp(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function o4e(t,s){return Mdt(t,s)||t.state.data!==void 0&&Bfe(t,s,s.refetchOnMount)}function Bfe(t,s,r){if(Wp(s.enabled,t)!==!1&&e_(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&t1e(t,s)}return!1}function l4e(t,s,r,n){return(t!==s||Wp(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&t1e(t,r)}function t1e(t,s){return Wp(s.enabled,t)!==!1&&t.isStaleByTime(e_(s.staleTime,t))}function Tdt(t,s){return!$re(t.getCurrentResult(),s)}var Adt=class extends URe{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:Ure()})}getOptimisticResult(t){return t.behavior=Ure(),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 b,w;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,d=(w=(b=r.fetchMeta)==null?void 0:b.fetchMore)==null?void 0:w.direction,u=l&&d==="forward",f=a&&d==="forward",g=l&&d==="backward",v=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ndt(s,r.data),hasPreviousPage:Sdt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:f,isFetchPreviousPageError:g,isFetchingPreviousPage:v,isRefetchError:i&&!u&&!g,isRefetching:o&&!f&&!v}}},w1,j1,cm,r0,E0,Bse,$fe,nDe,Edt=(nDe=class extends eM{constructor(r,n){super();za(this,E0);za(this,w1);za(this,j1);za(this,cm);za(this,r0);Bn(this,w1,r),this.setOptions(n),this.bindMethods(),Bi(this,E0,Bse).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=cs(this,w1).defaultMutationOptions(r),$re(this.options,n)||cs(this,w1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:cs(this,cm),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&bN(n.mutationKey)!==bN(this.options.mutationKey)?this.reset():((a=cs(this,cm))==null?void 0:a.state.status)==="pending"&&cs(this,cm).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=cs(this,cm))==null||r.removeObserver(this)}onMutationUpdate(r){Bi(this,E0,Bse).call(this),Bi(this,E0,$fe).call(this,r)}getCurrentResult(){return cs(this,j1)}reset(){var r;(r=cs(this,cm))==null||r.removeObserver(this),Bn(this,cm,void 0),Bi(this,E0,Bse).call(this),Bi(this,E0,$fe).call(this)}mutate(r,n){var a;return Bn(this,r0,n),(a=cs(this,cm))==null||a.removeObserver(this),Bn(this,cm,cs(this,w1).getMutationCache().build(cs(this,w1),this.options)),cs(this,cm).addObserver(this),cs(this,cm).execute(r)}},w1=new WeakMap,j1=new WeakMap,cm=new WeakMap,r0=new WeakMap,E0=new WeakSet,Bse=function(){var n;const r=((n=cs(this,cm))==null?void 0:n.state)??$Re();Bn(this,j1,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},$fe=function(r){Id.batch(()=>{var n,a,o,l,i,d,u,f;if(cs(this,r0)&&this.hasListeners()){const g=cs(this,j1).variables,v=cs(this,j1).context;(r==null?void 0:r.type)==="success"?((a=(n=cs(this,r0)).onSuccess)==null||a.call(n,r.data,g,v),(l=(o=cs(this,r0)).onSettled)==null||l.call(o,r.data,null,g,v)):(r==null?void 0:r.type)==="error"&&((d=(i=cs(this,r0)).onError)==null||d.call(i,r.error,g,v),(f=(u=cs(this,r0)).onSettled)==null||f.call(u,void 0,r.error,g,v))}this.listeners.forEach(g=>{g(cs(this,j1))})})},nDe),HRe=M.createContext(void 0),ds=t=>{const s=M.useContext(HRe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Pdt=({client:t,children:s})=>(M.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(HRe.Provider,{value:t,children:s})),WRe=M.createContext(!1),Idt=()=>M.useContext(WRe);WRe.Provider;function Ldt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Ddt=M.createContext(Ldt()),Odt=()=>M.useContext(Ddt),Rdt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},Fdt=t=>{M.useEffect(()=>{t.clearReset()},[t])},zdt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||DRe(r,[t.error,n])),Bdt=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))}},$dt=(t,s)=>t.isLoading&&t.isFetching&&!s,qdt=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,c4e=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function GRe(t,s,r){var g,v,_,b,w;const n=Idt(),a=Odt(),o=ds(),l=o.defaultQueryOptions(t);(v=(g=o.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||v.call(g,l),l._optimisticResults=n?"isRestoring":"optimistic",Bdt(l),Rdt(l,a),Fdt(a);const i=!o.getQueryCache().get(l.queryHash),[d]=M.useState(()=>new s(o,l)),u=d.getOptimisticResult(l),f=!n&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(j=>{const N=f?d.subscribe(Id.batchCalls(j)):bh;return d.updateResult(),N},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),M.useEffect(()=>{d.setOptions(l)},[l,d]),qdt(l,u))throw c4e(l,d,a);if(zdt({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:_._experimental_afterQuery)==null||b.call(_,l,u),l.experimental_prefetchInRender&&!_N&&$dt(u,n)){const j=i?c4e(l,d,a):(w=o.getQueryCache().get(l.queryHash))==null?void 0:w.promise;j==null||j.catch(bh).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function Tt(t,s){return GRe(t,URe)}function Bt(t,s){const r=ds(),[n]=M.useState(()=>new Edt(r,t));M.useEffect(()=>{n.setOptions(t)},[n,t]);const a=M.useSyncExternalStore(M.useCallback(l=>n.subscribe(Id.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=M.useCallback((l,i)=>{n.mutate(l,i).catch(bh)},[n]);if(a.error&&DRe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function Udt(t,s){return GRe(t,Adt)}/** * @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 kI(){return kI=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function KRe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Hdt(){return Math.random().toString(36).substr(2,8)}function u4e(t,s){return{usr:t.state,key:t.key,idx:s}}function qfe(t,s,r,n){return r===void 0&&(r=null),kI({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?tM(s):s,{state:r,key:s&&s.key||n||Hdt()})}function Vre(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 tM(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 Wdt(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=C1.Pop,d=null,u=f();u==null&&(u=0,l.replaceState(kI({},l.state,{idx:u}),""));function f(){return(l.state||{idx:null}).idx}function g(){i=C1.Pop;let j=f(),N=j==null?null:j-u;u=j,d&&d({action:i,location:w.location,delta:N})}function v(j,N){i=C1.Push;let S=qfe(w.location,j,N);u=f()+1;let A=u4e(S,u),I=w.createHref(S);try{l.pushState(A,"",I)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(I)}o&&d&&d({action:i,location:w.location,delta:1})}function _(j,N){i=C1.Replace;let S=qfe(w.location,j,N);u=f();let A=u4e(S,u),I=w.createHref(S);l.replaceState(A,"",I),o&&d&&d({action:i,location:w.location,delta:0})}function b(j){let N=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof j=="string"?j:Vre(j);return S=S.replace(/ $/,"%20"),ad(N,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,N)}let w={get action(){return i},get location(){return t(a,l)},listen(j){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(d4e,g),d=j,()=>{a.removeEventListener(d4e,g),d=null}},createHref(j){return s(a,j)},createURL:b,encodeLocation(j){let N=b(j);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:v,replace:_,go(j){return l.go(j)}};return w}var h4e;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(h4e||(h4e={}));function Gdt(t,s,r){return r===void 0&&(r="/"),Kdt(t,s,r)}function Kdt(t,s,r,n){let a=typeof s=="string"?tM(s):s,o=s1e(a.pathname||"/",r);if(o==null)return null;let l=ZRe(t);Zdt(l);let i=null;for(let d=0;i==null&&d{let d={relativePath:i===void 0?o.path||"":i,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};d.relativePath.startsWith("/")&&(ad(d.relativePath.startsWith(n),'Absolute route path "'+d.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),d.relativePath=d.relativePath.slice(n.length));let u=t_([n,d.relativePath]),f=r.concat(d);o.children&&o.children.length>0&&(ad(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),ZRe(o.children,s,f,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:sut(u,o.index),routesMeta:f})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let d of YRe(o.path))a(o,l,d)}),s}function YRe(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=YRe(n.join("/")),i=[];return i.push(...l.map(d=>d===""?o:[o,d].join("/"))),a&&i.push(...l),i.map(d=>t.startsWith("/")&&d===""?"/":d)}function Zdt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:rut(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Ydt=/^:[\w-]+$/,Xdt=3,Qdt=2,Jdt=1,eut=10,tut=-2,m4e=t=>t==="*";function sut(t,s){let r=t.split("/"),n=r.length;return r.some(m4e)&&(n+=tut),s&&(n+=Qdt),r.filter(a=>!m4e(a)).reduce((a,o)=>a+(Ydt.test(o)?Xdt:o===""?Jdt:eut),n)}function rut(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 nut(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:v,isOptional:_}=f;if(v==="*"){let w=i[g]||"";l=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const b=i[g];return _&&!b?u[v]=void 0:u[v]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function iut(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),KRe(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,d)=>(n.push({paramName:i,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function out(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return KRe(!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 s1e(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 lut(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?tM(t):t;return{pathname:r?r.startsWith("/")?r:cut(r,s):s,search:hut(n),hash:mut(a)}}function cut(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 ehe(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 dut(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function r1e(t,s){let r=dut(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function n1e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=tM(t):(a=kI({},t),ad(!a.pathname||!a.pathname.includes("?"),ehe("?","pathname","search",a)),ad(!a.pathname||!a.pathname.includes("#"),ehe("#","pathname","hash",a)),ad(!a.search||!a.search.includes("#"),ehe("#","search","hash",a)));let o=t===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=r;else{let g=s.length-1;if(!n&&l.startsWith("..")){let v=l.split("/");for(;v[0]==="..";)v.shift(),g-=1;a.pathname=v.join("/")}i=g>=0?s[g]:"/"}let d=lut(a,i),u=l&&l!=="/"&&l.endsWith("/"),f=(o||l===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(u||f)&&(d.pathname+="/"),d}const t_=t=>t.join("/").replace(/\/\/+/g,"/"),uut=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),hut=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,mut=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function put(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const XRe=["post","put","patch","delete"];new Set(XRe);const fut=["get",...XRe];new Set(fut);/** * 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 NI(){return NI=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),M.useCallback(function(u,f){if(f===void 0&&(f={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let g=n1e(u,JSON.parse(l),o,f.relative==="path");t==null&&s!=="/"&&(g.pathname=g.pathname==="/"?s:t_([s,g.pathname])),(f.replace?n.replace:n.push)(g,f.state,f)},[s,n,l,o,t])}const vut=M.createContext(null);function _ut(t){let s=M.useContext(oy).outlet;return s&&M.createElement(vut.Provider,{value:t},s)}function Uo(){let{matches:t}=M.useContext(oy),s=t[t.length-1];return s?s.params:{}}function eFe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=M.useContext(M_),{matches:a}=M.useContext(oy),{pathname:o}=sh(),l=JSON.stringify(r1e(a,n.v7_relativeSplatPath));return M.useMemo(()=>n1e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function but(t,s){return wut(t,s)}function wut(t,s,r,n){sM()||ad(!1);let{navigator:a}=M.useContext(M_),{matches:o}=M.useContext(oy),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=sh(),f;if(s){var g;let j=typeof s=="string"?tM(s):s;d==="/"||(g=j.pathname)!=null&&g.startsWith(d)||ad(!1),f=j}else f=u;let v=f.pathname||"/",_=v;if(d!=="/"){let j=d.replace(/^\//,"").split("/");_="/"+v.replace(/^\//,"").split("/").slice(j.length).join("/")}let b=Gdt(t,{pathname:_}),w=Cut(b&&b.map(j=>Object.assign({},j,{params:Object.assign({},i,j.params),pathname:t_([d,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?d:t_([d,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),o,r,n);return s&&w?M.createElement(Kie.Provider,{value:{location:NI({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:C1.Pop}},w):w}function jut(){let t=Eut(),s=put(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 M.createElement(M.Fragment,null,M.createElement("h2",null,"Unexpected Application Error!"),M.createElement("h3",{style:{fontStyle:"italic"}},s),r?M.createElement("pre",{style:a},r):null,null)}const kut=M.createElement(jut,null);class Nut extends M.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?M.createElement(oy.Provider,{value:this.props.routeContext},M.createElement(QRe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Sut(t){let{routeContext:s,match:r,children:n}=t,a=M.useContext(a1e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),M.createElement(oy.Provider,{value:s},n)}function Cut(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 f=l.findIndex(g=>g.route.id&&(i==null?void 0:i[g.route.id])!==void 0);f>=0||ad(!1),l=l.slice(0,Math.min(l.length,f+1))}let d=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let f=0;f=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((f,g,v)=>{let _,b=!1,w=null,j=null;r&&(_=i&&g.route.id?i[g.route.id]:void 0,w=g.route.errorElement||kut,d&&(u<0&&v===0?(Iut("route-fallback"),b=!0,j=null):u===v&&(b=!0,j=g.route.hydrateFallbackElement||null)));let N=s.concat(l.slice(0,v+1)),S=()=>{let A;return _?A=w:b?A=j:g.route.Component?A=M.createElement(g.route.Component,null):g.route.element?A=g.route.element:A=f,M.createElement(Sut,{match:g,routeContext:{outlet:f,matches:N,isDataRoute:r!=null},children:A})};return r&&(g.route.ErrorBoundary||g.route.errorElement||v===0)?M.createElement(Nut,{location:r.location,revalidation:r.revalidation,component:w,error:_,children:S(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):S()},null)}var tFe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(tFe||{}),sFe=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}(sFe||{});function Mut(t){let s=M.useContext(a1e);return s||ad(!1),s}function Tut(t){let s=M.useContext(gut);return s||ad(!1),s}function Aut(t){let s=M.useContext(oy);return s||ad(!1),s}function rFe(t){let s=Aut(),r=s.matches[s.matches.length-1];return r.route.id||ad(!1),r.route.id}function Eut(){var t;let s=M.useContext(QRe),r=Tut(),n=rFe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function Put(){let{router:t}=Mut(tFe.UseNavigateStable),s=rFe(sFe.UseNavigateStable),r=M.useRef(!1);return JRe(()=>{r.current=!0}),M.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,NI({fromRouteId:s},o)))},[t,s])}const p4e={};function Iut(t,s,r){p4e[t]||(p4e[t]=!0)}function Lut(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function the(t){let{to:s,replace:r,state:n,relative:a}=t;sM()||ad(!1);let{future:o,static:l}=M.useContext(M_),{matches:i}=M.useContext(oy),{pathname:d}=sh(),u=Or(),f=n1e(s,r1e(i,o.v7_relativeSplatPath),d,a==="path"),g=JSON.stringify(f);return M.useEffect(()=>u(JSON.parse(g),{replace:r,state:n,relative:a}),[u,g,a,r,n]),null}function Dut(t){return _ut(t.context)}function Zs(t){ad(!1)}function Out(t){let{basename:s="/",children:r=null,location:n,navigationType:a=C1.Pop,navigator:o,static:l=!1,future:i}=t;sM()&&ad(!1);let d=s.replace(/^\/*/,"/"),u=M.useMemo(()=>({basename:d,navigator:o,static:l,future:NI({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=tM(n));let{pathname:f="/",search:g="",hash:v="",state:_=null,key:b="default"}=n,w=M.useMemo(()=>{let j=s1e(f,d);return j==null?null:{location:{pathname:j,search:g,hash:v,state:_,key:b},navigationType:a}},[d,f,g,v,_,b,a]);return w==null?null:M.createElement(M_.Provider,{value:u},M.createElement(Kie.Provider,{children:r,value:w}))}function nFe(t){let{children:s,location:r}=t;return but(Ufe(s),r)}new Promise(()=>{});function Ufe(t,s){s===void 0&&(s=[]);let r=[];return M.Children.forEach(t,(n,a)=>{if(!M.isValidElement(n))return;let o=[...s,a];if(n.type===M.Fragment){r.push.apply(r,Ufe(n.props.children,o));return}n.type!==Zs&&ad(!1),!n.props.index||!n.props.children||ad(!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=Ufe(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 Vfe(){return Vfe=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function Fut(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function zut(t,s){return t.button===0&&(!s||s==="_self")&&!Fut(t)}function Hfe(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 But(t,s){let r=Hfe(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const $ut=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],qut="6";try{window.__reactRouterVersion=qut}catch{}const Uut="startTransition",f4e=U0e[Uut];function Vut(t){let{basename:s,children:r,future:n,window:a}=t,o=M.useRef();o.current==null&&(o.current=Vdt({window:a,v5Compat:!0}));let l=o.current,[i,d]=M.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},f=M.useCallback(g=>{u&&f4e?f4e(()=>d(g)):d(g)},[d,u]);return M.useLayoutEffect(()=>l.listen(f),[l,f]),M.useEffect(()=>Lut(n),[n]),M.createElement(Out,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const Hut=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Wut=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yo=M.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:u,preventScrollReset:f,viewTransition:g}=s,v=Rut(s,$ut),{basename:_}=M.useContext(M_),b,w=!1;if(typeof u=="string"&&Wut.test(u)&&(b=u,Hut))try{let A=new URL(window.location.href),I=u.startsWith("//")?new URL(A.protocol+u):new URL(u),L=s1e(I.pathname,_);I.origin===A.origin&&L!=null?u=L+I.search+I.hash:w=!0}catch{}let j=xut(u,{relative:a}),N=Gut(u,{replace:l,state:i,target:d,preventScrollReset:f,relative:a,viewTransition:g});function S(A){n&&n(A),A.defaultPrevented||N(A)}return M.createElement("a",Vfe({},v,{href:b||j,onClick:w||o?n:S,ref:r,target:d}))});var g4e;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(g4e||(g4e={}));var x4e;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(x4e||(x4e={}));function Gut(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=Or(),u=sh(),f=eFe(t,{relative:l});return M.useCallback(g=>{if(zut(g,r)){g.preventDefault();let v=n!==void 0?n:Vre(u)===Vre(f);d(t,{replace:v,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,d,f,n,a,r,t,o,l,i])}function Gc(t){let s=M.useRef(Hfe(t)),r=M.useRef(!1),n=sh(),a=M.useMemo(()=>But(n.search,r.current?null:s.current),[n.search]),o=Or(),l=M.useCallback((i,d)=>{const u=Hfe(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,d)},[o,a]);return[a,l]}var Kut=typeof Element<"u",Zut=typeof Map=="function",Yut=typeof Set=="function",Xut=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function $se(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(!$se(t[n],s[n]))return!1;return!0}var o;if(Zut&&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(!$se(n.value[1],s.get(n.value[0])))return!1;return!0}if(Yut&&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(Xut&&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(Kut&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!$se(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var Qut=function(s,r){try{return $se(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 Jut=vo(Qut);var eht=function(t,s,r,n,a,o,l,i){if(!t){var d;if(s===void 0)d=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],f=0;d=new Error(s.replace(/%s/g,function(){return u[f++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}},tht=eht;const y4e=vo(tht);var sht=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 d=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))(aFe||{}),she={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"]}},v4e=Object.values(aFe),i1e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},nht=Object.entries(i1e).reduce((t,[s,r])=>(t[r]=s,t),{}),jg="data-rh",y5={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},v5=(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},aht=t=>{let s=v5(t,"title");const r=v5(t,y5.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=v5(t,y5.DEFAULT_TITLE);return s||n||void 0},iht=t=>v5(t,y5.ON_CHANGE_CLIENT_STATE)||(()=>{}),rhe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),oht=(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),DA=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&lht(`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(d=>{let u;const f=Object.keys(d);for(let v=0;va.push(d));const i=Object.keys(l);for(let d=0;d{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:oht(["href"],t),bodyAttributes:rhe("bodyAttributes",t),defer:v5(t,y5.DEFER),encode:v5(t,y5.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:rhe("htmlAttributes",t),linkTags:DA("link",["rel","href"],t),metaTags:DA("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:DA("noscript",["innerHTML"],t),onChangeClientState:iht(t),scriptTags:DA("script",["src","innerHTML"],t),styleTags:DA("style",["cssText"],t),title:aht(t),titleAttributes:rhe("titleAttributes",t),prioritizeSeoTags:cht(t,y5.PRIORITIZE_SEO_TAGS)}),iFe=t=>Array.isArray(t)?t.join(""):t,uht=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(uht(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},_4e=(t,s)=>({...t,[s]:void 0}),hht=["noscript","script","style"],Wfe=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),oFe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),mht=(t,s,r,n)=>{const a=oFe(r),o=iFe(s);return a?`<${t} ${jg}="true" ${a}>${Wfe(o,n)}`:`<${t} ${jg}="true">${Wfe(o,n)}`},pht=(t,s,r=!0)=>s.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(u=>!(u==="innerHTML"||u==="cssText")).reduce((u,f)=>{const g=typeof o[f]>"u"?f:`${f}="${Wfe(o[f],r)}"`;return u?`${u} ${g}`:g},""),i=o.innerHTML||o.cssText||"",d=hht.indexOf(t)===-1;return`${n}<${t} ${jg}="true" ${l}${d?"/>":`>${i}`}`},""),lFe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=i1e[n];return r[a||n]=t[n],r},s),fht=(t,s,r)=>{const n={key:s,[jg]:!0},a=lFe(r,n);return[ut.createElement("title",a,s)]},qse=(t,s)=>s.map((r,n)=>{const a={key:n,[jg]:!0};return Object.keys(r).forEach(o=>{const i=i1e[o]||o;if(i==="innerHTML"||i==="cssText"){const d=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:d}}else a[i]=r[o]}),ut.createElement(t,a)}),Vp=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>fht(t,s.title,s.titleAttributes),toString:()=>mht(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>lFe(s),toString:()=>oFe(s)};default:return{toComponent:()=>qse(t,s),toString:()=>pht(t,s,r)}}},ght=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=nhe(t,she.meta),o=nhe(s,she.link),l=nhe(r,she.script);return{priorityMethods:{toComponent:()=>[...qse("meta",a.priority),...qse("link",o.priority),...qse("script",l.priority)],toString:()=>`${Vp("meta",a.priority,n)} ${Vp("link",o.priority,n)} ${Vp("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},xht=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:d,prioritizeSeoTags:u}=t;let{linkTags:f,metaTags:g,scriptTags:v}=t,_={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:_,linkTags:f,metaTags:g,scriptTags:v}=ght(t)),{priority:_,base:Vp("base",s,n),bodyAttributes:Vp("bodyAttributes",r,n),htmlAttributes:Vp("htmlAttributes",a,n),link:Vp("link",f,n),meta:Vp("meta",g,n),noscript:Vp("noscript",o,n),script:Vp("script",v,n),style:Vp("style",l,n),title:Vp("title",{title:i,titleAttributes:d},n)}},Gfe=xht,a8=[],cFe=!!(typeof window<"u"&&window.document&&window.document.createElement),Kfe=class{constructor(t,s){_n(this,"instances",[]);_n(this,"canUseDOM",cFe);_n(this,"context");_n(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?a8:this.instances,add:t=>{(this.canUseDOM?a8:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?a8:this.instances).indexOf(t);(this.canUseDOM?a8:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=Gfe({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},yht={},dFe=ut.createContext(yht),Bk,uFe=(Bk=class extends M.Component{constructor(r){super(r);_n(this,"helmetData");this.helmetData=new Kfe(this.props.context||{},Bk.canUseDOM)}render(){return ut.createElement(dFe.Provider,{value:this.helmetData.value},this.props.children)}},_n(Bk,"canUseDOM",cFe),Bk),RC=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${jg}]`),a=[].slice.call(n),o=[];let l;return s&&s.length&&s.forEach(i=>{const d=document.createElement(t);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u))if(u==="innerHTML")d.innerHTML=i.innerHTML;else if(u==="cssText")d.styleSheet?d.styleSheet.cssText=i.cssText:d.appendChild(document.createTextNode(i.cssText));else{const f=u,g=typeof i[f]>"u"?"":i[f];d.setAttribute(u,g)}d.setAttribute(jg,"true"),a.some((u,f)=>(l=f,d.isEqualNode(u)))?a.splice(l,1):o.push(d)}),a.forEach(i=>{var d;return(d=i.parentNode)==null?void 0:d.removeChild(i)}),o.forEach(i=>r.appendChild(i)),{oldTags:a,newTags:o}},Zfe=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(jg),a=n?n.split(","):[],o=[...a],l=Object.keys(s);for(const i of l){const d=s[i]||"";r.getAttribute(i)!==d&&r.setAttribute(i,d),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(jg):r.getAttribute(jg)!==l.join(",")&&r.setAttribute(jg,l.join(","))},vht=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=iFe(t)),Zfe("title",s)},b4e=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:u,styleTags:f,title:g,titleAttributes:v}=t;Zfe("body",n),Zfe("html",a),vht(g,v);const _={baseTag:RC("base",r),linkTags:RC("link",o),metaTags:RC("meta",l),noscriptTags:RC("noscript",i),scriptTags:RC("script",u),styleTags:RC("style",f)},b={},w={};Object.keys(_).forEach(j=>{const{newTags:N,oldTags:S}=_[j];N.length&&(b[j]=N),S.length&&(w[j]=_[j].oldTags)}),s&&s(),d(t,b,w)},OA=null,_ht=t=>{OA&&cancelAnimationFrame(OA),t.defer?OA=requestAnimationFrame(()=>{b4e(t,()=>{OA=null})}):(b4e(t),OA=null)},bht=_ht,w4e=class extends M.Component{constructor(){super(...arguments);_n(this,"rendered",!1)}shouldComponentUpdate(s){return!rht(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=dht(s.get().map(o=>{const l={...o.props};return delete l.context,l}));uFe.canUseDOM?bht(a):Gfe&&(n=Gfe(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}},kpe,Gh=(kpe=class extends M.Component{shouldComponentUpdate(t){return!Jut(_4e(this.props,"helmetData"),_4e(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 y4e(v4e.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 ${v4e.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),y4e(!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 ut.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((d,u)=>(d[nht[u]||u]=o[u],d),{});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 Kfe)){const a=n;n=new Kfe(a.context,!0),delete r.helmetData}return n?ut.createElement(w4e,{...r,context:n.value}):ut.createElement(dFe.Consumer,null,a=>ut.createElement(w4e,{...r,context:a}))}},_n(kpe,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),kpe),Yfe=function(t,s){return Yfe=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])},Yfe(t,s)};function hFe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");Yfe(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var Qp=function(){return Qp=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 pFe(t,s){return function(r,n){s(r,n,t)}}function fFe(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,d=i==="getter"?"get":i==="setter"?"set":"value",u=!s&&t?n.static?t:t.prototype:null,f=s||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),g,v=!1,_=r.length-1;_>=0;_--){var b={};for(var w in n)b[w]=w==="access"?{}:n[w];for(var w in n.access)b.access[w]=n.access[w];b.addInitializer=function(N){if(v)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(N||null))};var j=(0,r[_])(i==="accessor"?{get:f.get,set:f.set}:f[d],b);if(i==="accessor"){if(j===void 0)continue;if(j===null||typeof j!="object")throw new TypeError("Object expected");(g=l(j.get))&&(f.get=g),(g=l(j.set))&&(f.set=g),(g=l(j.init))&&a.unshift(g)}else(g=l(j))&&(i==="field"?a.unshift(g):f[d]=g)}u&&Object.defineProperty(u,n.name,f),v=!0}function gFe(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 o1e(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 wFe(){for(var t=[],s=0;s1||d(_,w)})},b&&(a[_]=b(a[_])))}function d(_,b){try{u(n[_](b))}catch(w){v(o[0][3],w)}}function u(_){_.value instanceof e3?Promise.resolve(_.value.v).then(f,g):v(o[0][2],_)}function f(_){d("next",_)}function g(_){d("throw",_)}function v(_,b){_(b),o.shift(),o.length&&d(o[0][0],o[0][1])}}function NFe(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:e3(t[a](l)),done:!1}:o?o(l):l}:o}}function SFe(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 Hre=="function"?Hre(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,d){l=t[o](l),a(i,d,l.done,l.value)})}}function a(o,l,i,d){Promise.resolve(d).then(function(u){o({value:u,done:i})},l)}}function CFe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var wht=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},Xfe=function(t){return Xfe=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},Xfe(t)};function MFe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=Xfe(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>H0(async()=>{const{default:n}=await Promise.resolve().then(()=>WN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class c1e extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class j4e extends c1e{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class k4e extends c1e{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class N4e extends c1e{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var Qfe;(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"})(Qfe||(Qfe={}));class Cht{constructor(s,{headers:r={},customFetch:n,region:a=Qfe.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=Sht(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return ia(this,arguments,void 0,function*(r,n={}){var a;try{const{headers:o,method:l,body:i,signal:d}=n;let u={},{region:f}=n;f||(f=this.region);const g=new URL(`${this.url}/${r}`);f&&f!=="any"&&(u["x-region"]=f,g.searchParams.set("forceFunctionRegion",f));let v;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",v=i):typeof i=="string"?(u["Content-Type"]="text/plain",v=i):typeof FormData<"u"&&i instanceof FormData?v=i:(u["Content-Type"]="application/json",v=JSON.stringify(i)):v=i;const _=yield this.fetch(g.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),o),body:v,signal:d}).catch(N=>{throw N.name==="AbortError"?N:new j4e(N)}),b=_.headers.get("x-relay-error");if(b&&b==="true")throw new k4e(_);if(!_.ok)throw new N4e(_);let w=((a=_.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),j;return w==="application/json"?j=yield _.json():w==="application/octet-stream"||w==="application/pdf"?j=yield _.blob():w==="text/event-stream"?j=_:w==="multipart/form-data"?j=yield _.formData():j=yield _.text(),{data:j,error:null,response:_}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new j4e(o)}:{data:null,error:o,response:o instanceof N4e||o instanceof k4e?o.context:void 0}}})}}var pm={};const rM=aDe(Nht);var i8={},o8={},l8={},c8={},d8={},Mht=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")},t3=Mht();const Tht=t3.fetch,OFe=t3.fetch.bind(t3),RFe=t3.Headers,Aht=t3.Request,Eht=t3.Response,WN=Object.freeze(Object.defineProperty({__proto__:null,Headers:RFe,Request:Aht,Response:Eht,default:OFe,fetch:Tht},Symbol.toStringTag,{value:"Module"})),Pht=aDe(WN);var u8={},S4e;function FFe(){if(S4e)return u8;S4e=1,Object.defineProperty(u8,"__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 u8.default=t,u8}var C4e;function zFe(){if(C4e)return d8;C4e=1,Object.defineProperty(d8,"__esModule",{value:!0});const t=rM,s=t.__importDefault(Pht),r=t.__importDefault(FFe());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 d=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var f,g,v,_;let b=null,w=null,j=null,N=u.status,S=u.statusText;if(u.ok){if(this.method!=="HEAD"){const F=await u.text();F===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((f=this.headers.get("Accept"))===null||f===void 0)&&f.includes("application/vnd.pgrst.plan+text"))?w=F:w=JSON.parse(F))}const I=(g=this.headers.get("Prefer"))===null||g===void 0?void 0:g.match(/count=(exact|planned|estimated)/),L=(v=u.headers.get("content-range"))===null||v===void 0?void 0:v.split("/");I&&L&&L.length>1&&(j=parseInt(L[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(w)&&(w.length>1?(b={code:"PGRST116",details:`Results contain ${w.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},w=null,j=null,N=406,S="Not Acceptable"):w.length===1?w=w[0]:w=null)}else{const I=await u.text();try{b=JSON.parse(I),Array.isArray(b)&&u.status===404&&(w=[],b=null,N=200,S="OK")}catch{u.status===404&&I===""?(N=204,S="No Content"):b={message:I}}if(b&&this.isMaybeSingle&&(!((_=b==null?void 0:b.details)===null||_===void 0)&&_.includes("0 rows"))&&(b=null,N=200,S="OK"),b&&this.shouldThrowOnError)throw new r.default(b)}return{error:b,data:w,count:j,status:N,statusText:S}});return this.shouldThrowOnError||(d=d.catch(u=>{var f,g,v;return{error:{message:`${(f=u==null?void 0:u.name)!==null&&f!==void 0?f:"FetchError"}: ${u==null?void 0:u.message}`,details:`${(g=u==null?void 0:u.stack)!==null&&g!==void 0?g:""}`,hint:"",code:`${(v=u==null?void 0:u.code)!==null&&v!==void 0?v:""}`},data:null,count:null,status:0,statusText:""}})),d.then(o,l)}returns(){return this}overrideTypes(){return this}}return d8.default=n,d8}var M4e;function BFe(){if(M4e)return c8;M4e=1,Object.defineProperty(c8,"__esModule",{value:!0});const s=rM.__importDefault(zFe());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:d=i}={}){const u=d?`${d}.order`:"order",f=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${f?`${f},`:""}${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 d=typeof i>"u"?"offset":`${i}.offset`,u=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(d,`${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:d=!1,format:u="text"}={}){var f;const g=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,d?"wal":null].filter(Boolean).join("|"),v=(f=this.headers.get("Accept"))!==null&&f!==void 0?f:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${v}"; options=${g};`),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 c8.default=r,c8}var T4e;function d1e(){if(T4e)return l8;T4e=1,Object.defineProperty(l8,"__esModule",{value:!0});const s=rM.__importDefault(BFe()),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(d=>typeof d=="string"&&r.test(d)?`"${d}"`:`${d}`).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:d}={}){let u="";d==="plain"?u="pl":d==="phrase"?u="ph":d==="websearch"&&(u="w");const f=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${u}fts${f}.${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 d=i?`${i}.or`:"or";return this.url.searchParams.append(d,`(${o})`),this}filter(o,l,i){return this.url.searchParams.append(o,`${l}.${i}`),this}}return l8.default=n,l8}var A4e;function $Fe(){if(A4e)return o8;A4e=1,Object.defineProperty(o8,"__esModule",{value:!0});const s=rM.__importDefault(d1e());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??{},d=l?"HEAD":"GET";let u=!1;const f=(a??"*").split("").map(g=>/\s/.test(g)&&!u?"":(g==='"'&&(u=!u),g)).join("");return this.url.searchParams.set("select",f),i&&this.headers.append("Prefer",`count=${i}`),new s.default({method:d,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:o,defaultToNull:l=!0}={}){var i;const d="POST";if(o&&this.headers.append("Prefer",`count=${o}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const u=a.reduce((f,g)=>f.concat(Object.keys(g)),[]);if(u.length>0){const f=[...new Set(u)].map(g=>`"${g}"`);this.url.searchParams.set("columns",f.join(","))}}return new s.default({method:d,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:d=!0}={}){var u;const f="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}`),d||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const g=a.reduce((v,_)=>v.concat(Object.keys(_)),[]);if(g.length>0){const v=[...new Set(g)].map(_=>`"${_}"`);this.url.searchParams.set("columns",v.join(","))}}return new s.default({method:f,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 o8.default=r,o8}var E4e;function Iht(){if(E4e)return i8;E4e=1,Object.defineProperty(i8,"__esModule",{value:!0});const t=rM,s=t.__importDefault($Fe()),r=t.__importDefault(d1e());class n{constructor(o,{headers:l={},schema:i,fetch:d}={}){this.url=o,this.headers=new Headers(l),this.schemaName=i,this.fetch=d}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:d=!1,count:u}={}){var f;let g;const v=new URL(`${this.url}/rpc/${o}`);let _;i||d?(g=i?"HEAD":"GET",Object.entries(l).filter(([w,j])=>j!==void 0).map(([w,j])=>[w,Array.isArray(j)?`{${j.join(",")}}`:`${j}`]).forEach(([w,j])=>{v.searchParams.append(w,j)})):(g="POST",_=l);const b=new Headers(this.headers);return u&&b.set("Prefer",`count=${u}`),new r.default({method:g,url:v,headers:b,schema:this.schemaName,body:_,fetch:(f=this.fetch)!==null&&f!==void 0?f:fetch})}}return i8.default=n,i8}Object.defineProperty(pm,"__esModule",{value:!0});var qFe=pm.PostgrestError=QFe=pm.PostgrestBuilder=YFe=pm.PostgrestTransformBuilder=KFe=pm.PostgrestFilterBuilder=WFe=pm.PostgrestQueryBuilder=VFe=pm.PostgrestClient=void 0;const nM=rM,UFe=nM.__importDefault(Iht());var VFe=pm.PostgrestClient=UFe.default;const HFe=nM.__importDefault($Fe());var WFe=pm.PostgrestQueryBuilder=HFe.default;const GFe=nM.__importDefault(d1e());var KFe=pm.PostgrestFilterBuilder=GFe.default;const ZFe=nM.__importDefault(BFe());var YFe=pm.PostgrestTransformBuilder=ZFe.default;const XFe=nM.__importDefault(zFe());var QFe=pm.PostgrestBuilder=XFe.default;const JFe=nM.__importDefault(FFe());qFe=pm.PostgrestError=JFe.default;var eze=pm.default={PostgrestClient:UFe.default,PostgrestQueryBuilder:HFe.default,PostgrestFilterBuilder:GFe.default,PostgrestTransformBuilder:ZFe.default,PostgrestBuilder:XFe.default,PostgrestError:JFe.default};const Lht=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return QFe},get PostgrestClient(){return VFe},get PostgrestError(){return qFe},get PostgrestFilterBuilder(){return KFe},get PostgrestQueryBuilder(){return WFe},get PostgrestTransformBuilder(){return YFe},default:eze},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:Dht,PostgrestQueryBuilder:Lvs,PostgrestFilterBuilder:Dvs,PostgrestTransformBuilder:Ovs,PostgrestBuilder:Rvs,PostgrestError:Fvs}=eze||Lht;class Oht{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 Rht="2.78.0",Fht=`realtime-js/${Rht}`,zht="1.0.0",Jfe=1e4,Bht=1e3,$ht=100;var kP;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(kP||(kP={}));var Md;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Md||(Md={}));var mg;(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"})(mg||(mg={}));var ege;(function(t){t.websocket="websocket"})(ege||(ege={}));var dk;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(dk||(dk={}));class qht{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 d=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:d,payload:u}}}class tze{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 jl;(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"})(jl||(jl={}));const P4e=(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]=Uht(l,t,s,a),o),{}):{}},Uht=(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)?sze(o,l):tge(l)},sze=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return Ght(s,r)}switch(t){case jl.bool:return Vht(s);case jl.float4:case jl.float8:case jl.int2:case jl.int4:case jl.int8:case jl.numeric:case jl.oid:return Hht(s);case jl.json:case jl.jsonb:return Wht(s);case jl.timestamp:return Kht(s);case jl.abstime:case jl.date:case jl.daterange:case jl.int4range:case jl.int8range:case jl.money:case jl.reltime:case jl.text:case jl.time:case jl.timestamptz:case jl.timetz:case jl.tsrange:case jl.tstzrange:return tge(s);default:return tge(s)}},tge=t=>t,Vht=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Hht=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},Wht=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},Ght=(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=>sze(s,i))}return t},Kht=t=>typeof t=="string"?t.replace(" ","T"):t,rze=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 ahe{constructor(s,r,n={},a=Jfe){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 I4e;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(I4e||(I4e={}));class NP{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=NP.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=NP.syncDiff(this.state,d,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=NP.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={},d={};return this.map(o,(u,f)=>{l[u]||(d[u]=f)}),this.map(l,(u,f)=>{const g=o[u];if(g){const v=f.map(j=>j.presence_ref),_=g.map(j=>j.presence_ref),b=f.filter(j=>_.indexOf(j.presence_ref)<0),w=g.filter(j=>v.indexOf(j.presence_ref)<0);b.length>0&&(i[u]=b),w.length>0&&(d[u]=w)}else i[u]=f}),this.syncDiff(o,{joins:i,leaves:d},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,d)=>{var u;const f=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(d),f.length>0){const g=s[i].map(_=>_.presence_ref),v=f.filter(_=>g.indexOf(_.presence_ref)<0);s[i].unshift(...v)}n(i,f,d)}),this.map(l,(i,d)=>{let u=s[i];if(!u)return;const f=d.map(g=>g.presence_ref);u=u.filter(g=>f.indexOf(g.presence_ref)<0),s[i]=u,a(i,u,d),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 L4e;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(L4e||(L4e={}));var SP;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(SP||(SP={}));var Ky;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Ky||(Ky={}));class u1e{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=Md.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 ahe(this,mg.join,this.params,this.timeout),this.rejoinTimer=new tze(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Md.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=Md.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Md.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Md.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Md.errored,this.rejoinTimer.scheduleTimeout())}),this._on(mg.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new NP(this),this.broadcastEndpointURL=rze(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==Md.closed){const{config:{broadcast:l,presence:i,private:d}}=this.params,u=(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(_=>_.filter))!==null&&a!==void 0?a:[],f=!!this.bindings[SP.PRESENCE]&&this.bindings[SP.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,g={},v={broadcast:l,presence:Object.assign(Object.assign({},i),{enabled:f}),postgres_changes:u,private:d};this.socket.accessTokenValue&&(g.access_token=this.socket.accessTokenValue),this._onError(_=>s==null?void 0:s(Ky.CHANNEL_ERROR,_)),this._onClose(()=>s==null?void 0:s(Ky.CLOSED)),this.updateJoinPayload(Object.assign({config:v},g)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:_})=>{var b;if(this.socket.setAuth(),_===void 0){s==null||s(Ky.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,j=(b=w==null?void 0:w.length)!==null&&b!==void 0?b:0,N=[];for(let S=0;S{this.state=Md.errored,s==null||s(Ky.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(Ky.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===Md.joined&&s===SP.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 d=i.statusText;try{const u=await i.json();d=u.error||u.message||d}catch{}return Promise.reject(new Error(d))}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,d={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,d,(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,d;const u=this._push(s.type,s,r.timeout||this.timeout);s.type==="broadcast"&&!(!((d=(i=(l=this.params)===null||l===void 0?void 0:l.config)===null||i===void 0?void 0:i.broadcast)===null||d===void 0)&&d.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=Md.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(mg.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new ahe(this,mg.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=Md.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 ahe(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>$ht){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:d,leave:u,join:f}=mg;if(n&&[i,d,u,f].indexOf(l)>=0&&n!==this._joinRef())return;let v=this._onMessage(l,r,n);if(r&&!v)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(_=>{var b,w,j;return((b=_.filter)===null||b===void 0?void 0:b.event)==="*"||((j=(w=_.filter)===null||w===void 0?void 0:w.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===l}).map(_=>_.callback(v,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var b,w,j,N,S,A;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in _){const I=_.id,L=(b=_.filter)===null||b===void 0?void 0:b.event;return I&&((w=r.ids)===null||w===void 0?void 0:w.includes(I))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((j=r.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{const I=(S=(N=_==null?void 0:_.filter)===null||N===void 0?void 0:N.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return I==="*"||I===((A=r==null?void 0:r.event)===null||A===void 0?void 0:A.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof v=="object"&&"ids"in v){const b=v.data,{schema:w,table:j,commit_timestamp:N,type:S,errors:A}=b;v=Object.assign(Object.assign({},{schema:w,table:j,commit_timestamp:N,eventType:S,new:{},old:{},errors:A}),this._getPayloadRecords(b))}_.callback(v,n)})}_isClosed(){return this.state===Md.closed}_isJoined(){return this.state===Md.joined}_isJoining(){return this.state===Md.joining}_isLeaving(){return this.state===Md.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&&u1e.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(mg.close,{},s)}_onError(s){this._on(mg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Md.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=P4e(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=P4e(s.columns,s.old_record)),r}}const ihe=()=>{},h8={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},Zht=[1e3,2e3,5e3,1e4],Yht=1e4,Xht=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class Qht{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=Jfe,this.transport=null,this.heartbeatIntervalMs=h8.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=ihe,this.ref=0,this.reconnectTimer=null,this.logger=ihe,this.conn=null,this.sendBuffer=[],this.serializer=new qht,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)=>H0(async()=>{const{default:i}=await Promise.resolve().then(()=>WN);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}/${ege.websocket}`,this.httpEndpoint=rze(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=Oht.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:zht}))}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 kP.connecting:return dk.Connecting;case kP.open:return dk.Open;case kP.closing:return dk.Closing;default:return dk.Closed}}isConnected(){return this.connectionState()===dk.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 u1e(`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 d;(d=this.conn)===null||d===void 0||d.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(Bht,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},h8.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})`:"",d=o.status||"";this.log("receive",`${d} ${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(mg.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([Xht],{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:Fht};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(mg.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 tze(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},h8.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(s){var r,n,a,o,l,i,d,u,f;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:Jfe,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:h8.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:ihe,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=(d=s==null?void 0:s.reconnectAfterMs)!==null&&d!==void 0?d:g=>Zht[g-1]||Yht,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(g,v)=>v(JSON.stringify(g)),this.decode=(f=s==null?void 0:s.decode)!==null&&f!==void 0?f: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 h1e extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function vc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class Jht extends h1e{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 sge extends h1e{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const m1e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>H0(async()=>{const{default:n}=await Promise.resolve().then(()=>WN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},emt=()=>ia(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield H0(()=>Promise.resolve().then(()=>WN),void 0)).Response:Response}),rge=t=>{if(Array.isArray(t))return t.map(r=>rge(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]=rge(n)}),s},tmt=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)},ohe=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)},smt=(t,s,r)=>ia(void 0,void 0,void 0,function*(){const n=yield emt();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 Jht(ohe(a),o,l))}).catch(a=>{s(new sge(ohe(a),a))}):s(new sge(ohe(t),t))}),rmt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(tmt(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 J6(t,s,r,n,a,o){return ia(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,rmt(s,n,a,o)).then(d=>{if(!d.ok)throw d;return n!=null&&n.noResolveJson?d:d.json()}).then(d=>l(d)).catch(d=>smt(d,i,n))})})}function SI(t,s,r,n){return ia(this,void 0,void 0,function*(){return J6(t,"GET",s,r,n)})}function cg(t,s,r,n,a){return ia(this,void 0,void 0,function*(){return J6(t,"POST",s,n,a,r)})}function nge(t,s,r,n,a){return ia(this,void 0,void 0,function*(){return J6(t,"PUT",s,n,a,r)})}function nmt(t,s,r,n){return ia(this,void 0,void 0,function*(){return J6(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function p1e(t,s,r,n,a){return ia(this,void 0,void 0,function*(){return J6(t,"DELETE",s,n,a,r)})}class amt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return ia(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(vc(s))return{data:null,error:s};throw s}})}}var nze;class imt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[nze]="BlobDownloadBuilder",this.promise=null}asStream(){return new amt(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 ia(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(vc(s))return{data:null,error:s};throw s}})}}nze=Symbol.toStringTag;const omt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},D4e={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class lmt{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=m1e(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return ia(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},D4e),a);let i=Object.assign(Object.assign({},this.headers),s==="POST"&&{"x-upsert":String(l.upsert)});const d=l.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",l.cacheControl),d&&o.append("metadata",this.encodeMetadata(d)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",l.cacheControl),d&&o.append("metadata",this.encodeMetadata(d))):(o=n,i["cache-control"]=`max-age=${l.cacheControl}`,i["content-type"]=l.contentType,d&&(i["x-metadata"]=this.toBase64(this.encodeMetadata(d)))),a!=null&&a.headers&&(i=Object.assign(Object.assign({},i),a.headers));const u=this._removeEmptyFolders(r),f=this._getFinalPath(u),g=yield(s=="PUT"?nge:cg)(this.fetch,`${this.url}/object/${f}`,o,Object.assign({headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{}));return{data:{path:u,id:g.Id,fullPath:g.Key},error:null}}catch(o){if(this.shouldThrowOnError)throw o;if(vc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return ia(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return ia(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 d;const u=Object.assign({upsert:D4e.upsert},a),f=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(d=new FormData,d.append("cacheControl",u.cacheControl),d.append("",n)):typeof FormData<"u"&&n instanceof FormData?(d=n,d.append("cacheControl",u.cacheControl)):(d=n,f["cache-control"]=`max-age=${u.cacheControl}`,f["content-type"]=u.contentType);const g=yield nge(this.fetch,i.toString(),d,{headers:f});return{data:{path:o,fullPath:g.Key},error:null}}catch(d){if(this.shouldThrowOnError)throw d;if(vc(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(s,r){return ia(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 cg(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 h1e("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(vc(n))return{data:null,error:n};throw n}})}update(s,r,n){return ia(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return ia(this,void 0,void 0,function*(){try{return{data:yield cg(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(vc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return ia(this,void 0,void 0,function*(){try{return{data:{path:(yield cg(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(vc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return ia(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield cg(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(vc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return ia(this,void 0,void 0,function*(){try{const a=yield cg(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(vc(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),d=()=>SI(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new imt(d,this.shouldThrowOnError)}info(s){return ia(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield SI(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:rge(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(vc(n))return{data:null,error:n};throw n}})}exists(s){return ia(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield nmt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(vc(n)&&n instanceof sge){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",d=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});d!==""&&a.push(d);let u=a.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${u}`)}}}remove(s){return ia(this,void 0,void 0,function*(){try{return{data:yield p1e(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(vc(r))return{data:null,error:r};throw r}})}list(s,r,n){return ia(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},omt),r),{prefix:s||""});return{data:yield cg(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(vc(a))return{data:null,error:a};throw a}})}listV2(s,r){return ia(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield cg(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(vc(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 aze="2.78.0",ize={"X-Client-Info":`storage-js/${aze}`};class cmt{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({},ize),r),this.fetch=m1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return ia(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield SI(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(vc(r))return{data:null,error:r};throw r}})}getBucket(s){return ia(this,void 0,void 0,function*(){try{return{data:yield SI(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(vc(r))return{data:null,error:r};throw r}})}createBucket(s){return ia(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield cg(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(vc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return ia(this,void 0,void 0,function*(){try{return{data:yield nge(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(vc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return ia(this,void 0,void 0,function*(){try{return{data:yield cg(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(vc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ia(this,void 0,void 0,function*(){try{return{data:yield p1e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(vc(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 dmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},ize),r),this.fetch=m1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ia(this,void 0,void 0,function*(){try{return{data:yield cg(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(vc(r))return{data:null,error:r};throw r}})}listBuckets(s){return ia(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 SI(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(vc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ia(this,void 0,void 0,function*(){try{return{data:yield p1e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(vc(r))return{data:null,error:r};throw r}})}}const f1e={"X-Client-Info":`storage-js/${aze}`,"Content-Type":"application/json"};class oze extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function tp(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class lhe extends oze{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 umt extends oze{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var O4e;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(O4e||(O4e={}));const g1e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>H0(async()=>{const{default:n}=await Promise.resolve().then(()=>WN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},hmt=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)},R4e=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),mmt=(t,s,r)=>ia(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 lhe(R4e(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new lhe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new lhe(i,a,l))}}else s(new umt(R4e(t),t))}),pmt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(hmt(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 fmt(t,s,r,n,a,o){return ia(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,pmt(s,n,a,o)).then(d=>{if(!d.ok)throw d;if(n!=null&&n.noResolveJson)return d;const u=d.headers.get("content-type");return!u||!u.includes("application/json")?{}:d.json()}).then(d=>l(d)).catch(d=>mmt(d,i,n))})})}function sp(t,s,r,n,a){return ia(this,void 0,void 0,function*(){return fmt(t,"POST",s,n,a,r)})}class gmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},f1e),r),this.fetch=g1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return ia(this,void 0,void 0,function*(){try{return{data:(yield sp(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}getIndex(s,r){return ia(this,void 0,void 0,function*(){try{return{data:yield sp(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(tp(n))return{data:null,error:n};throw n}})}listIndexes(s){return ia(this,void 0,void 0,function*(){try{return{data:yield sp(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return ia(this,void 0,void 0,function*(){try{return{data:(yield sp(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(tp(n))return{data:null,error:n};throw n}})}}class xmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},f1e),r),this.fetch=g1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return ia(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 sp(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}getVectors(s){return ia(this,void 0,void 0,function*(){try{return{data:yield sp(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}listVectors(s){return ia(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 sp(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}queryVectors(s){return ia(this,void 0,void 0,function*(){try{return{data:yield sp(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}deleteVectors(s){return ia(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 sp(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}}class ymt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},f1e),r),this.fetch=g1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ia(this,void 0,void 0,function*(){try{return{data:(yield sp(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}getBucket(s){return ia(this,void 0,void 0,function*(){try{return{data:yield sp(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}listBuckets(){return ia(this,arguments,void 0,function*(s={}){try{return{data:yield sp(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ia(this,void 0,void 0,function*(){try{return{data:(yield sp(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(tp(r))return{data:null,error:r};throw r}})}}class vmt extends ymt{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new _mt(this.url,this.headers,s,this.fetch)}}class _mt extends gmt{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return ia(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 ia(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 ia(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 ia(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new bmt(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class bmt extends xmt{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 ia(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 ia(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 ia(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 ia(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 ia(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class wmt extends cmt{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new lmt(this.url,this.headers,s,this.fetch)}get vectors(){return new vmt(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new dmt(this.url+"/iceberg",this.headers,this.fetch)}}const jmt="2.78.0";let pE="";typeof Deno<"u"?pE="deno":typeof document<"u"?pE="web":typeof navigator<"u"&&navigator.product==="ReactNative"?pE="react-native":pE="node";const kmt={"X-Client-Info":`supabase-js-${pE}/${jmt}`},Nmt={headers:kmt},Smt={schema:"public"},Cmt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Mmt={},Tmt=t=>{let s;return t?s=t:typeof fetch>"u"?s=OFe:s=fetch,(...r)=>s(...r)},Amt=()=>typeof Headers>"u"?RFe:Headers,Emt=(t,s,r)=>{const n=Tmt(r),a=Amt();return async(o,l)=>{var i;const d=(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 ${d}`),n(o,Object.assign(Object.assign({},l),{headers:u}))}};function Pmt(t){return t.endsWith("/")?t:t+"/"}function Imt(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:d,auth:u,realtime:f,global:g}=s,v={db:Object.assign(Object.assign({},d),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},f),l),storage:{},global:Object.assign(Object.assign(Object.assign({},g),i),{headers:Object.assign(Object.assign({},(r=g==null?void 0:g.headers)!==null&&r!==void 0?r:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?v.accessToken=t.accessToken:delete v.accessToken,v}function Lmt(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(Pmt(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const lze="2.78.0",i4=30*1e3,age=3,che=age*i4,Dmt="http://localhost:9999",Omt="supabase.auth.token",Rmt={"X-Client-Info":`gotrue-js/${lze}`},ige="X-Supabase-Api-Version",cze={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Fmt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,zmt=10*60*1e3;class CI extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function ka(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Bmt extends CI{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function $mt(t){return ka(t)&&t.name==="AuthApiError"}class uk extends CI{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class A_ extends CI{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class rg extends A_{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function qmt(t){return ka(t)&&t.name==="AuthSessionMissingError"}class FC extends A_{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class m8 extends A_{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class p8 extends A_{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 Umt(t){return ka(t)&&t.name==="AuthImplicitGrantRedirectError"}class F4e extends A_{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 oge extends A_{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function dhe(t){return ka(t)&&t.name==="AuthRetryableFetchError"}class z4e extends A_{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class lge extends A_{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const Wre="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),B4e=` \r=`.split(""),Vmt=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(Wre[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(Wre[n]),s.queuedBits-=6}}function dze(t,s,r){const n=Vmt[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 q4e(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{Gmt(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 Wmt(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}Hmt(n,s)}}function Gmt(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 _5(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function yk(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>$4e(a,r,n)),$4e(null,r,n),s.join("")}function Zmt(t){return Math.round(Date.now()/1e3)+t}function Ymt(){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 xh=()=>typeof window<"u"&&typeof document<"u",Rb={tested:!1,writable:!1},uze=()=>{if(!xh())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Rb.tested)return Rb.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Rb.tested=!0,Rb.writable=!0}catch{Rb.tested=!0,Rb.writable=!1}return Rb.writable};function Xmt(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 hze=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>H0(async()=>{const{default:n}=await Promise.resolve().then(()=>WN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Qmt=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",o4=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},Fb=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},zv=async(t,s)=>{await t.removeItem(s)};class Yie{constructor(){this.promise=new Yie.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}Yie.promiseConstructor=Promise;function uhe(t){const s=t.split(".");if(s.length!==3)throw new lge("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function ept(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 tpt(t){return("0"+t.toString(16)).substr(-2)}function spt(){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,tpt).join("")}async function rpt(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 npt(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 rpt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function zC(t,s,r=!1){const n=spt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await o4(t,`${s}-code-verifier`,a);const o=await npt(n);return[o,n===o?"plain":"s256"]}const apt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function ipt(t){const s=t.headers.get(ige);if(!s||!s.match(apt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function opt(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 lpt(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 cpt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function BC(t){if(!cpt.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function hhe(){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 dpt(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 U4e(t){return JSON.parse(JSON.stringify(t))}const nk=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),upt=[502,503,504];async function V4e(t){var s;if(!Qmt(t))throw new oge(nk(t),0);if(upt.includes(t.status))throw new oge(nk(t),t.status);let r;try{r=await t.json()}catch(o){throw new uk(nk(o),o)}let n;const a=ipt(t);if(a&&a.getTime()>=cze["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 z4e(nk(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new rg}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 z4e(nk(r),t.status,r.weak_password.reasons);throw new Bmt(nk(r),t.status||500,n)}const hpt=(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 oi(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[ige]||(o[ige]=cze["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():"",d=await mpt(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(d):{data:Object.assign({},d),error:null}}async function mpt(t,s,r,n,a,o){const l=hpt(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(d){throw console.error(d),new oge(nk(d),0)}if(i.ok||await V4e(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await V4e(d)}}function ng(t){var s;let r=null;gpt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Zmt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function H4e(t){const s=ng(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 c1(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function ppt(t){return{data:t,error:null}}function fpt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=T_(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},d=Object.assign({},l);return{data:{properties:i,user:d},error:null}}function W4e(t){return t}function gpt(t){return t.access_token&&t.refresh_token&&t.expires_in}const mhe=["global","local","others"];class xpt{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=hze(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=mhe[0]){if(mhe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${mhe.join(", ")}`);try{return await oi(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ka(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await oi(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:c1})}catch(n){if(ka(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=T_(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 oi(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:fpt,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(ka(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await oi(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:c1})}catch(r){if(ka(r))return{data:{user:null},error:r};throw r}}async listUsers(s){var r,n,a,o,l,i,d;try{const u={nextPage:null,lastPage:0,total:0},f=await oi(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:W4e});if(f.error)throw f.error;const g=await f.json(),v=(l=f.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=f.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(b=>{const w=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(b.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(v)),{data:Object.assign(Object.assign({},g),u),error:null}}catch(u){if(ka(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){BC(s);try{return await oi(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:c1})}catch(r){if(ka(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){BC(s);try{return await oi(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:c1})}catch(n){if(ka(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){BC(s);try{return await oi(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:c1})}catch(n){if(ka(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){BC(s.userId);try{const{data:r,error:n}=await oi(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(ka(r))return{data:null,error:r};throw r}}async _deleteFactor(s){BC(s.userId),BC(s.id);try{return{data:await oi(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(ka(r))return{data:null,error:r};throw r}}async _listOAuthClients(s){var r,n,a,o,l,i,d;try{const u={nextPage:null,lastPage:0,total:0},f=await oi(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:W4e});if(f.error)throw f.error;const g=await f.json(),v=(l=f.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=f.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(b=>{const w=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(b.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(v)),{data:Object.assign(Object.assign({},g),u),error:null}}catch(u){if(ka(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await oi(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(ka(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await oi(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(ka(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await oi(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ka(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await oi(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(ka(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await oi(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(ka(r))return{data:null,error:r};throw r}}}function G4e(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const $C={debug:!!(globalThis&&uze()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class mze extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class ypt extends mze{}async function vpt(t,s,r){$C.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),$C.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){$C.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{$C.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw $C.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new ypt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if($C.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 _pt(){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 pze(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function bpt(t){return parseInt(t,16)}function wpt(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function jpt(t){var s;const{chainId:r,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:d,resources:u,scheme:f,uri:g,version:v}=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(!g)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(v!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${v}`);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 _=pze(t.address),b=f?`${f}://${n}`:n,w=t.statement?`${t.statement} `:"",j=`${b} wants you to sign in with your Ethereum account: ${_} ${w}`;let N=`URI: ${g} Version: ${v} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(N+=` Expiration Time: ${a.toISOString()}`),i&&(N+=` Not Before: ${i.toISOString()}`),d&&(N+=` Request ID: ${d}`),u){let S=` Resources:`;for(const A of u){if(!A||typeof A!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${A}`);S+=` - ${A}`}N+=S}return`${j} ${N}`}class gd 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 Gre extends gd{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function kpt({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 gd({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 gd({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 gd({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 gd({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 gd({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new gd({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 gd({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new gd({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(fze(l)){if(o.rp.id!==l)return new gd({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new gd({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 gd({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 gd({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 gd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Npt({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 gd({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new gd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(fze(n)){if(r.rpId!==n)return new gd({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new gd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new gd({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 gd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Spt{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 Cpt=new Spt;function Mpt(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=T_(t,["challenge","user","excludeCredentials"]),o=_5(s).buffer,l=Object.assign(Object.assign({},r),{id:_5(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 d=0;d0){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]=Kre(i,l):n[o]=Kre(l)}else n[o]=l}return n}function Opt(t,s){return Kre(Lpt,t,s||{})}function Rpt(t,s){return Kre(Dpt,t,s||{})}class Fpt{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 d=a??Cpt.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=Opt(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:f,error:g}=await Ppt({publicKey:u,signal:d});return f?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:f}},error:null}:{data:null,error:g}}case"request":{const u=Rpt(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:f,error:g}=await Ipt(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:u,signal:d}));return f?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:f}},error:null}:{data:null,error:g}}}}catch(l){return ka(l)?{data:null,error:l}:{data:null,error:new uk("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 CI("rpId is required for WebAuthn authentication")};try{if(!K4e())return{data:null,error:new uk("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:d}=l;return this._verify({factorId:s,challengeId:l.challengeId,webauthn:{type:d.type,rpId:r,rpOrigins:n,credential_response:d.credential_response}})}catch(l){return ka(l)?{data:null,error:l}:{data:null,error:new uk("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 CI("rpId is required for WebAuthn registration")};try{if(!K4e())return{data:null,error:new uk("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(f=>{var g;return(g=f.data)===null||g===void 0?void 0:g.all.find(v=>v.factor_type==="webauthn"&&v.friendly_name===s&&v.status!=="unverified")}).then(f=>f?this.client.mfa.unenroll({factorId:f==null?void 0:f.id}):void 0),{data:null,error:i};const{data:d,error:u}=await this._challenge({factorId:l.id,friendlyName:l.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:a},{create:o});return d?this._verify({factorId:l.id,challengeId:d.challengeId,webauthn:{rpId:r,rpOrigins:n,type:d.webauthn.type,credential_response:d.webauthn.credential_response}}):{data:null,error:u}}catch(l){return ka(l)?{data:null,error:l}:{data:null,error:new uk("Unexpected error in register",l)}}}}_pt();const zpt={url:Dmt,storageKey:Omt,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Rmt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function Z4e(t,s,r){return await r()}const qC={};class MI{get jwks(){var s,r;return(r=(s=qC[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){qC[this.storageKey]=Object.assign(Object.assign({},qC[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=qC[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){qC[this.storageKey]=Object.assign(Object.assign({},qC[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=MI.nextInstanceID,MI.nextInstanceID+=1,this.instanceID>0&&xh()&&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({},zpt),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 xpt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=hze(a.fetch),this.lock=a.lock||Z4e,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:xh()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=vpt:this.lock=Z4e,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 Fpt(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:uze()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=G4e(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=G4e(this.memoryStorage)),xh()&&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} (${lze}) ${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=Xmt(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),xh()&&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),Umt(o)){const d=(s=o.details)===null||s===void 0?void 0:s.code;if(d==="identity_already_exists"||d==="identity_not_found"||d==="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 ka(r)?{error:r}:{error:new uk("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await oi(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:ng}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(o){if(ka(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:f,password:g,options:v}=s;let _=null,b=null;this.flowType==="pkce"&&([_,b]=await zC(this.storage,this.storageKey)),o=await oi(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:v==null?void 0:v.emailRedirectTo,body:{email:f,password:g,data:(r=v==null?void 0:v.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:v==null?void 0:v.captchaToken},code_challenge:_,code_challenge_method:b},xform:ng})}else if("phone"in s){const{phone:f,password:g,options:v}=s;o=await oi(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:f,password:g,data:(n=v==null?void 0:v.data)!==null&&n!==void 0?n:{},channel:(a=v==null?void 0:v.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:v==null?void 0:v.captchaToken}},xform:ng})}else throw new m8("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 d=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(o){if(ka(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 oi(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:H4e})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await oi(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:H4e})}else throw new m8("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 FC}:(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(ka(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,d,u,f,g,v;let _,b;if("message"in s)_=s.message,b=s.signature;else{const{chain:w,wallet:j,statement:N,options:S}=s;let A;if(xh())if(typeof j=="object")A=j;else{const H=window;if("ethereum"in H&&typeof H.ethereum=="object"&&"request"in H.ethereum&&typeof H.ethereum.request=="function")A=H.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof j!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=j}const I=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),L=await A.request({method:"eth_requestAccounts"}).then(H=>H).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 F=pze(L[0]);let $=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!$){const H=await A.request({method:"eth_chainId"});$=bpt(H)}const q={domain:I.host,address:F,statement:N,uri:I.href,version:"1",chainId:$,nonce:(a=S==null?void 0:S.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=S==null?void 0:S.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=S==null?void 0:S.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(d=S==null?void 0:S.signInWithEthereum)===null||d===void 0?void 0:d.notBefore,requestId:(u=S==null?void 0:S.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(f=S==null?void 0:S.signInWithEthereum)===null||f===void 0?void 0:f.resources};_=jpt(q),b=await A.request({method:"personal_sign",params:[wpt(_),F]})}try{const{data:w,error:j}=await oi(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:_,signature:b},!((g=s.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(v=s.options)===null||v===void 0?void 0:v.captchaToken}}:null),xform:ng});if(j)throw j;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new FC}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:j})}catch(w){if(ka(w))return{data:{user:null,session:null},error:w};throw w}}async signInWithSolana(s){var r,n,a,o,l,i,d,u,f,g,v,_;let b,w;if("message"in s)b=s.message,w=s.signature;else{const{chain:j,wallet:N,statement:S,options:A}=s;let I;if(xh())if(typeof N=="object")I=N;else{const F=window;if("solana"in F&&typeof F.solana=="object"&&("signIn"in F.solana&&typeof F.solana.signIn=="function"||"signMessage"in F.solana&&typeof F.solana.signMessage=="function"))I=F.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"||!(A!=null&&A.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=A==null?void 0:A.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in I&&I.signIn){const F=await I.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},A==null?void 0:A.signInWithSolana),{version:"1",domain:L.host,uri:L.href}),S?{statement:S}:null));let $;if(Array.isArray(F)&&F[0]&&typeof F[0]=="object")$=F[0];else if(F&&typeof F=="object"&&"signedMessage"in F&&"signature"in F)$=F;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in $&&"signature"in $&&(typeof $.signedMessage=="string"||$.signedMessage instanceof Uint8Array)&&$.signature instanceof Uint8Array)b=typeof $.signedMessage=="string"?$.signedMessage:new TextDecoder().decode($.signedMessage),w=$.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in 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");b=[`${L.host} wants you to sign in with your Solana account:`,I.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${L.href}`,`Issued At: ${(a=(n=A==null?void 0:A.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=A==null?void 0:A.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${A.signInWithSolana.notBefore}`]:[],...!((l=A==null?void 0:A.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${A.signInWithSolana.expirationTime}`]:[],...!((i=A==null?void 0:A.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${A.signInWithSolana.chainId}`]:[],...!((d=A==null?void 0:A.signInWithSolana)===null||d===void 0)&&d.nonce?[`Nonce: ${A.signInWithSolana.nonce}`]:[],...!((u=A==null?void 0:A.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${A.signInWithSolana.requestId}`]:[],...!((g=(f=A==null?void 0:A.signInWithSolana)===null||f===void 0?void 0:f.resources)===null||g===void 0)&&g.length?["Resources",...A.signInWithSolana.resources.map($=>`- ${$}`)]:[]].join(` `);const F=await I.signMessage(new TextEncoder().encode(b),"utf8");if(!F||!(F instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=F}}try{const{data:j,error:N}=await oi(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:b,signature:yk(w)},!((v=s.options)===null||v===void 0)&&v.captchaToken?{gotrue_meta_security:{captcha_token:(_=s.options)===null||_===void 0?void 0:_.captchaToken}}:null),xform:ng});if(N)throw N;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new FC}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:N})}catch(j){if(ka(j))return{data:{user:null,session:null},error:j};throw j}}async _exchangeCodeForSession(s){const r=await Fb(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await oi(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:ng});if(await zv(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new FC}:(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(ka(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 oi(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:ng}),{data:d,error:u}=i;return u?{data:{user:null,session:null},error:u}:!d||!d.session||!d.user?{data:{user:null,session:null},error:new FC}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:u})}catch(r){if(ka(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:d}=s;let u=null,f=null;this.flowType==="pkce"&&([u,f]=await zC(this.storage,this.storageKey));const{error:g}=await oi(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},create_user:(n=d==null?void 0:d.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:u,code_challenge_method:f},redirectTo:d==null?void 0:d.emailRedirectTo});return{data:{user:null,session:null},error:g}}if("phone"in s){const{phone:i,options:d}=s,{data:u,error:f}=await oi(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:i,data:(a=d==null?void 0:d.data)!==null&&a!==void 0?a:{},create_user:(o=d==null?void 0:d.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},channel:(l=d==null?void 0:d.channel)!==null&&l!==void 0?l:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:f}}throw new m8("You must provide either an email or phone number.")}catch(i){if(ka(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 oi(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:ng});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const d=l.session,u=l.user;return d!=null&&d.access_token&&(await this._saveSession(d),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(a){if(ka(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 zC(this.storage,this.storageKey)),await oi(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:ppt})}catch(o){if(ka(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 rg;const{error:a}=await oi(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(ka(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 oi(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 oi(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 m8("You must provide either an email or phone number and a type")}catch(r){if(ka(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 Fb(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 oi(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:c1}):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 rg}:await oi(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:c1})})}catch(r){if(ka(r))return qmt(r)&&(await this._removeSession(),await zv(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 rg;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&s.email!=null&&([i,d]=await zC(this.storage,this.storageKey));const{data:u,error:f}=await oi(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:d}),jwt:l.access_token,xform:c1});if(f)throw f;return l.user=u.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(ka(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 rg;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=uhe(s.access_token);if(l.exp&&(n=l.exp,a=n<=r),a){const{data:i,error:d}=await this._callRefreshToken(s.refresh_token);if(d)return{data:{user:null,session:null},error:d};if(!i)return{data:{user:null,session:null},error:null};o=i}else{const{data:i,error:d}=await this._getUser(s.access_token);if(d)throw d;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(ka(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 rg;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(ka(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!xh())throw new p8("No browser detected.");if(s.error||s.error_description||s.error_code)throw new p8(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 F4e("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new p8("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 F4e("No code detected.");const{data:S,error:A}=await this._exchangeCodeForSession(s.code);if(A)throw A;const I=new URL(window.location.href);return I.searchParams.delete("code"),window.history.replaceState(window.history.state,"",I.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:d,token_type:u}=s;if(!o||!i||!l||!u)throw new p8("No session defined in URL");const f=Math.round(Date.now()/1e3),g=parseInt(i);let v=f+g;d&&(v=parseInt(d));const _=v-f;_*1e3<=i4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${g}s`);const b=v-g;f-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,v,f):f-b<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",b,v,f);const{data:w,error:j}=await this._getUser(o);if(j)throw j;const N={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:g,expires_at:v,refresh_token:l,token_type:u,user:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:N,redirectType:s.type},error:null}}catch(n){if(ka(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 Fb(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&&!($mt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await zv(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=Ymt(),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 zC(this.storage,this.storageKey,!0));try{return await oi(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(ka(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(ka(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,d,u,f;const{data:g,error:v}=o;if(v)throw v;const _=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:(d=s.options)===null||d===void 0?void 0:d.queryParams,skipBrowserRedirect:!0});return await oi(this.fetch,"GET",_,{headers:this.headers,jwt:(f=(u=g.session)===null||u===void 0?void 0:u.access_token)!==null&&f!==void 0?f:void 0})});if(a)throw a;return xh()&&!(!((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(ka(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:d,access_token:u,nonce:f}=s,g=await oi(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:d,access_token:u,nonce:f,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:ng}),{data:v,error:_}=g;return _?{data:{user:null,session:null},error:_}:!v||!v.session||!v.user?{data:{user:null,session:null},error:new FC}:(v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("USER_UPDATED",v.session)),{data:v,error:_})}catch(a){if(ka(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 oi(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(ka(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 ept(async a=>(a>0&&await Jmt(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await oi(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:ng})),(a,o)=>{const l=200*Math.pow(2,a);return o&&dhe(o)&&Date.now()+l-n{try{await i.callback(s,r)}catch(d){o.push(d)}});if(await Promise.all(l),o.length>0){for(let i=0;ithis._autoRefreshTokenTick(),i4);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)/i4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${i4}ms, refresh threshold is ${age} ticks`),a<=age&&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 mze)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!xh()||!(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 zC(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 oi(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(ka(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:d,error:u}=await oi(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"&&d.type==="totp"&&(!((a=d==null?void 0:d.totp)===null||a===void 0)&&a.qr_code)&&(d.totp.qr_code=`data:image/svg+xml;utf-8,${d.totp.qr_code}`),{data:d,error:null})})}catch(r){if(ka(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"?Apt(s.webauthn.credential_response):Ept(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:d}=await oi(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 d?{data:null,error:d}:(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:d})})}catch(r){if(ka(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 oi(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:Mpt(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:Tpt(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(ka(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}=uhe(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(f=>f.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 oi(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 rg}})}catch(r){if(ka(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 rg};const l=await oi(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&&xh()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(ka(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 rg};const l=await oi(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&&xh()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(ka(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+zmt>a)return n;const{data:o,error:l}=await oi(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:_,error:b}=await this.getSession();if(b||!_.session)return{data:null,error:b};n=_.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:d}}=uhe(n);r!=null&&r.allowExpired||opt(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:_}=await this.getUser(n);if(_)throw _;return{data:{claims:o,header:a,signature:l},error:null}}const f=lpt(a.alg),g=await crypto.subtle.importKey("jwk",u,f,!0,["verify"]);if(!await crypto.subtle.verify(f,g,l,Kmt(`${i}.${d}`)))throw new lge("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(ka(n))return{data:null,error:n};throw n}}}MI.nextInstanceID=0;const Bpt=MI;class $pt extends Bpt{constructor(s){super(s)}}class qpt{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=Lmt(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 d=`sb-${i.hostname.split(".")[0]}-auth-token`,u={db:Smt,realtime:Mmt,auth:Object.assign(Object.assign({},Cmt),{storageKey:d}),global:Nmt},f=Imt(n??{},u);this.storageKey=(a=f.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=f.global.headers)!==null&&o!==void 0?o:{},f.accessToken?(this.accessToken=f.accessToken,this.auth=new Proxy({},{get:(g,v)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(v)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=f.auth)!==null&&l!==void 0?l:{},this.headers,f.global.fetch),this.fetch=Emt(r,this._getAccessToken.bind(this),f.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},f.realtime)),this.rest=new Dht(new URL("rest/v1",i).href,{headers:this.headers,schema:f.db.schema,fetch:this.fetch}),this.storage=new wmt(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),f.accessToken||this._listenForAuthEvents()}get functions(){return new Cht(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:d,debug:u},f,g){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new $pt({url:this.authUrl.href,headers:Object.assign(Object.assign({},v),f),storageKey:l,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:d,debug:u,fetch:g,hasCustomAuthorizationHeader:Object.keys(this.headers).some(_=>_.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new Qht(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 Upt=(t,s,r)=>new qpt(t,s,r);function Vpt(){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}Vpt()&&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 Hpt="https://relzejiswnotikjgvjhz.supabase.co",Wpt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",K=Upt(Hpt,Wpt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),gze=M.createContext(void 0),Gpt=({children:t})=>{const[s,r]=M.useState(null),[n,a]=M.useState(null),[o,l]=M.useState(!0),[i,d]=M.useState(!1),[u,f]=M.useState(!1),[g,v]=M.useState(null),[_,b]=M.useState([]),[w,j]=M.useState(null),N=Or(),S=()=>{d(!1),f(!1),v(null),b([]),j(null)},A=async $=>{try{console.log("Checking roles via RPC for user:",$);const[{data:q,error:H},{data:U,error:Q}]=await Promise.all([K.rpc("has_role",{_user_id:$,_role:"admin"}),K.rpc("has_role",{_user_id:$,_role:"brokerage_manager"})]);if(H||Q)console.error("Role RPC errors:",{isAdminError:H,isBrokerError:Q}),d(!1),f(!1);else{const Y=!!q,ce=!!U;console.log("RPC roles result:",{adminValue:Y,brokerValue:ce}),d(Y),f(ce)}const{data:se,error:te}=await K.from("profiles").select("brokerage_id").eq("id",$).single();if(v(!te&&se?se.brokerage_id:null),U){console.log("Fetching managed brokerages for user:",$);const{data:Y,error:ce}=await K.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",$);if(console.log("Managed brokerage assignments result:",{assignments:Y,assignmentsError:ce}),ce||!Y){console.error("Error fetching managed brokerage assignments:",ce),b([]);return}const oe=Array.from(new Set(Y.map(be=>be.brokerage_id).filter(Boolean)));if(oe.length===0){b([]);return}const{data:le,error:de}=await K.from("brokerages").select("id, name").in("id",oe);if(console.log("Managed brokerages details result:",{brokeragesData:le,brokeragesError:de}),de||!le){console.error("Error fetching managed brokerages details:",de),b([]);return}const xe=le.map(be=>({id:be.id,name:be.name})).sort((be,ye)=>oe.indexOf(be.id)-oe.indexOf(ye.id));console.log("Parsed managed brokerages:",xe),b(xe),xe.length>0&&j(be=>be??xe[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),b([])}catch(q){console.error("Unexpected error in checkRoles:",q),S()}};M.useEffect(()=>{let $=!0,q=!1;const H=()=>{!$||q||(q=!0,l(!1))},{data:{subscription:U}}=K.auth.onAuthStateChange((te,Y)=>{console.log("Auth event:",te),$&&(a(Y),r((Y==null?void 0:Y.user)??null),H(),te==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{N("/profile?reset=true")},100)),Y!=null&&Y.user?setTimeout(()=>{A(Y.user.id)},0):S())}),Q=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),H()},4e3);return(async()=>{try{const{data:{session:te}}=await K.auth.getSession();if(!$)return;a(te),r((te==null?void 0:te.user)??null),te!=null&&te.user?await A(te.user.id):S()}catch(te){console.error("Error restoring auth session:",te),$&&(a(null),r(null),S())}finally{H()}})(),()=>{$=!1,window.clearTimeout(Q),U.unsubscribe()}},[]);const I=async($,q)=>{const{error:H}=await K.auth.signInWithPassword({email:$,password:q});if(H)throw ge.error(H.message),H;ge.success("Welcome back!"),N("/dashboard")},L=async($,q,H)=>{const U=`${window.location.origin}/dashboard`,{error:Q}=await K.auth.signUp({email:$,password:q,options:{emailRedirectTo:U,data:{name:H}}});if(Q)throw ge.error(Q.message),Q;ge.success("Account created! Welcome to LevelUp."),N("/dashboard")},F=async()=>{try{const{data:{session:$}}=await K.auth.getSession();if($){const{error:q}=await K.auth.signOut();q?q.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",q.message):(console.error("Sign out error:",q),ge.error(q.message)):ge.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),d(!1),f(!1),v(null),b([]),j(null),N("/auth")}catch($){console.error("Unexpected sign out error:",$),N("/auth")}};return e.jsx(gze.Provider,{value:{user:s,session:n,loading:o,signIn:I,signUp:L,signOut:F,isAdmin:i,isBrokerageManager:u,brokerageId:g,managedBrokerages:_,selectedBrokerageId:w,setSelectedBrokerageId:j},children:t})},Qs=()=>{const t=M.useContext(gze);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},xze=M.createContext(void 0),zb="levelup_admin_session",Bv="levelup_impersonation",Kpt=({children:t})=>{const[s,r]=M.useState(!1),[n,a]=M.useState(null),[o,l]=M.useState(!1);M.useEffect(()=>{const u=sessionStorage.getItem(Bv);if(u)try{const f=JSON.parse(u);r(!0),a(f)}catch{sessionStorage.removeItem(Bv)}},[]);const i=async u=>{l(!0);try{const{data:{session:f}}=await K.auth.getSession();if(!f)return ge.error("No active session found"),!1;const g={access_token:f.access_token,refresh_token:f.refresh_token};sessionStorage.setItem(zb,JSON.stringify(g));const v=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.access_token}`},body:JSON.stringify({targetUserId:u})}),_=await v.json();if(!v.ok)throw new Error(_.error||"Failed to impersonate user");const b={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(Bv,JSON.stringify(b)),_.method==="session"){const{error:w}=await K.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(zb),sessionStorage.removeItem(Bv),new Error("Failed to establish impersonation session")}else{const w=_.type||"recovery",{error:j}=await K.auth.verifyOtp({token_hash:_.token_hash,type:w});if(j)throw console.error("Verify OTP error:",j),sessionStorage.removeItem(zb),sessionStorage.removeItem(Bv),new Error("Failed to establish impersonation session")}return r(!0),a(b),ge.success(`Now viewing as ${b.name}`),window.location.href="/dashboard",!0}catch(f){return console.error("Impersonation error:",f),ge.error(f.message||"Failed to impersonate user"),sessionStorage.removeItem(zb),sessionStorage.removeItem(Bv),!1}finally{l(!1)}},d=async()=>{l(!0);try{const u=sessionStorage.getItem(zb);if(!u){await K.auth.signOut(),window.location.href="/auth";return}const f=JSON.parse(u);await K.auth.signOut();const{error:g}=await K.auth.setSession({access_token:f.access_token,refresh_token:f.refresh_token});if(sessionStorage.removeItem(zb),sessionStorage.removeItem(Bv),g){console.error("Failed to restore admin session:",g),ge.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),ge.success("Returned to admin account"),window.location.href="/admin/members"}catch(u){console.error("Stop impersonation error:",u),ge.error("Failed to restore admin session"),sessionStorage.removeItem(zb),sessionStorage.removeItem(Bv),window.location.href="/auth"}finally{l(!1)}};return e.jsx(xze.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:t})},x1e=()=>{const t=M.useContext(xze);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},TI=VN("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"}}),Z=M.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?Dve:"button";return e.jsx(l,{className:It(TI({variant:s,size:r,className:t})),ref:o,...a})});Z.displayName="Button";const Zpt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=x1e();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(jh,{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(Z,{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(Rs,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Vr,{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"})]})})]})})},yze=M.createContext(void 0),UC="levelup_acting_as",f8="levelup_acting_as_self",Ypt=({children:t})=>{const{user:s}=Qs(),[r,n]=M.useState(!1),[a,o]=M.useState([]),[l,i]=M.useState(null),[d,u]=M.useState({}),[f,g]=M.useState(!0),[v,_]=M.useState(()=>sessionStorage.getItem(f8)==="true");M.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),g(!1);return}(async()=>{g(!0);try{const{data:A}=await K.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!A){n(!1),o([]),i(null),u({}),g(!1);return}n(!0);const{data:I,error:L}=await K.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(L||!I||I.length===0){o([]),g(!1);return}const F=I.map(H=>H.agent_id),{data:$}=await K.from("profiles").select("id, name, email, avatar_url").in("id",F),q=($||[]).map(H=>({id:H.id,name:H.name||H.email||"Unknown",email:H.email||"",avatar_url:H.avatar_url}));if(o(q),sessionStorage.getItem(f8)==="true")_(!0),i(null),u({});else{const H=sessionStorage.getItem(UC);if(H){const U=q.find(Q=>Q.id===H);if(U){i(U);const Q=I.find(se=>se.agent_id===H);u((Q==null?void 0:Q.permissions)||{})}else if(q.length>0){i(q[0]);const Q=I.find(se=>se.agent_id===q[0].id);u((Q==null?void 0:Q.permissions)||{}),sessionStorage.setItem(UC,q[0].id)}}else if(q.length>0){i(q[0]);const U=I.find(Q=>Q.agent_id===q[0].id);u((U==null?void 0:U.permissions)||{}),sessionStorage.setItem(UC,q[0].id)}}}catch(A){console.error("Error loading assistant data:",A)}finally{g(!1)}})()},[s==null?void 0:s.id]);const b=S=>{i(S),_(!1),sessionStorage.removeItem(f8),S?(sessionStorage.setItem(UC,S.id),K.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",S.id).single().then(({data:A})=>{u((A==null?void 0:A.permissions)||{})})):(sessionStorage.removeItem(UC),u({}))},w=()=>{_(!0),i(null),u({}),sessionStorage.setItem(f8,"true"),sessionStorage.removeItem(UC)},j=S=>!r||v?!0:d[S]===!0,N=r&&l&&!v?l.id:(s==null?void 0:s.id)||null;return e.jsx(yze.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:b,effectiveUserId:N,permissions:d,hasPermission:j,isLoading:f,isActingAsSelf:v,setActingAsSelf:w},children:t})},y1e=()=>{const t=M.useContext(yze);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},vi=()=>{const{effectiveUserId:t}=y1e();return t};var vze={exports:{}},_ze={};/** * @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 s3=M;function Xpt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Qpt=typeof Object.is=="function"?Object.is:Xpt,Jpt=s3.useState,eft=s3.useEffect,tft=s3.useLayoutEffect,sft=s3.useDebugValue;function rft(t,s){var r=s(),n=Jpt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return tft(function(){a.value=r,a.getSnapshot=s,phe(a)&&o({inst:a})},[t,r,s]),eft(function(){return phe(a)&&o({inst:a}),t(function(){phe(a)&&o({inst:a})})},[t]),sft(r),r}function phe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!Qpt(t,r)}catch{return!0}}function nft(t,s){return s()}var aft=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?nft:rft;_ze.useSyncExternalStore=s3.useSyncExternalStore!==void 0?s3.useSyncExternalStore:aft;vze.exports=_ze;var ift=vze.exports;function oft(){return ift.useSyncExternalStore(lft,()=>!0,()=>!1)}function lft(){return()=>{}}var v1e="Avatar",[cft]=Cc(v1e),[dft,bze]=cft(v1e),wze=M.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=M.useState("idle");return e.jsx(dft,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Qr.span,{...n,ref:s})})});wze.displayName=v1e;var jze="AvatarImage",kze=M.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=bze(jze,r),i=uft(n,o),d=Bc(u=>{a(u),l.onImageLoadingStatusChange(u)});return Hc(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(Qr.img,{...o,ref:s,src:n}):null});kze.displayName=jze;var Nze="AvatarFallback",Sze=M.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=bze(Nze,r),[l,i]=M.useState(n===void 0);return M.useEffect(()=>{if(n!==void 0){const d=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(d)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(Qr.span,{...a,ref:s}):null});Sze.displayName=Nze;function Y4e(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function uft(t,{referrerPolicy:s,crossOrigin:r}){const n=oft(),a=M.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=M.useState(()=>Y4e(o,t));return Hc(()=>{i(Y4e(o,t))},[o,t]),Hc(()=>{const d=g=>()=>{i(g)};if(!o)return;const u=d("loaded"),f=d("error");return o.addEventListener("load",u),o.addEventListener("error",f),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",f)}},[o,r,s]),l}var Cze=wze,Mze=kze,Tze=Sze;const mn=M.forwardRef(({className:t,...s},r)=>e.jsx(Cze,{ref:r,className:It("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));mn.displayName=Cze.displayName;const ba=M.forwardRef(({className:t,...s},r)=>e.jsx(Mze,{ref:r,className:It("aspect-square h-full w-full",t),...s}));ba.displayName=Mze.displayName;const pn=M.forwardRef(({className:t,...s},r)=>e.jsx(Tze,{ref:r,className:It("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));pn.displayName=Tze.displayName;const hft=VN("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 nt({className:t,variant:s,...r}){return e.jsx("div",{className:It(hft({variant:s}),t),...r})}var mft=M.createContext(void 0);function E_(t){const s=M.useContext(mft);return t||s||"ltr"}var fhe=0;function Xie(){M.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??X4e()),document.body.insertAdjacentElement("beforeend",t[1]??X4e()),fhe++,()=>{fhe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),fhe--}},[])}function X4e(){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 ghe="focusScope.autoFocusOnMount",xhe="focusScope.autoFocusOnUnmount",Q4e={bubbles:!1,cancelable:!0},pft="FocusScope",eL=M.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=M.useState(null),u=Bc(a),f=Bc(o),g=M.useRef(null),v=Sa(s,w=>d(w)),_=M.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;M.useEffect(()=>{if(n){let w=function(A){if(_.paused||!i)return;const I=A.target;i.contains(I)?g.current=I:Vv(g.current,{select:!0})},j=function(A){if(_.paused||!i)return;const I=A.relatedTarget;I!==null&&(i.contains(I)||Vv(g.current,{select:!0}))},N=function(A){if(document.activeElement===document.body)for(const L of A)L.removedNodes.length>0&&Vv(i)};document.addEventListener("focusin",w),document.addEventListener("focusout",j);const S=new MutationObserver(N);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),S.disconnect()}}},[n,i,_.paused]),M.useEffect(()=>{if(i){e5e.add(_);const w=document.activeElement;if(!i.contains(w)){const N=new CustomEvent(ghe,Q4e);i.addEventListener(ghe,u),i.dispatchEvent(N),N.defaultPrevented||(fft(_ft(Aze(i)),{select:!0}),document.activeElement===w&&Vv(i))}return()=>{i.removeEventListener(ghe,u),setTimeout(()=>{const N=new CustomEvent(xhe,Q4e);i.addEventListener(xhe,f),i.dispatchEvent(N),N.defaultPrevented||Vv(w??document.body,{select:!0}),i.removeEventListener(xhe,f),e5e.remove(_)},0)}}},[i,u,f,_]);const b=M.useCallback(w=>{if(!r&&!n||_.paused)return;const j=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,N=document.activeElement;if(j&&N){const S=w.currentTarget,[A,I]=gft(S);A&&I?!w.shiftKey&&N===I?(w.preventDefault(),r&&Vv(A,{select:!0})):w.shiftKey&&N===A&&(w.preventDefault(),r&&Vv(I,{select:!0})):N===S&&w.preventDefault()}},[r,n,_.paused]);return e.jsx(Qr.div,{tabIndex:-1,...l,ref:v,onKeyDown:b})});eL.displayName=pft;function fft(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(Vv(n,{select:s}),document.activeElement!==r)return}function gft(t){const s=Aze(t),r=J4e(s,t),n=J4e(s.reverse(),t);return[r,n]}function Aze(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 J4e(t,s){for(const r of t)if(!xft(r,{upTo:s}))return r}function xft(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 yft(t){return t instanceof HTMLInputElement&&"select"in t}function Vv(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&yft(t)&&s&&t.select()}}var e5e=vft();function vft(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=t5e(t,s),t.unshift(s)},remove(s){var r;t=t5e(t,s),(r=t[0])==null||r.resume()}}}function t5e(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function _ft(t){return t.filter(s=>s.tagName!=="A")}var yhe="rovingFocusGroup.onEntryFocus",bft={bubbles:!1,cancelable:!0},tL="RovingFocusGroup",[cge,Eze,wft]=W6(tL),[jft,P_]=Cc(tL,[wft]),[kft,Nft]=jft(tL),Pze=M.forwardRef((t,s)=>e.jsx(cge.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(cge.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Sft,{...t,ref:s})})}));Pze.displayName=tL;var Sft=M.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...g}=t,v=M.useRef(null),_=Sa(s,v),b=E_(o),[w,j]=uu({prop:l,defaultProp:i??null,onChange:d,caller:tL}),[N,S]=M.useState(!1),A=Bc(u),I=Eze(r),L=M.useRef(!1),[F,$]=M.useState(0);return M.useEffect(()=>{const q=v.current;if(q)return q.addEventListener(yhe,A),()=>q.removeEventListener(yhe,A)},[A]),e.jsx(kft,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:w,onItemFocus:M.useCallback(q=>j(q),[j]),onItemShiftTab:M.useCallback(()=>S(!0),[]),onFocusableItemAdd:M.useCallback(()=>$(q=>q+1),[]),onFocusableItemRemove:M.useCallback(()=>$(q=>q-1),[]),children:e.jsx(Qr.div,{tabIndex:N||F===0?-1:0,"data-orientation":n,...g,ref:_,style:{outline:"none",...t.style},onMouseDown:Sr(t.onMouseDown,()=>{L.current=!0}),onFocus:Sr(t.onFocus,q=>{const H=!L.current;if(q.target===q.currentTarget&&H&&!N){const U=new CustomEvent(yhe,bft);if(q.currentTarget.dispatchEvent(U),!U.defaultPrevented){const Q=I().filter(oe=>oe.focusable),se=Q.find(oe=>oe.active),te=Q.find(oe=>oe.id===w),ce=[se,te,...Q].filter(Boolean).map(oe=>oe.ref.current);Dze(ce,f)}}L.current=!1}),onBlur:Sr(t.onBlur,()=>S(!1))})})}),Ize="RovingFocusGroupItem",Lze=M.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=Bd(),u=o||d,f=Nft(Ize,r),g=f.currentTabStopId===u,v=Eze(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:w}=f;return M.useEffect(()=>{if(n)return _(),()=>b()},[n,_,b]),e.jsx(cge.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(Qr.span,{tabIndex:g?0:-1,"data-orientation":f.orientation,...i,ref:s,onMouseDown:Sr(t.onMouseDown,j=>{n?f.onItemFocus(u):j.preventDefault()}),onFocus:Sr(t.onFocus,()=>f.onItemFocus(u)),onKeyDown:Sr(t.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){f.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const N=Tft(j,f.orientation,f.dir);if(N!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let A=v().filter(I=>I.focusable).map(I=>I.ref.current);if(N==="last")A.reverse();else if(N==="prev"||N==="next"){N==="prev"&&A.reverse();const I=A.indexOf(j.currentTarget);A=f.loop?Aft(A,I+1):A.slice(I+1)}setTimeout(()=>Dze(A))}}),children:typeof l=="function"?l({isCurrentTabStop:g,hasTabStop:w!=null}):l})})});Lze.displayName=Ize;var Cft={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Mft(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Tft(t,s,r){const n=Mft(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Cft[n]}function Dze(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function Aft(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Qie=Pze,Jie=Lze,Eft=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},VC=new WeakMap,g8=new WeakMap,x8={},vhe=0,Oze=function(t){return t&&(t.host||Oze(t.parentNode))},Pft=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=Oze(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})},Ift=function(t,s,r,n){var a=Pft(s,Array.isArray(t)?t:[t]);x8[r]||(x8[r]=new WeakMap);var o=x8[r],l=[],i=new Set,d=new Set(a),u=function(g){!g||i.has(g)||(i.add(g),u(g.parentNode))};a.forEach(u);var f=function(g){!g||d.has(g)||Array.prototype.forEach.call(g.children,function(v){if(i.has(v))f(v);else try{var _=v.getAttribute(n),b=_!==null&&_!=="false",w=(VC.get(v)||0)+1,j=(o.get(v)||0)+1;VC.set(v,w),o.set(v,j),l.push(v),w===1&&b&&g8.set(v,!0),j===1&&v.setAttribute(r,"true"),b||v.setAttribute(n,"true")}catch(N){console.error("aria-hidden: cannot operate on ",v,N)}})};return f(s),i.clear(),vhe++,function(){l.forEach(function(g){var v=VC.get(g)-1,_=o.get(g)-1;VC.set(g,v),o.set(g,_),v||(g8.has(g)||g.removeAttribute(n),g8.delete(g)),_||g.removeAttribute(r)}),vhe--,vhe||(VC=new WeakMap,VC=new WeakMap,g8=new WeakMap,x8={})}},eoe=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=Eft(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),Ift(n,a,r,"aria-hidden")):function(){return null}},Use="right-scroll-bar-position",Vse="width-before-scroll-bar",Lft="with-scroll-bars-hidden",Dft="--removed-body-scroll-bar-size";function _he(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function Oft(t,s){var r=M.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 Rft=typeof window<"u"?M.useLayoutEffect:M.useEffect,s5e=new WeakMap;function Fft(t,s){var r=Oft(null,function(n){return t.forEach(function(a){return _he(a,n)})});return Rft(function(){var n=s5e.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||_he(i,null)}),o.forEach(function(i){a.has(i)||_he(i,l)})}s5e.set(r,t)},[t]),r}function zft(t){return t}function Bft(t,s){s===void 0&&(s=zft);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 d=function(){var f=l;l=[],f.forEach(o)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(f){l.push(f),u()},filter:function(f){return l=l.filter(f),r}}}};return a}function $ft(t){t===void 0&&(t={});var s=Bft(null);return s.options=Qp({async:!0,ssr:!1},t),s}var Rze=function(t){var s=t.sideCar,r=T_(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 M.createElement(n,Qp({},r))};Rze.isSideCarExport=!0;function qft(t,s){return t.useMedium(s),Rze}var Fze=$ft(),bhe=function(){},toe=M.forwardRef(function(t,s){var r=M.useRef(null),n=M.useState({onScrollCapture:bhe,onWheelCapture:bhe,onTouchMoveCapture:bhe}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,d=t.className,u=t.removeScrollBar,f=t.enabled,g=t.shards,v=t.sideCar,_=t.noRelative,b=t.noIsolation,w=t.inert,j=t.allowPinchZoom,N=t.as,S=N===void 0?"div":N,A=t.gapMode,I=T_(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),L=v,F=Fft([r,s]),$=Qp(Qp({},I),a);return M.createElement(M.Fragment,null,f&&M.createElement(L,{sideCar:Fze,removeScrollBar:u,shards:g,noRelative:_,noIsolation:b,inert:w,setCallbacks:o,allowPinchZoom:!!j,lockRef:r,gapMode:A}),l?M.cloneElement(M.Children.only(i),Qp(Qp({},$),{ref:F})):M.createElement(S,Qp({},$,{className:d,ref:F}),i))});toe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};toe.classNames={fullWidth:Vse,zeroRight:Use};var Uft=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Vft(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=Uft();return s&&t.setAttribute("nonce",s),t}function Hft(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function Wft(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var Gft=function(){var t=0,s=null;return{add:function(r){t==0&&(s=Vft())&&(Hft(s,r),Wft(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},Kft=function(){var t=Gft();return function(s,r){M.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},zze=function(){var t=Kft(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},Zft={left:0,top:0,right:0,gap:0},whe=function(t){return parseInt(t||"",10)||0},Yft=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[whe(r),whe(n),whe(a)]},Xft=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Zft;var s=Yft(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])}},Qft=zze(),b5="data-scroll-locked",Jft=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(Lft,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(b5,`] { 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(Use,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(Vse,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(Use," .").concat(Use,` { right: 0 `).concat(n,`; } .`).concat(Vse," .").concat(Vse,` { margin-right: 0 `).concat(n,`; } body[`).concat(b5,`] { `).concat(Dft,": ").concat(i,`px; } `)},r5e=function(){var t=parseInt(document.body.getAttribute(b5)||"0",10);return isFinite(t)?t:0},egt=function(){M.useEffect(function(){return document.body.setAttribute(b5,(r5e()+1).toString()),function(){var t=r5e()-1;t<=0?document.body.removeAttribute(b5):document.body.setAttribute(b5,t.toString())}},[])},tgt=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;egt();var o=M.useMemo(function(){return Xft(a)},[a]);return M.createElement(Qft,{styles:Jft(o,!s,a,r?"":"!important")})},dge=!1;if(typeof window<"u")try{var y8=Object.defineProperty({},"passive",{get:function(){return dge=!0,!0}});window.addEventListener("test",y8,y8),window.removeEventListener("test",y8,y8)}catch{dge=!1}var HC=dge?{passive:!1}:!1,sgt=function(t){return t.tagName==="TEXTAREA"},Bze=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!sgt(t)&&r[s]==="visible")},rgt=function(t){return Bze(t,"overflowY")},ngt=function(t){return Bze(t,"overflowX")},n5e=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=$ze(t,n);if(a){var o=qze(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},agt=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},igt=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},$ze=function(t,s){return t==="v"?rgt(s):ngt(s)},qze=function(t,s){return t==="v"?agt(s):igt(s)},ogt=function(t,s){return t==="h"&&s==="rtl"?-1:1},lgt=function(t,s,r,n,a){var o=ogt(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,d=s.contains(i),u=!1,f=l>0,g=0,v=0;do{if(!i)break;var _=qze(t,i),b=_[0],w=_[1],j=_[2],N=w-j-o*b;(b||N)&&$ze(t,i)&&(g+=N,v+=b);var S=i.parentNode;i=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!d&&i!==document.body||d&&(s.contains(i)||s===i));return(f&&Math.abs(g)<1||!f&&Math.abs(v)<1)&&(u=!0),u},v8=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},a5e=function(t){return[t.deltaX,t.deltaY]},i5e=function(t){return t&&"current"in t?t.current:t},cgt=function(t,s){return t[0]===s[0]&&t[1]===s[1]},dgt=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},ugt=0,WC=[];function hgt(t){var s=M.useRef([]),r=M.useRef([0,0]),n=M.useRef(),a=M.useState(ugt++)[0],o=M.useState(zze)[0],l=M.useRef(t);M.useEffect(function(){l.current=t},[t]),M.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=l1e([t.lockRef.current],(t.shards||[]).map(i5e),!0).filter(Boolean);return w.forEach(function(j){return j.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=M.useCallback(function(w,j){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var N=v8(w),S=r.current,A="deltaX"in w?w.deltaX:S[0]-N[0],I="deltaY"in w?w.deltaY:S[1]-N[1],L,F=w.target,$=Math.abs(A)>Math.abs(I)?"h":"v";if("touches"in w&&$==="h"&&F.type==="range")return!1;var q=n5e($,F);if(!q)return!0;if(q?L=$:(L=$==="v"?"h":"v",q=n5e($,F)),!q)return!1;if(!n.current&&"changedTouches"in w&&(A||I)&&(n.current=L),!L)return!0;var H=n.current||L;return lgt(H,j,w,H==="h"?A:I)},[]),d=M.useCallback(function(w){var j=w;if(!(!WC.length||WC[WC.length-1]!==o)){var N="deltaY"in j?a5e(j):v8(j),S=s.current.filter(function(L){return L.name===j.type&&(L.target===j.target||j.target===L.shadowParent)&&cgt(L.delta,N)})[0];if(S&&S.should){j.cancelable&&j.preventDefault();return}if(!S){var A=(l.current.shards||[]).map(i5e).filter(Boolean).filter(function(L){return L.contains(j.target)}),I=A.length>0?i(j,A[0]):!l.current.noIsolation;I&&j.cancelable&&j.preventDefault()}}},[]),u=M.useCallback(function(w,j,N,S){var A={name:w,delta:j,target:N,should:S,shadowParent:mgt(N)};s.current.push(A),setTimeout(function(){s.current=s.current.filter(function(I){return I!==A})},1)},[]),f=M.useCallback(function(w){r.current=v8(w),n.current=void 0},[]),g=M.useCallback(function(w){u(w.type,a5e(w),w.target,i(w,t.lockRef.current))},[]),v=M.useCallback(function(w){u(w.type,v8(w),w.target,i(w,t.lockRef.current))},[]);M.useEffect(function(){return WC.push(o),t.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:v}),document.addEventListener("wheel",d,HC),document.addEventListener("touchmove",d,HC),document.addEventListener("touchstart",f,HC),function(){WC=WC.filter(function(w){return w!==o}),document.removeEventListener("wheel",d,HC),document.removeEventListener("touchmove",d,HC),document.removeEventListener("touchstart",f,HC)}},[]);var _=t.removeScrollBar,b=t.inert;return M.createElement(M.Fragment,null,b?M.createElement(o,{styles:dgt(a)}):null,_?M.createElement(tgt,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function mgt(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const pgt=qft(Fze,hgt);var sL=M.forwardRef(function(t,s){return M.createElement(toe,Qp({},t,{ref:s,sideCar:pgt}))});sL.classNames=toe.classNames;var uge=["Enter"," "],fgt=["ArrowDown","PageUp","Home"],Uze=["ArrowUp","PageDown","End"],ggt=[...fgt,...Uze],xgt={ltr:[...uge,"ArrowRight"],rtl:[...uge,"ArrowLeft"]},ygt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},rL="Menu",[AI,vgt,_gt]=W6(rL),[GN,Vze]=Cc(rL,[_gt,iy,P_]),soe=iy(),Hze=P_(),[bgt,KN]=GN(rL),[wgt,nL]=GN(rL),Wze=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=soe(s),[d,u]=M.useState(null),f=M.useRef(!1),g=Bc(o),v=E_(a);return M.useEffect(()=>{const _=()=>{f.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>f.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),e.jsx(Y6,{...i,children:e.jsx(bgt,{scope:s,open:r,onOpenChange:g,content:d,onContentChange:u,children:e.jsx(wgt,{scope:s,onClose:M.useCallback(()=>g(!1),[g]),isUsingKeyboardRef:f,dir:v,modal:l,children:n})})})};Wze.displayName=rL;var jgt="MenuAnchor",_1e=M.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=soe(r);return e.jsx(J3,{...a,...n,ref:s})});_1e.displayName=jgt;var b1e="MenuPortal",[kgt,Gze]=GN(b1e,{forceMount:void 0}),Kze=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=KN(b1e,s);return e.jsx(kgt,{scope:s,forceMount:r,children:e.jsx(od,{present:r||o.open,children:e.jsx(Z3,{asChild:!0,container:a,children:n})})})};Kze.displayName=b1e;var cf="MenuContent",[Ngt,w1e]=GN(cf),Zze=M.forwardRef((t,s)=>{const r=Gze(cf,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=KN(cf,t.__scopeMenu),l=nL(cf,t.__scopeMenu);return e.jsx(AI.Provider,{scope:t.__scopeMenu,children:e.jsx(od,{present:n||o.open,children:e.jsx(AI.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(Sgt,{...a,ref:s}):e.jsx(Cgt,{...a,ref:s})})})})}),Sgt=M.forwardRef((t,s)=>{const r=KN(cf,t.__scopeMenu),n=M.useRef(null),a=Sa(s,n);return M.useEffect(()=>{const o=n.current;if(o)return eoe(o)},[]),e.jsx(j1e,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Sr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Cgt=M.forwardRef((t,s)=>{const r=KN(cf,t.__scopeMenu);return e.jsx(j1e,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Mgt=m_("MenuContent.ScrollLock"),j1e=M.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:g,onInteractOutside:v,onDismiss:_,disableOutsideScroll:b,...w}=t,j=KN(cf,r),N=nL(cf,r),S=soe(r),A=Hze(r),I=vgt(r),[L,F]=M.useState(null),$=M.useRef(null),q=Sa(s,$,j.onContentChange),H=M.useRef(0),U=M.useRef(""),Q=M.useRef(0),se=M.useRef(null),te=M.useRef("right"),Y=M.useRef(0),ce=b?sL:M.Fragment,oe=b?{as:Mgt,allowPinchZoom:!0}:void 0,le=xe=>{var Pe,Fe;const be=U.current+xe,ye=I().filter(Ie=>!Ie.disabled),ve=document.activeElement,ke=(Pe=ye.find(Ie=>Ie.ref.current===ve))==null?void 0:Pe.textValue,Ge=ye.map(Ie=>Ie.textValue),Ne=Bgt(Ge,be,ke),Ae=(Fe=ye.find(Ie=>Ie.textValue===Ne))==null?void 0:Fe.ref.current;(function Ie(Ve){U.current=Ve,window.clearTimeout(H.current),Ve!==""&&(H.current=window.setTimeout(()=>Ie(""),1e3))})(be),Ae&&setTimeout(()=>Ae.focus())};M.useEffect(()=>()=>window.clearTimeout(H.current),[]),Xie();const de=M.useCallback(xe=>{var ye,ve;return te.current===((ye=se.current)==null?void 0:ye.side)&&qgt(xe,(ve=se.current)==null?void 0:ve.area)},[]);return e.jsx(Ngt,{scope:r,searchRef:U,onItemEnter:M.useCallback(xe=>{de(xe)&&xe.preventDefault()},[de]),onItemLeave:M.useCallback(xe=>{var be;de(xe)||((be=$.current)==null||be.focus(),F(null))},[de]),onTriggerLeave:M.useCallback(xe=>{de(xe)&&xe.preventDefault()},[de]),pointerGraceTimerRef:Q,onPointerGraceIntentChange:M.useCallback(xe=>{se.current=xe},[]),children:e.jsx(ce,{...oe,children:e.jsx(eL,{asChild:!0,trapped:a,onMountAutoFocus:Sr(o,xe=>{var be;xe.preventDefault(),(be=$.current)==null||be.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(C_,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:g,onInteractOutside:v,onDismiss:_,children:e.jsx(Qie,{asChild:!0,...A,dir:N.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:F,onEntryFocus:Sr(d,xe=>{N.isUsingKeyboardRef.current||xe.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(X6,{role:"menu","aria-orientation":"vertical","data-state":u7e(j.open),"data-radix-menu-content":"",dir:N.dir,...S,...w,ref:q,style:{outline:"none",...w.style},onKeyDown:Sr(w.onKeyDown,xe=>{const ye=xe.target.closest("[data-radix-menu-content]")===xe.currentTarget,ve=xe.ctrlKey||xe.altKey||xe.metaKey,ke=xe.key.length===1;ye&&(xe.key==="Tab"&&xe.preventDefault(),!ve&&ke&&le(xe.key));const Ge=$.current;if(xe.target!==Ge||!ggt.includes(xe.key))return;xe.preventDefault();const Ae=I().filter(Pe=>!Pe.disabled).map(Pe=>Pe.ref.current);Uze.includes(xe.key)&&Ae.reverse(),Fgt(Ae)}),onBlur:Sr(t.onBlur,xe=>{xe.currentTarget.contains(xe.target)||(window.clearTimeout(H.current),U.current="")}),onPointerMove:Sr(t.onPointerMove,EI(xe=>{const be=xe.target,ye=Y.current!==xe.clientX;if(xe.currentTarget.contains(be)&&ye){const ve=xe.clientX>Y.current?"right":"left";te.current=ve,Y.current=xe.clientX}}))})})})})})})});Zze.displayName=cf;var Tgt="MenuGroup",k1e=M.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"group",...n,ref:s})});k1e.displayName=Tgt;var Agt="MenuLabel",Yze=M.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});Yze.displayName=Agt;var Zre="MenuItem",o5e="menu.itemSelect",roe=M.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=M.useRef(null),l=nL(Zre,t.__scopeMenu),i=w1e(Zre,t.__scopeMenu),d=Sa(s,o),u=M.useRef(!1),f=()=>{const g=o.current;if(!r&&g){const v=new CustomEvent(o5e,{bubbles:!0,cancelable:!0});g.addEventListener(o5e,_=>n==null?void 0:n(_),{once:!0}),Ove(g,v),v.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(Xze,{...a,ref:d,disabled:r,onClick:Sr(t.onClick,f),onPointerDown:g=>{var v;(v=t.onPointerDown)==null||v.call(t,g),u.current=!0},onPointerUp:Sr(t.onPointerUp,g=>{var v;u.current||(v=g.currentTarget)==null||v.click()}),onKeyDown:Sr(t.onKeyDown,g=>{const v=i.searchRef.current!=="";r||v&&g.key===" "||uge.includes(g.key)&&(g.currentTarget.click(),g.preventDefault())})})});roe.displayName=Zre;var Xze=M.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=w1e(Zre,r),i=Hze(r),d=M.useRef(null),u=Sa(s,d),[f,g]=M.useState(!1),[v,_]=M.useState("");return M.useEffect(()=>{const b=d.current;b&&_((b.textContent??"").trim())},[o.children]),e.jsx(AI.ItemSlot,{scope:r,disabled:n,textValue:a??v,children:e.jsx(Jie,{asChild:!0,...i,focusable:!n,children:e.jsx(Qr.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Sr(t.onPointerMove,EI(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Sr(t.onPointerLeave,EI(b=>l.onItemLeave(b))),onFocus:Sr(t.onFocus,()=>g(!0)),onBlur:Sr(t.onBlur,()=>g(!1))})})})}),Egt="MenuCheckboxItem",Qze=M.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(r7e,{scope:t.__scopeMenu,checked:r,children:e.jsx(roe,{role:"menuitemcheckbox","aria-checked":Yre(r)?"mixed":r,...a,ref:s,"data-state":S1e(r),onSelect:Sr(a.onSelect,()=>n==null?void 0:n(Yre(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Qze.displayName=Egt;var Jze="MenuRadioGroup",[Pgt,Igt]=GN(Jze,{value:void 0,onValueChange:()=>{}}),e7e=M.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=Bc(n);return e.jsx(Pgt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(k1e,{...a,ref:s})})});e7e.displayName=Jze;var t7e="MenuRadioItem",s7e=M.forwardRef((t,s)=>{const{value:r,...n}=t,a=Igt(t7e,t.__scopeMenu),o=r===a.value;return e.jsx(r7e,{scope:t.__scopeMenu,checked:o,children:e.jsx(roe,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":S1e(o),onSelect:Sr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});s7e.displayName=t7e;var N1e="MenuItemIndicator",[r7e,Lgt]=GN(N1e,{checked:!1}),n7e=M.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=Lgt(N1e,r);return e.jsx(od,{present:n||Yre(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{...a,ref:s,"data-state":S1e(o.checked)})})});n7e.displayName=N1e;var Dgt="MenuSeparator",a7e=M.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});a7e.displayName=Dgt;var Ogt="MenuArrow",i7e=M.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=soe(r);return e.jsx(Q6,{...a,...n,ref:s})});i7e.displayName=Ogt;var Rgt="MenuSub",[zvs,o7e]=GN(Rgt),fE="MenuSubTrigger",l7e=M.forwardRef((t,s)=>{const r=KN(fE,t.__scopeMenu),n=nL(fE,t.__scopeMenu),a=o7e(fE,t.__scopeMenu),o=w1e(fE,t.__scopeMenu),l=M.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,u={__scopeMenu:t.__scopeMenu},f=M.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return M.useEffect(()=>f,[f]),M.useEffect(()=>{const g=i.current;return()=>{window.clearTimeout(g),d(null)}},[i,d]),e.jsx(_1e,{asChild:!0,...u,children:e.jsx(Xze,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":u7e(r.open),...t,ref:O0(s,a.onTriggerChange),onClick:g=>{var v;(v=t.onClick)==null||v.call(t,g),!(t.disabled||g.defaultPrevented)&&(g.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Sr(t.onPointerMove,EI(g=>{o.onItemEnter(g),!g.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),f()},100))})),onPointerLeave:Sr(t.onPointerLeave,EI(g=>{var _,b;f();const v=(_=r.content)==null?void 0:_.getBoundingClientRect();if(v){const w=(b=r.content)==null?void 0:b.dataset.side,j=w==="right",N=j?-5:5,S=v[j?"left":"right"],A=v[j?"right":"left"];o.onPointerGraceIntentChange({area:[{x:g.clientX+N,y:g.clientY},{x:S,y:v.top},{x:A,y:v.top},{x:A,y:v.bottom},{x:S,y:v.bottom}],side:w}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(g),g.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Sr(t.onKeyDown,g=>{var _;const v=o.searchRef.current!=="";t.disabled||v&&g.key===" "||xgt[n.dir].includes(g.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),g.preventDefault())})})})});l7e.displayName=fE;var c7e="MenuSubContent",d7e=M.forwardRef((t,s)=>{const r=Gze(cf,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=KN(cf,t.__scopeMenu),l=nL(cf,t.__scopeMenu),i=o7e(c7e,t.__scopeMenu),d=M.useRef(null),u=Sa(s,d);return e.jsx(AI.Provider,{scope:t.__scopeMenu,children:e.jsx(od,{present:n||o.open,children:e.jsx(AI.Slot,{scope:t.__scopeMenu,children:e.jsx(j1e,{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:f=>{var g;l.isUsingKeyboardRef.current&&((g=d.current)==null||g.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Sr(t.onFocusOutside,f=>{f.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Sr(t.onEscapeKeyDown,f=>{l.onClose(),f.preventDefault()}),onKeyDown:Sr(t.onKeyDown,f=>{var _;const g=f.currentTarget.contains(f.target),v=ygt[l.dir].includes(f.key);g&&v&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),f.preventDefault())})})})})})});d7e.displayName=c7e;function u7e(t){return t?"open":"closed"}function Yre(t){return t==="indeterminate"}function S1e(t){return Yre(t)?"indeterminate":t?"checked":"unchecked"}function Fgt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function zgt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function Bgt(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=zgt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function $gt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=v>n&&r<(g-u)*(n-f)/(v-f)+u&&(a=!a)}return a}function qgt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return $gt(r,s)}function EI(t){return s=>s.pointerType==="mouse"?t(s):void 0}var Ugt=Wze,Vgt=_1e,Hgt=Kze,Wgt=Zze,Ggt=k1e,Kgt=Yze,Zgt=roe,Ygt=Qze,Xgt=e7e,Qgt=s7e,Jgt=n7e,ext=a7e,txt=i7e,sxt=l7e,rxt=d7e,noe="DropdownMenu",[nxt]=Cc(noe,[Vze]),Kh=Vze(),[axt,h7e]=nxt(noe),m7e=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=Kh(s),u=M.useRef(null),[f,g]=uu({prop:a,defaultProp:o??!1,onChange:l,caller:noe});return e.jsx(axt,{scope:s,triggerId:Bd(),triggerRef:u,contentId:Bd(),open:f,onOpenChange:g,onOpenToggle:M.useCallback(()=>g(v=>!v),[g]),modal:i,children:e.jsx(Ugt,{...d,open:f,onOpenChange:g,dir:n,modal:i,children:r})})};m7e.displayName=noe;var p7e="DropdownMenuTrigger",f7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=h7e(p7e,r),l=Kh(r);return e.jsx(Vgt,{asChild:!0,...l,children:e.jsx(Qr.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:O0(s,o.triggerRef),onPointerDown:Sr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Sr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});f7e.displayName=p7e;var ixt="DropdownMenuPortal",g7e=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Kh(s);return e.jsx(Hgt,{...n,...r})};g7e.displayName=ixt;var x7e="DropdownMenuContent",y7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=h7e(x7e,r),o=Kh(r),l=M.useRef(!1);return e.jsx(Wgt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Sr(t.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Sr(t.onInteractOutside,i=>{const d=i.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,f=d.button===2||u;(!a.modal||f)&&(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)"}})});y7e.displayName=x7e;var oxt="DropdownMenuGroup",lxt=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(Ggt,{...a,...n,ref:s})});lxt.displayName=oxt;var cxt="DropdownMenuLabel",v7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(Kgt,{...a,...n,ref:s})});v7e.displayName=cxt;var dxt="DropdownMenuItem",_7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(Zgt,{...a,...n,ref:s})});_7e.displayName=dxt;var uxt="DropdownMenuCheckboxItem",b7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(Ygt,{...a,...n,ref:s})});b7e.displayName=uxt;var hxt="DropdownMenuRadioGroup",mxt=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(Xgt,{...a,...n,ref:s})});mxt.displayName=hxt;var pxt="DropdownMenuRadioItem",w7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(Qgt,{...a,...n,ref:s})});w7e.displayName=pxt;var fxt="DropdownMenuItemIndicator",j7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(Jgt,{...a,...n,ref:s})});j7e.displayName=fxt;var gxt="DropdownMenuSeparator",k7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(ext,{...a,...n,ref:s})});k7e.displayName=gxt;var xxt="DropdownMenuArrow",yxt=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(txt,{...a,...n,ref:s})});yxt.displayName=xxt;var vxt="DropdownMenuSubTrigger",N7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(sxt,{...a,...n,ref:s})});N7e.displayName=vxt;var _xt="DropdownMenuSubContent",S7e=M.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Kh(r);return e.jsx(rxt,{...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)"}})});S7e.displayName=_xt;var bxt=m7e,wxt=f7e,jxt=g7e,C7e=y7e,M7e=v7e,T7e=_7e,A7e=b7e,E7e=w7e,P7e=j7e,I7e=k7e,L7e=N7e,D7e=S7e;const Du=bxt,Ou=wxt,kxt=M.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(L7e,{ref:a,className:It("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",s&&"pl-8",t),...n,children:[r,e.jsx(ei,{className:"ml-auto h-4 w-4"})]}));kxt.displayName=L7e.displayName;const Nxt=M.forwardRef(({className:t,...s},r)=>e.jsx(D7e,{ref:r,className:It("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));Nxt.displayName=D7e.displayName;const mu=M.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(jxt,{children:e.jsx(C7e,{ref:n,sideOffset:s,className:It("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));mu.displayName=C7e.displayName;const Wa=M.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(T7e,{ref:n,className:It("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s&&"pl-8",t),...r}));Wa.displayName=T7e.displayName;const Sxt=M.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(A7e,{ref:a,className:It("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(P7e,{children:e.jsx(ma,{className:"h-4 w-4"})})}),s]}));Sxt.displayName=A7e.displayName;const Cxt=M.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(E7e,{ref:n,className:It("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(P7e,{children:e.jsx(qc,{className:"h-2 w-2 fill-current"})})}),s]}));Cxt.displayName=E7e.displayName;const hge=M.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(M7e,{ref:n,className:It("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));hge.displayName=M7e.displayName;const g_=M.forwardRef(({className:t,...s},r)=>e.jsx(I7e,{ref:r,className:It("-mx-1 my-1 h-px bg-muted",t),...s}));g_.displayName=I7e.displayName;const Mxt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=y1e();if(!t)return null;const l=i=>i.split(" ").map(d=>d[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(mo,{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(xr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsxs(Z,{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(mo,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(mn,{className:"h-5 w-5",children:[e.jsx(ba,{src:s.avatar_url||void 0}),e.jsx(pn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(tl,{className:"h-3 w-3"})]})}),e.jsxs(mu,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Wa,{onClick:o,className:"gap-2",children:[e.jsx(mo,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(nt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(g_,{}),r.map(i=>e.jsxs(Wa,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(mn,{className:"h-6 w-6",children:[e.jsx(ba,{src:i.avatar_url||void 0}),e.jsx(pn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(nt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(nt,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},gr=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,isAdmin:o,isBrokerageManager:l}=Qs();return a?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&&!o?e.jsx(the,{to:"/dashboard",replace:!0}):r&&!l&&!o?e.jsx(the,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(the,{to:"/auth",replace:!0})};var C1e={};(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 be=new OffscreenCanvas(1,1),ye=be.getContext("2d");ye.fillRect(0,0,1,1);var ve=be.transferToImageBitmap();ye.createPattern(ve,"no-repeat")}catch{return!1}return!0}();function d(){}function u(be){var ye=r.exports.Promise,ve=ye!==void 0?ye:s.Promise;return typeof ve=="function"?new ve(be):(be(d,d),null)}var f=function(be,ye){return{transform:function(ve){if(be)return ve;if(ye.has(ve))return ye.get(ve);var ke=new OffscreenCanvas(ve.width,ve.height),Ge=ke.getContext("2d");return Ge.drawImage(ve,0,0),ye.set(ve,ke),ke},clear:function(){ye.clear()}}}(i,new Map),g=function(){var be=Math.floor(16.666666666666668),ye,ve,ke={},Ge=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ye=function(Ne){var Ae=Math.random();return ke[Ae]=requestAnimationFrame(function Pe(Fe){Ge===Fe||Ge+be-1{const{data:s,error:r}=await K.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 Axt(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function Ext(){const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{error:n}=await K.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 aoe="Dialog",[O7e,R7e]=Cc(aoe),[Pxt,qg]=O7e(aoe),F7e=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=M.useRef(null),d=M.useRef(null),[u,f]=uu({prop:n,defaultProp:a??!1,onChange:o,caller:aoe});return e.jsx(Pxt,{scope:s,triggerRef:i,contentRef:d,contentId:Bd(),titleId:Bd(),descriptionId:Bd(),open:u,onOpenChange:f,onOpenToggle:M.useCallback(()=>f(g=>!g),[f]),modal:l,children:r})};F7e.displayName=aoe;var z7e="DialogTrigger",B7e=M.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=qg(z7e,r),o=Sa(s,a.triggerRef);return e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":A1e(a.open),...n,ref:o,onClick:Sr(t.onClick,a.onOpenToggle)})});B7e.displayName=z7e;var M1e="DialogPortal",[Ixt,$7e]=O7e(M1e,{forceMount:void 0}),q7e=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=qg(M1e,s);return e.jsx(Ixt,{scope:s,forceMount:r,children:M.Children.map(n,l=>e.jsx(od,{present:r||o.open,children:e.jsx(Z3,{asChild:!0,container:a,children:l})}))})};q7e.displayName=M1e;var Xre="DialogOverlay",U7e=M.forwardRef((t,s)=>{const r=$7e(Xre,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=qg(Xre,t.__scopeDialog);return o.modal?e.jsx(od,{present:n||o.open,children:e.jsx(Dxt,{...a,ref:s})}):null});U7e.displayName=Xre;var Lxt=m_("DialogOverlay.RemoveScroll"),Dxt=M.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=qg(Xre,r);return e.jsx(sL,{as:Lxt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Qr.div,{"data-state":A1e(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),wN="DialogContent",V7e=M.forwardRef((t,s)=>{const r=$7e(wN,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=qg(wN,t.__scopeDialog);return e.jsx(od,{present:n||o.open,children:o.modal?e.jsx(Oxt,{...a,ref:s}):e.jsx(Rxt,{...a,ref:s})})});V7e.displayName=wN;var Oxt=M.forwardRef((t,s)=>{const r=qg(wN,t.__scopeDialog),n=M.useRef(null),a=Sa(s,r.contentRef,n);return M.useEffect(()=>{const o=n.current;if(o)return eoe(o)},[]),e.jsx(H7e,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Sr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Sr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Sr(t.onFocusOutside,o=>o.preventDefault())})}),Rxt=M.forwardRef((t,s)=>{const r=qg(wN,t.__scopeDialog),n=M.useRef(!1),a=M.useRef(!1);return e.jsx(H7e,{...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 d,u;(d=t.onInteractOutside)==null||d.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()}})}),H7e=M.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=qg(wN,r),d=M.useRef(null),u=Sa(s,d);return Xie(),e.jsxs(e.Fragment,{children:[e.jsx(eL,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(C_,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":A1e(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(zxt,{titleId:i.titleId}),e.jsx($xt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),T1e="DialogTitle",W7e=M.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=qg(T1e,r);return e.jsx(Qr.h2,{id:a.titleId,...n,ref:s})});W7e.displayName=T1e;var G7e="DialogDescription",K7e=M.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=qg(G7e,r);return e.jsx(Qr.p,{id:a.descriptionId,...n,ref:s})});K7e.displayName=G7e;var Z7e="DialogClose",Y7e=M.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=qg(Z7e,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Sr(t.onClick,()=>a.onOpenChange(!1))})});Y7e.displayName=Z7e;function A1e(t){return t?"open":"closed"}var X7e="DialogTitleWarning",[Fxt,Q7e]=_it(X7e,{contentName:wN,titleName:T1e,docsSlug:"dialog"}),zxt=({titleId:t})=>{const s=Q7e(X7e),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 M.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},Bxt="DialogDescriptionWarning",$xt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Q7e(Bxt).contentName}}.`;return M.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},ioe=F7e,E1e=B7e,ooe=q7e,aM=U7e,iM=V7e,aL=W7e,iL=K7e,oL=Y7e;const bs=ioe,Si=E1e,qxt=ooe,Bvs=oL,J7e=M.forwardRef(({className:t,...s},r)=>e.jsx(aM,{ref:r,className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));J7e.displayName=aM.displayName;const _s=M.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(qxt,{children:[e.jsx(J7e,{}),e.jsxs(iM,{ref:n,className:It("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...r,children:[s,e.jsxs(oL,{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(Vr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_s.displayName=iM.displayName;const Cs=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});Cs.displayName="DialogHeader";const qn=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});qn.displayName="DialogFooter";const Ss=M.forwardRef(({className:t,...s},r)=>e.jsx(aL,{ref:r,className:It("text-lg font-semibold leading-none tracking-tight",t),...s}));Ss.displayName=aL.displayName;const Kr=M.forwardRef(({className:t,...s},r)=>e.jsx(iL,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));Kr.displayName=iL.displayName;const Uxt={points_earned:so,listing_created:Hn,deal_closed:Uc,custom:Gn},c5e={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"},d5e=()=>{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.")};function Vxt(){const{user:t}=Qs(),s=ds(),{data:r}=Txt(),n=Axt(),[a,o]=M.useState(null),[l,i]=M.useState(!1),d=M.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},w=(N,S)=>Math.random()*(S-N)+N,j=setInterval(()=>{const N=_-Date.now();if(N<=0){clearInterval(j);return}const S=50*(N/3e3);l5e({...b,particleCount:S,origin:{x:w(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),l5e({...b,particleCount:S,origin:{x:w(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);M.useEffect(()=>{d5e()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(d,100))},[r,a,d]);const u=async()=>{if(a){const v=a.id;i(!1),o(null),s.setQueryData(["celebrations","pending",t==null?void 0:t.id],_=>(_==null?void 0:_.filter(b=>b.id!==v))??[]),await n.mutateAsync(v)}};if(d5e()||!a)return null;const f=Uxt[a.celebration_type]||Gn,g=c5e[a.celebration_type]||c5e.custom;return e.jsx(bs,{open:l,onOpenChange:v=>!v&&u(),children:e.jsxs(_s,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${g} 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 ${g} flex items-center justify-center animate-bounce`,children:e.jsx(f,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(gn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(gn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(gn,{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(Z,{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 eBe="/assets/levelup-logo-horizontal-DEFNc0ms.png",P1e="/assets/levelup-logo-white-C2RAgAoG.png",Hxt="/assets/listings-hero-BI9Ki9Dq.jpg",Re=M.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:It("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));Re.displayName="Input";var tBe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(a0,function(){var r,n,a;function o(i,d){if(!r)r=d;else if(!n)n=d;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;",f={};r(f),a=d(f),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 d=1e-6,u=typeof Float32Array<"u"?Float32Array:Array;function f(p,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=m*E-k*y;return P?(p[0]=E*(P=1/P),p[1]=-y*P,p[2]=-k*P,p[3]=m*P,p):null}function g(){var p=new u(9);return u!=Float32Array&&(p[1]=0,p[2]=0,p[3]=0,p[5]=0,p[6]=0,p[7]=0),p[0]=1,p[4]=1,p[8]=1,p}function v(p,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=c[4],O=c[5],B=c[6],W=c[7],J=c[8];return p[0]=P*J-O*W,p[1]=k*W-y*J,p[2]=y*O-k*P,p[3]=O*B-E*J,p[4]=m*J-k*B,p[5]=k*E-m*O,p[6]=E*W-P*B,p[7]=y*B-m*W,p[8]=m*P-y*E,p}function _(p,c,m){var y=c[0],k=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ne=m[0],ie=m[1],ue=m[2],we=m[3],Ee=m[4],Te=m[5],Ue=m[6],Ye=m[7],st=m[8];return p[0]=ne*y+ie*P+ue*W,p[1]=ne*k+ie*O+ue*J,p[2]=ne*E+ie*B+ue*ee,p[3]=we*y+Ee*P+Te*W,p[4]=we*k+Ee*O+Te*J,p[5]=we*E+Ee*B+Te*ee,p[6]=Ue*y+Ye*P+st*W,p[7]=Ue*k+Ye*O+st*J,p[8]=Ue*E+Ye*B+st*ee,p}function b(){var p=new u(16);return u!=Float32Array&&(p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[11]=0,p[12]=0,p[13]=0,p[14]=0),p[0]=1,p[5]=1,p[10]=1,p[15]=1,p}function w(p){var c=new u(16);return c[0]=p[0],c[1]=p[1],c[2]=p[2],c[3]=p[3],c[4]=p[4],c[5]=p[5],c[6]=p[6],c[7]=p[7],c[8]=p[8],c[9]=p[9],c[10]=p[10],c[11]=p[11],c[12]=p[12],c[13]=p[13],c[14]=p[14],c[15]=p[15],c}function j(p){return p[0]=1,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=1,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=1,p[11]=0,p[12]=0,p[13]=0,p[14]=0,p[15]=1,p}function N(p,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=c[4],O=c[5],B=c[6],W=c[7],J=c[8],ee=c[9],ne=c[10],ie=c[11],ue=c[12],we=c[13],Ee=c[14],Te=c[15],Ue=m*O-y*P,Ye=m*B-k*P,st=m*W-E*P,_t=y*B-k*O,ft=y*W-E*O,St=k*W-E*B,Pt=J*we-ee*ue,Ft=J*Ee-ne*ue,ns=J*Te-ie*ue,Wt=ee*Ee-ne*we,hs=ee*Te-ie*we,ys=ne*Te-ie*Ee,vs=Ue*ys-Ye*hs+st*Wt+_t*ns-ft*Ft+St*Pt;return vs?(p[0]=(O*ys-B*hs+W*Wt)*(vs=1/vs),p[1]=(k*hs-y*ys-E*Wt)*vs,p[2]=(we*St-Ee*ft+Te*_t)*vs,p[3]=(ne*ft-ee*St-ie*_t)*vs,p[4]=(B*ns-P*ys-W*Ft)*vs,p[5]=(m*ys-k*ns+E*Ft)*vs,p[6]=(Ee*st-ue*St-Te*Ye)*vs,p[7]=(J*St-ne*st+ie*Ye)*vs,p[8]=(P*hs-O*ns+W*Pt)*vs,p[9]=(y*ns-m*hs-E*Pt)*vs,p[10]=(ue*ft-we*st+Te*Ue)*vs,p[11]=(ee*st-J*ft-ie*Ue)*vs,p[12]=(O*Ft-P*Wt-B*Pt)*vs,p[13]=(m*Wt-y*Ft+k*Pt)*vs,p[14]=(we*Ye-ue*_t-Ee*Ue)*vs,p[15]=(J*_t-ee*Ye+ne*Ue)*vs,p):null}function S(p,c,m){var y=c[0],k=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ne=c[9],ie=c[10],ue=c[11],we=c[12],Ee=c[13],Te=c[14],Ue=c[15],Ye=m[0],st=m[1],_t=m[2],ft=m[3];return p[0]=Ye*y+st*O+_t*ee+ft*we,p[1]=Ye*k+st*B+_t*ne+ft*Ee,p[2]=Ye*E+st*W+_t*ie+ft*Te,p[3]=Ye*P+st*J+_t*ue+ft*Ue,p[4]=(Ye=m[4])*y+(st=m[5])*O+(_t=m[6])*ee+(ft=m[7])*we,p[5]=Ye*k+st*B+_t*ne+ft*Ee,p[6]=Ye*E+st*W+_t*ie+ft*Te,p[7]=Ye*P+st*J+_t*ue+ft*Ue,p[8]=(Ye=m[8])*y+(st=m[9])*O+(_t=m[10])*ee+(ft=m[11])*we,p[9]=Ye*k+st*B+_t*ne+ft*Ee,p[10]=Ye*E+st*W+_t*ie+ft*Te,p[11]=Ye*P+st*J+_t*ue+ft*Ue,p[12]=(Ye=m[12])*y+(st=m[13])*O+(_t=m[14])*ee+(ft=m[15])*we,p[13]=Ye*k+st*B+_t*ne+ft*Ee,p[14]=Ye*E+st*W+_t*ie+ft*Te,p[15]=Ye*P+st*J+_t*ue+ft*Ue,p}function A(p,c,m){var y,k,E,P,O,B,W,J,ee,ne,ie,ue,we=m[0],Ee=m[1],Te=m[2];return c===p?(p[12]=c[0]*we+c[4]*Ee+c[8]*Te+c[12],p[13]=c[1]*we+c[5]*Ee+c[9]*Te+c[13],p[14]=c[2]*we+c[6]*Ee+c[10]*Te+c[14],p[15]=c[3]*we+c[7]*Ee+c[11]*Te+c[15]):(k=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ne=c[9],ie=c[10],ue=c[11],p[0]=y=c[0],p[1]=k,p[2]=E,p[3]=P,p[4]=O,p[5]=B,p[6]=W,p[7]=J,p[8]=ee,p[9]=ne,p[10]=ie,p[11]=ue,p[12]=y*we+O*Ee+ee*Te+c[12],p[13]=k*we+B*Ee+ne*Te+c[13],p[14]=E*we+W*Ee+ie*Te+c[14],p[15]=P*we+J*Ee+ue*Te+c[15]),p}function I(p,c,m){var y=m[0],k=m[1],E=m[2];return p[0]=c[0]*y,p[1]=c[1]*y,p[2]=c[2]*y,p[3]=c[3]*y,p[4]=c[4]*k,p[5]=c[5]*k,p[6]=c[6]*k,p[7]=c[7]*k,p[8]=c[8]*E,p[9]=c[9]*E,p[10]=c[10]*E,p[11]=c[11]*E,p[12]=c[12],p[13]=c[13],p[14]=c[14],p[15]=c[15],p}function L(p,c,m){var y=Math.sin(m),k=Math.cos(m),E=c[4],P=c[5],O=c[6],B=c[7],W=c[8],J=c[9],ee=c[10],ne=c[11];return c!==p&&(p[0]=c[0],p[1]=c[1],p[2]=c[2],p[3]=c[3],p[12]=c[12],p[13]=c[13],p[14]=c[14],p[15]=c[15]),p[4]=E*k+W*y,p[5]=P*k+J*y,p[6]=O*k+ee*y,p[7]=B*k+ne*y,p[8]=W*k-E*y,p[9]=J*k-P*y,p[10]=ee*k-O*y,p[11]=ne*k-B*y,p}function F(p,c,m){var y=Math.sin(m),k=Math.cos(m),E=c[0],P=c[1],O=c[2],B=c[3],W=c[8],J=c[9],ee=c[10],ne=c[11];return c!==p&&(p[4]=c[4],p[5]=c[5],p[6]=c[6],p[7]=c[7],p[12]=c[12],p[13]=c[13],p[14]=c[14],p[15]=c[15]),p[0]=E*k-W*y,p[1]=P*k-J*y,p[2]=O*k-ee*y,p[3]=B*k-ne*y,p[8]=E*y+W*k,p[9]=P*y+J*k,p[10]=O*y+ee*k,p[11]=B*y+ne*k,p}function $(p,c,m){var y=Math.sin(m),k=Math.cos(m),E=c[0],P=c[1],O=c[2],B=c[3],W=c[4],J=c[5],ee=c[6],ne=c[7];return c!==p&&(p[8]=c[8],p[9]=c[9],p[10]=c[10],p[11]=c[11],p[12]=c[12],p[13]=c[13],p[14]=c[14],p[15]=c[15]),p[0]=E*k+W*y,p[1]=P*k+J*y,p[2]=O*k+ee*y,p[3]=B*k+ne*y,p[4]=W*k-E*y,p[5]=J*k-P*y,p[6]=ee*k-O*y,p[7]=ne*k-B*y,p}function q(p,c){return p[0]=c[0],p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=c[1],p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=c[2],p[11]=0,p[12]=0,p[13]=0,p[14]=0,p[15]=1,p}function H(p,c,m){var y,k,E,P=m[0],O=m[1],B=m[2],W=Math.sqrt(P*P+O*O+B*B);return W0&&(E=1/Math.sqrt(E)),p[0]=c[0]*E,p[1]=c[1]*E,p[2]=c[2]*E,p}function Ve(p,c){return p[0]*c[0]+p[1]*c[1]+p[2]*c[2]}function dt(p,c,m){var y=c[0],k=c[1],E=c[2],P=m[0],O=m[1],B=m[2];return p[0]=k*B-E*O,p[1]=E*P-y*B,p[2]=y*O-k*P,p}function Le(p,c,m,y){var k=c[0],E=c[1],P=c[2];return p[0]=k+y*(m[0]-k),p[1]=E+y*(m[1]-E),p[2]=P+y*(m[2]-P),p}function Rt(p,c,m){var y=c[0],k=c[1],E=c[2],P=m[3]*y+m[7]*k+m[11]*E+m[15];return p[0]=(m[0]*y+m[4]*k+m[8]*E+m[12])/(P=P||1),p[1]=(m[1]*y+m[5]*k+m[9]*E+m[13])/P,p[2]=(m[2]*y+m[6]*k+m[10]*E+m[14])/P,p}function fe(p,c,m){var y=c[0],k=c[1],E=c[2];return p[0]=y*m[0]+k*m[3]+E*m[6],p[1]=y*m[1]+k*m[4]+E*m[7],p[2]=y*m[2]+k*m[5]+E*m[8],p}function Qe(p,c,m){var y=m[0],k=m[1],E=m[2],P=m[3],O=c[0],B=c[1],W=c[2],J=k*W-E*B,ee=E*O-y*W,ne=y*B-k*O;return p[0]=O+P*(J+=J)+k*(ne+=ne)-E*(ee+=ee),p[1]=B+P*ee+E*J-y*ne,p[2]=W+P*ne+y*ee-k*J,p}function at(p){return p[0]=0,p[1]=0,p[2]=0,p}function rt(p,c){return p[0]===c[0]&&p[1]===c[1]&&p[2]===c[2]}var je=xe,mt=be,He=ce;function ct(){var p=new u(4);return u!=Float32Array&&(p[0]=0,p[1]=0,p[2]=0,p[3]=0),p}function We(p,c,m){return p[0]=c[0]*m,p[1]=c[1]*m,p[2]=c[2]*m,p[3]=c[3]*m,p}function Ze(p,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=m*m+y*y+k*k+E*E;return P>0&&(P=1/Math.sqrt(P)),p[0]=m*P,p[1]=y*P,p[2]=k*P,p[3]=E*P,p}function ht(p,c,m){var y=c[0],k=c[1],E=c[2],P=c[3];return p[0]=m[0]*y+m[4]*k+m[8]*E+m[12]*P,p[1]=m[1]*y+m[5]*k+m[9]*E+m[13]*P,p[2]=m[2]*y+m[6]*k+m[10]*E+m[14]*P,p[3]=m[3]*y+m[7]*k+m[11]*E+m[15]*P,p}function Ke(){var p=new u(4);return u!=Float32Array&&(p[0]=0,p[1]=0,p[2]=0),p[3]=1,p}function qe(p){return p[0]=0,p[1]=0,p[2]=0,p[3]=1,p}function Je(p,c,m){m*=.5;var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return p[0]=y*B+P*O,p[1]=k*B+E*O,p[2]=E*B-k*O,p[3]=P*B-y*O,p}function Lt(p,c,m){m*=.5;var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return p[0]=y*B-E*O,p[1]=k*B+P*O,p[2]=E*B+y*O,p[3]=P*B-k*O,p}te(),ct();var zt,is,Kt,Qt=Ze,fs=(zt=te(),is=oe(1,0,0),Kt=oe(0,1,0),function(p,c,m){var y=Ve(c,m);return y<-.999999?(dt(zt,is,c),He(zt)<1e-6&&dt(zt,Kt,c),Ie(zt,zt),function(k,E,P){P*=.5;var O=Math.sin(P);k[0]=O*E[0],k[1]=O*E[1],k[2]=O*E[2],k[3]=Math.cos(P)}(p,zt,Math.PI),p):y>.999999?(p[0]=0,p[1]=0,p[2]=0,p[3]=1,p):(dt(zt,c,m),p[0]=zt[0],p[1]=zt[1],p[2]=zt[2],p[3]=1+y,Qt(p,p))});function dr(){var p=new u(2);return u!=Float32Array&&(p[0]=0,p[1]=0),p}function bt(p,c){var m=new u(2);return m[0]=p,m[1]=c,m}function ws(p,c,m){return p[0]=c,p[1]=m,p}function ir(p,c,m){return p[0]=c[0]+m[0],p[1]=c[1]+m[1],p}function Rr(p,c,m){return p[0]=c[0]-m[0],p[1]=c[1]-m[1],p}function oa(p,c,m){return p[0]=c[0]*m,p[1]=c[1]*m,p}function ri(p){var c=p[0],m=p[1];return Math.sqrt(c*c+m*m)}function no(p,c){var m=c[0],y=c[1],k=m*m+y*y;return k>0&&(k=1/Math.sqrt(k)),p[0]=c[0]*k,p[1]=c[1]*k,p}function Da(p,c){return p[0]*c[0]+p[1]*c[1]}Ke(),Ke(),g();var yn,ea,Zt=Rr;function yr(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}dr();var Gr=function(){if(ea)return yn;function p(c,m,y,k){this.cx=3*c,this.bx=3*(y-c)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*m,this.by=3*(k-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=c,this.p1y=m,this.p2x=y,this.p2y=k}return ea=1,yn=p,p.prototype={sampleCurveX:function(c){return((this.ax*c+this.bx)*c+this.cx)*c},sampleCurveY:function(c){return((this.ay*c+this.by)*c+this.cy)*c},sampleCurveDerivativeX:function(c){return(3*this.ax*c+2*this.bx)*c+this.cx},solveCurveX:function(c,m){if(m===void 0&&(m=1e-6),c<0)return 0;if(c>1)return 1;for(var y=c,k=0;k<8;k++){var E=this.sampleCurveX(y)-c;if(Math.abs(E)E?O=y:B=y,y=.5*(B-O)+O;return y},solve:function(c,m){return this.sampleCurveY(this.solveCurveX(c,m))}},yn}(),Dn=yr(Gr);function rs(p,c){this.x=p,this.y=c}function An(p,c){if(Array.isArray(p)){if(!Array.isArray(c)||p.length!==c.length)return!1;for(let m=0;m=1)return 1;const c=p*p,m=c*p;return 4*(p<.5?m:3*(p-c)+m-.75)}function Kc(p,c,m,y){const k=new Dn(p,c,m,y);return function(E){return k.solve(E)}}const it=Kc(.25,.1,.25,1);function Se(p,c,m){return Math.min(m,Math.max(c,p))}function ze(p,c,m){return(m=Se((m-p)/(c-p),0,1))*m*(3-2*m)}function tt(p,c,m){const y=m-c,k=((p-c)%y+y)%y+c;return k===c?m:k}function Mt(p,c,m){if(!p.length)return m(null,[]);let y=p.length;const k=new Array(p.length);let E=null;p.forEach((P,O)=>{c(P,(B,W)=>{B&&(E=B),k[O]=W,--y==0&&m(E,k)})})}let Nt=1;function Ot(){return Nt++}function Yt(p){return p<=1?1:Math.pow(2,Math.ceil(Math.log2(p)))}function qt(p,c){p.forEach(m=>{c[m]&&(c[m]=c[m].bind(c))})}function Jt(p,c,m){const y={};for(const k in p)y[k]=c.call(this,p[k],k,p);return y}function Ps(p,c,m){const y={};for(const k in p)c.call(this,p[k],k,p)&&(y[k]=p[k]);return y}function xs(p){return Array.isArray(p)?p.map(xs):typeof p=="object"&&p?Jt(p,xs):p}function hr(p,c){for(let m=0;m=0)return!0;return!1}const Br={};function cr(p){Br[p]||(typeof console<"u"&&console.warn(p),Br[p]=!0)}function Nn(p,c,m){return(m.y-p.y)*(c.x-p.x)>(c.y-p.y)*(m.x-p.x)}function Sn(p){let c=0;for(let m,y,k=0,E=p.length,P=E-1;k@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,y,k,E)=>{const P=k||E;return c[y]=!P||P.toLowerCase(),""}),c["max-age"]){const m=parseInt(c["max-age"],10);isNaN(m)?delete c["max-age"]:c["max-age"]=m}return c}let zo=null;function Ua(p,c){return[p[4*c],p[4*c+1],p[4*c+2],p[4*c+3]]}function Vo(p,c,m,y){for(;c>1;p[k]>1;p[k]<=y?c=k+1:m=k}return c}function xa(p){return p>0?1/(1.001-p):1+p}function Zi(p){return p>0?1-1/(1.001-p):-p}function mi(p,c,m){return(p-c.min)*(m.max-m.min)/(c.max-c.min)+m.min}const ta={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(!ta.API_URL)return null;try{const p=new URL(ta.API_URL);return p.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":p.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 Yi(p){return ta.API_URL_REGEX.test(p)}function tc(p){return ta.API_SPRITE_REGEX.test(p)}let fc,jd,kp,gl,gu,Zc;function Zh(){return fc==null&&(fc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),fc}const xl={now:()=>gl!==void 0?gl:performance.now(),setNow(p){gl=p},restoreNow(){gl=void 0},frame(p){const c=requestAnimationFrame(p);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(p,c=0){const{width:m,height:y}=p;gu||(gu=document.createElement("canvas"));const k=gu.getContext("2d",{willReadFrequently:!0});if(!k)throw new Error("failed to create canvas 2d context");return(m>gu.width||y>gu.height)&&(gu.width=m,gu.height=y),k.clearRect(-c,-c,m+2*c,y+2*c),k.drawImage(p,0,0,m,y),k.getImageData(-c,-c,m+2*c,y+2*c)},resolveURL:p=>(jd||(jd=document.createElement("a")),jd.href=p,jd.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(kp==null&&(kp=window.matchMedia("(prefers-reduced-motion: reduce)")),kp.matches)},hasCanvasFingerprintNoise(){if(Zc!==void 0)return Zc;if(!Zh())return Zc=!1,!1;const p=new OffscreenCanvas(85,1),c=p.getContext("2d",{willReadFrequently:!0});let m=0;for(let k=0;k0?`?${E}`:""}`}const Q0="mapbox-tiles";let J0=500,ev=50;const Om=["language","worldview","jobid"];let ih,kd;function oh(){try{return caches}catch{}}function ld(){const p=oh();p&&ih==null&&(ih=p.open(Q0))}let Yc=1/0;const Nd={supported:!1,testSupport:function(p){!Yh&&Sp&&(Xh?hy(p):Np=p)}};let Np,Sp,Yh=!1,Xh=!1;const Xc=typeof self<"u"?self:{};function hy(p){const c=p.createTexture();p.bindTexture(p.TEXTURE_2D,c);try{if(p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,Sp),p.isContextLost())return;Nd.supported=!0}catch{}p.deleteTexture(c),Yh=!0}Xc.document&&(Sp=Xc.document.createElement("img"),Sp.onload=function(){Np&&hy(Np),Np=null,Xh=!0},Sp.onerror=function(){Yh=!0,Np=null},Sp.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Cf={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(Cf);class ul extends Error{constructor(c,m,y){m===401&&Yi(y)&&(c+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(c),this.status=m,this.url=y}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const tv=ca()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Mf=function(p,c){if(!(/^file:/.test(m=p.url)||/^file:/.test(tv())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(y,k){const E=new AbortController,P=new Request(y.url,{method:y.method||"GET",body:y.body,credentials:y.credentials,headers:y.headers,referrer:tv(),referrerPolicy:y.referrerPolicy,signal:E.signal});let O=!1,B=!1;const W=(J=P.url).indexOf("sku=")>0&&Yi(J);var J;y.type==="json"&&P.headers.set("Accept","application/json");const ee=(ie,ue,we)=>{if(B)return;if(ie&&ie.message!=="SecurityError"&&cr(ie.toString()),ue&&we)return ne(ue);const Ee=Date.now();fetch(P).then(Te=>{if(Te.ok){const Ue=W?Te.clone():null;return ne(Te,Ue,Ee)}return k(new ul(Te.statusText,Te.status,y.url))}).catch(Te=>{Te.name!=="AbortError"&&k(new Error(`${Te.message} ${y.url}`))})},ne=(ie,ue,we)=>{(y.type==="arrayBuffer"?ie.arrayBuffer():y.type==="json"?ie.json():ie.text()).then(Ee=>{B||(ue&&we&&function(Te,Ue,Ye){if(ld(),ih==null)return;const st=ao(Ue.headers.get("Cache-Control")||"");if(st["no-store"])return;const _t={status:Ue.status,statusText:Ue.statusText,headers:new Headers};Ue.headers.forEach((Pt,Ft)=>_t.headers.set(Ft,Pt)),st["max-age"]&&_t.headers.set("Expires",new Date(Ye+1e3*st["max-age"]).toUTCString());const ft=_t.headers.get("Expires");if(!ft||new Date(ft).getTime()-Ye<42e4)return;let St=Kg(Te.url,{persistentParams:Om});if(Ue.status===206){const Pt=Te.headers.get("Range");if(!Pt)return;_t.status=200,St=Sf(St,{range:Pt})}(function(Pt,Ft){if(kd===void 0)try{new Response(new ReadableStream),kd=!0}catch{kd=!1}kd?Ft(Pt.body):Pt.blob().then(Ft).catch(ns=>cr(ns.message))})(Ue,Pt=>{const Ft=new Response((ns=Ue.status)!==200&&ns!==404&&[101,103,204,205,304].includes(ns)?null:Pt,_t);var ns;ld(),ih!=null&&ih.then(Wt=>Wt.put(St,Ft)).catch(Wt=>cr(Wt.message))})}(P,ue,we),O=!0,k(null,Ee,ie.headers))}).catch(Ee=>{B||k(new Error(Ee.message))})};return W?function(ie,ue){if(ld(),ih==null)return ue(null);ih.then(we=>{let Ee=Kg(ie.url,{persistentParams:Om});const Te=ie.headers.get("Range");Te&&(Ee=Sf(Ee,{range:Te})),we.match(Ee).then(Ue=>{const Ye=function(st){if(!st)return!1;const _t=new Date(st.headers.get("Expires")||0),ft=ao(st.headers.get("Cache-Control")||"");return Number(_t)>Date.now()&&!ft["no-cache"]}(Ue);we.delete(Ee).catch(ue),Ye&&we.put(Ee,Ue.clone()).catch(ue),ue(null,Ue,Ye)}).catch(ue)}).catch(ue)}(P,ee):ee(null,null),{cancel:()=>{B=!0,O||E.abort()}}}(p,c);if(ca(self)&&self.worker.actor)return self.worker.actor.send("getResource",p,c,void 0,!0)}var m;return function(y,k){const E=new XMLHttpRequest;E.open(y.method||"GET",y.url,!0),y.type==="arrayBuffer"&&(E.responseType="arraybuffer");for(const P in y.headers)E.setRequestHeader(P,y.headers[P]);return y.type==="json"&&(E.responseType="text",E.setRequestHeader("Accept","application/json")),E.withCredentials=y.credentials==="include",E.onerror=()=>{k(new Error(E.statusText))},E.onload=()=>{if((E.status>=200&&E.status<300||E.status===0)&&E.response!==null){let P=E.response;if(y.type==="json")try{P=JSON.parse(E.response)}catch(B){return k(B)}const O=new Headers;E.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(B=>{const W=B.split(": "),J=W.shift(),ee=W.join(": ");O.append(J,ee)}),k(null,P,O)}else k(new ul(E.statusText,E.status,y.url))},E.send(y.body),{cancel:()=>E.abort()}}(p,c)},Ru=function(p,c){return Mf(Object.assign(p,{type:"arrayBuffer"}),c)};function G_(p){const c=document.createElement("a");return c.href=p,c.protocol===location.protocol&&c.host===location.host}const rS="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let my,ya;my=[],ya=0;const Zg=function(p,c){if(Nd.supported&&(p.headers||(p.headers={}),p.headers.accept="image/webp,*/*"),ya>=ta.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:p,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return my.push(E),E}ya++;let m=!1;const y=()=>{if(!m)for(m=!0,ya--;my.length&&ya{y(),E?c(E):P&&(self.createImageBitmap?function(B,W){const J=new Blob([new Uint8Array(B)],{type:"image/png"});createImageBitmap(J).then(ee=>{W(null,ee)}).catch(ee=>{W(new Error(`Could not load image because of ${ee.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(P,(B,W)=>c(B,W,O)):function(B,W){const J=new Image;J.onload=()=>{W(null,J),URL.revokeObjectURL(J.src),J.onload=null,requestAnimationFrame(()=>{J.src=rS})},J.onerror=()=>W(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const ee=new Blob([new Uint8Array(B)],{type:"image/png"});J.src=B.byteLength?URL.createObjectURL(ee):rS}(P,(B,W)=>c(B,W,O)))});return{cancel:()=>{k.cancel(),y()}}};var K_,nS,aS,lh={exports:{}},py={exports:{}},fy={exports:{}},Z_=function(){if(aS)return lh.exports;aS=1;var p=(K_||(K_=1,py.exports=function(m,y){var k,E,P,O,B,W,J,ee;for(E=m.length-(k=3&m.length),P=y,B=3432918353,W=461845907,ee=0;ee>>16)*B&65535)<<16)&4294967295)<<15|J>>>17))*W+(((J>>>16)*W&65535)<<16)&4294967295)<<13|P>>>19))+((5*(P>>>16)&65535)<<16)&4294967295))+((58964+(O>>>16)&65535)<<16);switch(J=0,k){case 3:J^=(255&m.charCodeAt(ee+2))<<16;case 2:J^=(255&m.charCodeAt(ee+1))<<8;case 1:P^=J=(65535&(J=(J=(65535&(J^=255&m.charCodeAt(ee)))*B+(((J>>>16)*B&65535)<<16)&4294967295)<<15|J>>>17))*W+(((J>>>16)*W&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}),py.exports),c=(nS||(nS=1,fy.exports=function(m,y){for(var k,E=m.length,P=y^E,O=0;E>=4;)k=1540483477*(65535&(k=255&m.charCodeAt(O)|(255&m.charCodeAt(++O))<<8|(255&m.charCodeAt(++O))<<16|(255&m.charCodeAt(++O))<<24))+((1540483477*(k>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(k=1540483477*(65535&(k^=k>>>24))+((1540483477*(k>>>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}),fy.exports);return lh.exports=p,lh.exports.murmur3=p,lh.exports.murmur2=c,lh.exports}(),sv=yr(Z_);class Qh{constructor(c,...m){Object.assign(this,m[0]||{}),this.type=c}}class Yg extends Qh{constructor(c,m={}){super("error",Object.assign({error:c},m))}}function Y_(p,c,m){m[p]&&m[p].indexOf(c)!==-1||(m[p]=m[p]||[],m[p].push(c))}function yt(p,c,m){if(m&&m[p]){const y=m[p].indexOf(c);y!==-1&&m[p].splice(y,1)}}class Ns{on(c,m){return this._listeners=this._listeners||{},Y_(c,m,this._listeners),this}off(c,m){return yt(c,m,this._listeners),yt(c,m,this._oneTimeListeners),this}once(c,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},Y_(c,m,this._oneTimeListeners),this):new Promise(y=>{this.once(c,y)})}fire(c,m){const y=typeof c=="string"?new Qh(c,m):c,k=y.type;if(this.listens(k)){y.target=this;const E=this._listeners&&this._listeners[k]?this._listeners[k].slice():[];for(const B of E)B.call(this,y);const P=this._oneTimeListeners&&this._oneTimeListeners[k]?this._oneTimeListeners[k].slice():[];for(const B of P)yt(k,B,this._oneTimeListeners),B.call(this,y);const O=this._eventedParent;if(O){const B=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(y,B),O.fire(y)}}else y instanceof Yg&&console.error(y.error);return this}listens(c){return!!(this._listeners&&this._listeners[c]&&this._listeners[c].length>0||this._oneTimeListeners&&this._oneTimeListeners[c]&&this._oneTimeListeners[c].length>0||this._eventedParent&&this._eventedParent.listens(c))}setEventedParent(c,m){return this._eventedParent=c,this._eventedParentData=m,this}}class Hs{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new Hs(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[m,y]=c.split("");return new Hs({name:m,iconsetId:y})}static isEqual(c,m){return c.name===m.name&&c.iconsetId===m.iconsetId}toString(){return Hs.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var an,on={},Jn=function(){if(an)return on;an=1;var p={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 c(E){return(E=Math.round(E))<0?0:E>255?255:E}function m(E){return c(E[E.length-1]==="%"?parseFloat(E)/100*255:parseInt(E))}function y(E){return(P=E[E.length-1]==="%"?parseFloat(E)/100:parseFloat(E))<0?0:P>1?1:P;var P}function k(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{on.parseCSSColor=function(E){var P,O=E.replace(/ /g,"").toLowerCase();if(O in p)return p[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 B=O.indexOf("("),W=O.indexOf(")");if(B!==-1&&W+1===O.length){var J=O.substr(0,B),ee=O.substr(B+1,W-(B+1)).split(","),ne=1;switch(J){case"rgba":if(ee.length!==4)return null;ne=y(ee.pop());case"rgb":return ee.length!==3?null:[m(ee[0]),m(ee[1]),m(ee[2]),ne];case"hsla":if(ee.length!==4)return null;ne=y(ee.pop());case"hsl":if(ee.length!==3)return null;var ie=(parseFloat(ee[0])%360+360)%360/360,ue=y(ee[1]),we=y(ee[2]),Ee=we<=.5?we*(ue+1):we+ue-we*ue,Te=2*we-Ee;return[c(255*k(Te,Ee,ie+1/3)),c(255*k(Te,Ee,ie)),c(255*k(Te,Ee,ie-1/3)),ne];default:return null}}return null}}catch{}return on}();class Fr{constructor(c,m,y,k=1){this.r=c,this.g=m,this.b=y,this.a=k}static parse(c){if(!c)return;if(c instanceof Fr)return c;if(typeof c!="string")return;const m=Jn.parseCSSColor(c);return m?new Fr(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[c,m,y,k]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*c)},${Math.round(255*m)},${Math.round(255*y)},${k})`}toNonPremultipliedRenderColor(c){const{r:m,g:y,b:k,a:E}=this;return new Tf(c,m,y,k,E)}toPremultipliedRenderColor(c){const{r:m,g:y,b:k,a:E}=this;return new Rm(c,m*E,y*E,k*E,E)}clone(){return new Fr(this.r,this.g,this.b,this.a)}}class Xi{constructor(c,m,y,k,E,P=!1){if(this.premultiplied=!1,this.premultiplied=P,c){const O=c.image.height,B=O*O;this.premultiplied?(m=E===0?0:m/E*(O-1),y=E===0?0:y/E*(O-1),k=E===0?0:k/E*(O-1)):(m*=O-1,y*=O-1,k*=O-1);const W=Math.floor(m),J=Math.floor(y),ee=Math.floor(k),ne=Math.ceil(m),ie=Math.ceil(y),ue=Math.ceil(k),we=m-W,Ee=y-J,Te=k-ee,Ue=c.image.data,Ye=4*(W+J*B+ee*O),st=4*(W+J*B+ue*O),_t=4*(W+ie*B+ee*O),ft=4*(W+ie*B+ue*O),St=4*(ne+J*B+ee*O),Pt=4*(ne+J*B+ue*O),Ft=4*(ne+ie*B+ee*O),ns=4*(ne+ie*B+ue*O);if(Ye<0||ns>=Ue.length)throw new Error("out of range");this.r=Ur(Ur(Ur(Ue[Ye],Ue[st],Te),Ur(Ue[_t],Ue[ft],Te),Ee),Ur(Ur(Ue[St],Ue[Pt],Te),Ur(Ue[Ft],Ue[ns],Te),Ee),we)/255*(this.premultiplied?E:1),this.g=Ur(Ur(Ur(Ue[Ye+1],Ue[st+1],Te),Ur(Ue[_t+1],Ue[ft+1],Te),Ee),Ur(Ur(Ue[St+1],Ue[Pt+1],Te),Ur(Ue[Ft+1],Ue[ns+1],Te),Ee),we)/255*(this.premultiplied?E:1),this.b=Ur(Ur(Ur(Ue[Ye+2],Ue[st+2],Te),Ur(Ue[_t+2],Ue[ft+2],Te),Ee),Ur(Ur(Ue[St+2],Ue[Pt+2],Te),Ur(Ue[Ft+2],Ue[ns+2],Te),Ee),we)/255*(this.premultiplied?E:1),this.a=E}else this.r=m,this.g=y,this.b=k,this.a=E}toArray(){const{r:c,g:m,b:y,a:k}=this;return[255*c,255*m,255*y,k]}toHslaArray(){let{r:c,g:m,b:y,a:k}=this;if(this.premultiplied){if(k===0)return[0,0,0,0];const ue=1/k;c*=ue,m*=ue,y*=ue}const E=Math.min(Math.max(c,0),1),P=Math.min(Math.max(m,0),1),O=Math.min(Math.max(y,0),1),B=Math.min(E,P,O),W=Math.max(E,P,O),J=W-B,ee=.5*(B+W);if(J===0)return[0,0,100*ee,k];const ne=ee>.5?J/(2-W-B):J/(W+B);let ie;switch(W){case E:ie=60*((P-O)/J+(PUr(y,c[k],m))}Fr.black=new Fr(0,0,0,1),Fr.white=new Fr(1,1,1,1),Fr.transparent=new Fr(0,0,0,0),Fr.red=new Fr(1,0,0,1),Fr.blue=new Fr(0,0,1,1);var xy=Object.freeze({__proto__:null,array:gy,color:function(p,c,m){return new Fr(Ur(p.r,c.r,m),Ur(p.g,c.g,m),Ur(p.b,c.b,m),Ur(p.a,c.a,m))},number:Ur});class Jh extends Error{constructor(c,m){super(m),this.message=m,this.key=c}}class rv{constructor(c,m=[]){this.parent=c,this.bindings={};for(const[y,k]of m)this.bindings[y]=k}concat(c){return new rv(this,c)}get(c){if(this.bindings[c])return this.bindings[c];if(this.parent)return this.parent.get(c);throw new Error(`${c} not found in scope.`)}has(c){return!!this.bindings[c]||!!this.parent&&this.parent.has(c)}}const Fm={kind:"null"},Dr={kind:"number"},va={kind:"string"},di={kind:"boolean"},xu={kind:"color"},Cp={kind:"object"},ti={kind:"value"},iS={kind:"collator"},X_={kind:"formatted"},Q_={kind:"resolvedImage"};function cd(p,c){return{kind:"array",itemType:p,N:c}}function rl(p){if(p.kind==="array"){const c=rl(p.itemType);return typeof p.N=="number"?`array<${c}, ${p.N}>`:p.itemType.kind==="value"?"array":`array<${c}>`}return p.kind}const wce=[Fm,Dr,va,di,xu,X_,Cp,cd(ti),Q_];function Xg(p,c){if(c.kind==="error")return null;if(p.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!Xg(p.itemType,c.itemType))&&(typeof p.N!="number"||p.N===c.N))return null}else{if(p.kind===c.kind)return null;if(p.kind==="value"){for(const m of wce)if(!Xg(m,c))return null}}return`Expected ${rl(p)} but found ${rl(c)} instead.`}function DM(p,c){return c.some(m=>m.kind===p.kind)}function J_(p,c){return c.some(m=>m==="null"?p===null:m==="array"?Array.isArray(p):m==="object"?p&&!Array.isArray(p)&&typeof p=="object":m===typeof p)}function oS(p,c){return p.kind==="array"&&c.kind==="array"?p.N===c.N&&oS(p.itemType,c.itemType):p.kind===c.kind}class OM{constructor(c,m,y){this.sensitivity=c?m?"variant":"case":m?"accent":"base",this.locale=y,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(c,m){return this.collator.compare(c,m)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class lS{constructor(c,m,y,k,E){this.text=c.normalize?c.normalize():c,this.image=m,this.scale=y,this.fontStack=k,this.textColor=E}}class Vd{constructor(c){this.sections=c}static fromString(c){return new Vd([new lS(c,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(c=>c.text.length!==0||!!c.image&&c.image.hasPrimary())}static factory(c){return c instanceof Vd?c:Vd.fromString(c)}toString(){return this.sections.length===0?"":this.sections.map(c=>c.text).join("")}serialize(){const c=["format"];for(const m of this.sections){if(m.image){const k=m.image.getPrimary().id.toString();c.push(["image",k]);continue}c.push(m.text);const y={};m.fontStack&&(y["text-font"]=["literal",m.fontStack.split(",")]),m.scale&&(y["font-scale"]=m.scale),m.textColor&&(y["text-color"]=["rgba"].concat(m.textColor.toNonPremultipliedRenderColor(null).toArray())),c.push(y)}return c}}class Af{constructor(c,m={}){this.id=Hs.from(c),this.params=m.params,this.sx=m.sx||1,this.sy=m.sy||1}toString(){return JSON.stringify(this)}static parse(c){let m,y,k,E;try{({id:m,params:y,sx:k,sy:E}=JSON.parse(c)||{})}catch{return null}return m?new Af(m,{params:y,sx:k,sy:E}):null}scaleSelf(c,m=c){return this.sx*=c,this.sy*=m,this}}class Hd{constructor(c,m,y,k,E=!1){this.primaryId=Hs.from(c),this.primaryOptions=m,y&&(this.secondaryId=Hs.from(y)),this.secondaryOptions=k,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 Af(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Af(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Hd.build({name:c}):c}static build(c,m,y,k){return!c||typeof c=="object"&&!("name"in c)?null:new Hd(c,y,m,k)}}function yy(p,c,m,y){return typeof p=="number"&&p>=0&&p<=255&&typeof c=="number"&&c>=0&&c<=255&&typeof m=="number"&&m>=0&&m<=255?y===void 0||typeof y=="number"&&y>=0&&y<=1?null:`Invalid rgba value [${[p,c,m,y].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof y=="number"?[p,c,m,y]:[p,c,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function nv(p){if(p===null||typeof p=="string"||typeof p=="boolean"||typeof p=="number"||p instanceof Fr||p instanceof OM||p instanceof Vd||p instanceof Hd)return!0;if(Array.isArray(p)){for(const c of p)if(!nv(c))return!1;return!0}if(typeof p=="object"){for(const c in p)if(!nv(p[c]))return!1;return!0}return!1}function sc(p){if(p===null)return Fm;if(typeof p=="string")return va;if(typeof p=="boolean")return di;if(typeof p=="number")return Dr;if(p instanceof Fr)return xu;if(p instanceof OM)return iS;if(p instanceof Vd)return X_;if(p instanceof Hd)return Q_;if(Array.isArray(p)){const c=p.length;let m;for(const y of p){const k=sc(y);if(m){if(m===k)continue;m=ti;break}m=k}return cd(m||ti,c)}return Cp}function em(p){const c=typeof p;return p===null?"":c==="string"||c==="number"||c==="boolean"?String(p):p instanceof Vd||p instanceof Hd||p instanceof Fr?p.toString():JSON.stringify(p)}class Ef{constructor(c,m){this.type=c,this.value=m}static parse(c,m){if(c.length!==2)return m.error(`'literal' expression requires exactly one argument, but found ${c.length-1} instead.`);if(!nv(c[1]))return m.error("invalid value");const y=c[1];let k=sc(y);const E=m.expectedType;return k.kind!=="array"||k.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(k=E),new Ef(k,y)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Fr?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Vd?this.value.serialize():this.value}}class Ol{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const RM={string:va,number:Dr,boolean:di,object:Cp};class zm{constructor(c,m){this.type=c,this.args=m}static parse(c,m){if(c.length<2)return m.error("Expected at least one argument.");let y,k=1;const E=c[0];if(E==="array"){let O,B;if(c.length>2){const W=c[1];if(typeof W!="string"||!(W in RM)||W==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);O=RM[W],k++}else O=ti;if(c.length>3){if(c[2]!==null&&(typeof c[2]!="number"||c[2]<0||c[2]!==Math.floor(c[2])))return m.error('The length argument to "array" must be a positive integer literal',2);B=c[2],k++}y=cd(O,B)}else y=RM[E];const P=[];for(;kc.outputDefined())}serialize(){const c=this.type,m=[c.kind];if(c.kind==="array"){const y=c.itemType;if(y.kind==="string"||y.kind==="number"||y.kind==="boolean"){m.push(y.kind);const k=c.N;(typeof k=="number"||this.args.length>1)&&m.push(k)}}return m.concat(this.args.map(y=>y.serialize()))}}class Mp{constructor(c){this.type=X_,this.sections=c}static parse(c,m){if(c.length<2)return m.error("Expected at least one argument.");const y=c[1];if(!Array.isArray(y)&&typeof y=="object")return m.error("First argument must be an image or text section.");const k=[];let E=!1;for(let P=1;P<=c.length-1;++P){const O=c[P];if(E&&typeof O=="object"&&!Array.isArray(O)){E=!1;let B=null;if(O["font-scale"]&&(B=m.parseObjectValue(O["font-scale"],P,"font-scale",Dr),!B))return null;let W=null;if(O["text-font"]&&(W=m.parseObjectValue(O["text-font"],P,"text-font",cd(va)),!W))return null;let J=null;if(O["text-color"]&&(J=m.parseObjectValue(O["text-color"],P,"text-color",xu),!J))return null;const ee=k[k.length-1];ee.scale=B,ee.font=W,ee.textColor=J}else{const B=m.parse(c[P],P,ti);if(!B)return null;const W=B.type.kind;if(W!=="string"&&W!=="value"&&W!=="null"&&W!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");E=!0,k.push({content:B,scale:null,font:null,textColor:null})}}return new Mp(k)}evaluate(c){return new Vd(this.sections.map(m=>{const y=m.content.evaluate(c);return oS(sc(y),Q_)?new lS("",y,null,null,null):new lS(em(y),null,m.scale?m.scale.evaluate(c):null,m.font?m.font.evaluate(c).join(","):null,m.textColor?m.textColor.evaluate(c):null)}))}eachChild(c){for(const m of this.sections)c(m.content),m.scale&&c(m.scale),m.font&&c(m.font),m.textColor&&c(m.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const m of this.sections){c.push(m.content.serialize());const y={};m.scale&&(y["font-scale"]=m.scale.serialize()),m.font&&(y["text-font"]=m.font.serialize()),m.textColor&&(y["text-color"]=m.textColor.serialize()),c.push(y)}return c}}class En{constructor(c,m,y,k){this._imageWarnHistory={},this.type=Q_,this.namePrimary=c,this.nameSecondary=m,y&&(this.paramsPrimary=y.params,this.iconsetIdPrimary=y.iconset?y.iconset.id:void 0),k&&(this.paramsSecondary=k.params,this.iconsetIdSecondary=k.iconset?k.iconset.id:void 0)}static parse(c,m){if(c.length<2)return m.error("Expected two or more arguments.");let y=1;const k=[];function E(){if(yHs.isEqual(P,E)),k.available){const P=k.getSecondary()?k.getSecondary().id:null;P&&(k.available=c.availableImages.some(O=>Hs.isEqual(O,P)))}}return k}eachChild(c){if(c(this.namePrimary),this.paramsPrimary)for(const m in this.paramsPrimary)this.paramsPrimary[m]&&c(this.paramsPrimary[m]);if(this.nameSecondary&&(c(this.nameSecondary),this.paramsSecondary))for(const m in this.paramsSecondary)this.paramsSecondary[m]&&c(this.paramsSecondary[m])}outputDefined(){return!1}serializeOptions(c,m){const y={};if(m&&(y.iconset={id:m}),c){y.params={};for(const k in c)c[k]&&(y.params[k]=c[k].serialize())}return Object.keys(y).length>0?y:void 0}serialize(){const c=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const m=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);m&&c.push(m)}if(this.nameSecondary&&(c.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const m=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);m&&c.push(m)}return c}}function Er(p){return ln(p)?"string":av(p)?"number":dS(p)?"boolean":Array.isArray(p)?"array":p===null?"null":cS(p)?"object":typeof p}function cS(p){return p!=null&&!Array.isArray(p)&&typeof p!="function"&&!(p instanceof String||p instanceof Number||p instanceof Boolean)&&typeof p=="object"}function ln(p){return typeof p=="string"||p instanceof String}function av(p){return typeof p=="number"||p instanceof Number}function dS(p){return typeof p=="boolean"||p instanceof Boolean}const rn={"to-boolean":di,"to-color":xu,"to-number":Dr,"to-string":va};class Tp{constructor(c,m){this.type=c,this.args=m}static parse(c,m){if(c.length<2)return m.error("Expected at least one argument.");const y=c[0],k=[];let E=Fm;if(y==="to-array"){if(!Array.isArray(c[1]))return null;const P=c[1].length;if(m.expectedType){if(m.expectedType.kind!=="array")return m.error(`Expected ${m.expectedType.kind} but found array.`);E=cd(m.expectedType.itemType,P)}else{if(!(P>0&&nv(c[1][0])))return null;E=cd(sc(c[1][0]),P)}for(let O=0;O4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:yy(m[0],m[1],m[2],m[3]),!y))return new Fr(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new Ol(y||`Could not parse color from value '${typeof m=="string"?m:String(JSON.stringify(m))}'`)}if(this.type.kind==="number"){let m=null;for(const y of this.args){if(m=y.evaluate(c),m===null)return 0;const k=Number(m);if(!isNaN(k))return k}throw new Ol(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Vd.fromString(em(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Hd.build(em(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(m=>m.evaluate(c)):em(this.args[0].evaluate(c))}eachChild(c){this.args.forEach(c)}outputDefined(){return this.args.every(c=>c.outputDefined())}serialize(){if(this.type.kind==="formatted")return new Mp([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new En(this.args[0]).serialize();const c=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{c.push(m.serialize())}),c}}const FM=["Unknown","Point","LineString","Polygon"];class uS{constructor(c,m,y){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=c,this.options=m,this.iconImageUseTheme=y}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?FM[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(c){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const c=this.featureDistanceData.center,m=this.featureDistanceData.scale,{x:y,y:k}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(y*m-c[0])+this.featureDistanceData.bearing[1]*(k*m-c[1])}return 0}parseColor(c){let m=this._parseColorCache[c];return m||(m=this._parseColorCache[c]=Fr.parse(c)),m}getConfig(c){return this.options?this.options.get(c):null}}class Wd{constructor(c,m,y,k,E){this.name=c,this.type=m,this._evaluate=y,this.args=k,this._overloadIndex=E}evaluate(c){if(!this._evaluate){const m=Wd.definitions[this.name];this._evaluate=Array.isArray(m)?m[2]:m.overloads[this._overloadIndex][1]}return this._evaluate(c,this.args)}eachChild(c){this.args.forEach(c)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(c=>c.serialize()))}static parse(c,m){const y=c[0],k=Wd.definitions[y];if(!k)return m.error(`Unknown expression "${y}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(k)?k[0]:k.type,P=Array.isArray(k)?[[k[1],k[2]]]:k.overloads,O=[];let B=null,W=-1;for(const[J,ee]of P){if(Array.isArray(J)&&J.length!==c.length-1)continue;O.push(J),W++,B=new jS(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ne=[];let ie=!1;for(let ue=1;uene)).map(hS).join(" | "),ee=[];for(let ne=1;nem;){if(y-m>600){const B=y-m+1,W=c-m+1,J=Math.log(B),ee=.5*Math.exp(2*J/3),ne=.5*Math.sqrt(J*ee*(B-ee)/B)*(W-B/2<0?-1:1);mS(p,c,Math.max(m,Math.floor(c-W*ee/B+ne)),Math.min(y,Math.floor(c+(B-W)*ee/B+ne)),k)}const E=p[c];let P=m,O=y;for(Bm(p,m,c),k(p[y],E)>0&&Bm(p,m,y);P0;)O--}k(p[m],E)===0?Bm(p,m,O):(O++,Bm(p,O,y)),O<=c&&(m=O+1),c<=O&&(y=O-1)}}function Bm(p,c,m){const y=p[c];p[c]=p[m],p[m]=y}function zM(p,c){return pc?1:0}function Qg(p){let c=0;for(let m,y,k=0,E=p.length,P=E-1;k=c[2]||p[1]<=c[1]||p[3]>=c[3])}function jce(p,c,m){const y=p[0]-c[0],k=p[1]-c[1],E=p[0]-m[0],P=p[1]-m[1];return y*P-E*k==0&&y*E<=0&&k*P<=0}function iv(p,c,m=!1){let y=!1;for(let O=0,B=c.length;O(k=p)[1]!=(P=ue)[1]>k[1]&&k[0]<(P[0]-E[0])*(k[1]-E[1])/(P[1]-E[1])+E[0]&&(y=!y)}}var k,E,P;return y}function tb(p,c,m,y){const k=y[0]-m[0],E=y[1]-m[1],P=(p[0]-m[0])*E-k*(p[1]-m[1]),O=(c[0]-m[0])*E-k*(c[1]-m[1]);return P>0&&O<0||P<0&&O>0}function sb(p,c,m,y){return(k=[y[0]-m[0],y[1]-m[1]])[0]*(E=[c[0]-p[0],c[1]-p[1]])[1]-k[1]*E[0]!=0&&!(!tb(p,c,m,y)||!tb(m,y,p,c));var k,E}function Pf(p){const c=new rs(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new rs(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const y of p[0])c.x>y.x&&(c.x=y.x),c.y>y.y&&(c.y=y.y),m.xm[2]){const k=.5*y;let E=p[0]-m[0]>k?-y:m[0]-p[0]>k?y:0;E===0&&(E=p[0]-m[2]>k?-y:m[2]-p[0]>k?y:0),p[0]+=E}tm(c,p)}function ZL(p,c,m,y){const k=Math.pow(2,y.z)*Jg,E=[y.x*Jg,y.y*Jg],P=[];if(!p)return P;for(const O of p)for(const B of O){const W=[B.x+E[0],B.y+E[1]];KL(W,c,m,k),P.push(W)}return P}function pS(p,c,m,y){const k=Math.pow(2,y.z)*Jg,E=[y.x*Jg,y.y*Jg],P=[];if(!p)return P;for(const B of p){const W=[];for(const J of B){const ee=[J.x+E[0],J.y+E[1]];tm(c,ee),W.push(ee)}P.push(W)}if(c[2]-c[0]<=k/2){(O=c)[0]=O[1]=1/0,O[2]=O[3]=-1/0;for(const B of P)for(const W of B)KL(W,c,m,k)}var O;return P}class tx{constructor(c,m){this.type=di,this.geojson=c,this.geometries=m}static parse(c,m){if(c.length!==2)return m.error(`'within' expression requires exactly one argument, but found ${c.length-1} instead.`);if(nv(c[1])){const y=c[1];if(y.type==="FeatureCollection")for(let k=0;km)return fS(E,P,(m-(y-O))/O)}return c[c.length-1]}pointToSegmentDistance(c,m,y){let[k,E]=m,P=ch(y[0]-k)*this.kx,O=(y[1]-E)*this.ky;if(P!==0||O!==0){const B=(ch(c[0]-k)*this.kx*P+(c[1]-E)*this.ky*O)/(P*P+O*O);B>1?(k=y[0],E=y[1]):B>0&&(k+=P/this.kx*B,E+=O/this.ky*B)}return P=ch(c[0]-k)*this.kx,O=(c[1]-E)*this.ky,Math.sqrt(P*P+O*O)}pointOnLine(c,m){let y=1/0,k=c[0][0],E=c[0][1],P=0,O=0;for(let B=0;B1?(W=c[B+1][0],J=c[B+1][1]):ie>0&&(W+=ee/this.kx*ie,J+=ne/this.ky*ie)),ee=ch(m[0]-W)*this.kx,ne=(m[1]-J)*this.ky;const ue=ee*ee+ne*ne;ueE.index||k.index===E.index&&k.t>E.t){const W=k;k=E,E=W}const P=[k.point],O=k.index+1,B=E.index;!qM(y[O],P[0])&&O<=B&&P.push(y[O]);for(let W=O+1;W<=B;W++)P.push(y[W]);return qM(y[B],E.point)||P.push(E.point),P}lineSliceAlong(c,m,y){let k=0;const E=[];for(let P=0;Pc&&E.length===0&&E.push(fS(O,B,(c-(k-W))/W)),k>=m)return E.push(fS(O,B,(m-(k-W))/W)),E;k>c&&E.push(B)}return E}bufferPoint(c,m){const y=m/this.ky,k=m/this.kx;return[c[0]-k,c[1]-y,c[0]+k,c[1]+y]}bufferBBox(c,m){const y=m/this.ky,k=m/this.kx;return[c[0]-k,c[1]-y,c[2]+k,c[3]+y]}insideBBox(c,m){return ch(c[0]-m[0])>=0&&ch(c[0]-m[2])<=0&&c[1]>=m[1]&&c[1]<=m[3]}}function qM(p,c){return p[0]===c[0]&&p[1]===c[1]}function fS(p,c,m){const y=ch(c[0]-p[0]);return[p[0]+y*m,p[1]+(c[1]-p[1])*m]}function ch(p){for(;p<-180;)p+=360;for(;p>180;)p-=360;return p}class gS{constructor(c=[],m=(y,k)=>yk?1:0){if(this.data=c,this.length=this.data.length,this.compare=m,this.length>0)for(let y=(this.length>>1)-1;y>=0;y--)this._down(y)}push(c){this.data.push(c),this._up(this.length++)}pop(){if(this.length===0)return;const c=this.data[0],m=this.data.pop();return--this.length>0&&(this.data[0]=m,this._down(0)),c}peek(){return this.data[0]}_up(c){const{data:m,compare:y}=this,k=m[c];for(;c>0;){const E=c-1>>1,P=m[E];if(y(k,P)>=0)break;m[c]=P,c=E}m[c]=k}_down(c){const{data:m,compare:y}=this,k=this.length>>1,E=m[c];for(;c=0)break;m[c]=m[P],c=P}m[c]=E}}var Gs=8192;function UM(p,c){return c.dist-p.dist}const xS=100,yS=50;function VM(p){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==p.length)return!1;for(let m=0;m=p[0]&&p[1]p[1])return[null,null];const m=nb(p);if(c){if(m===2)return[p,null];const y=Math.floor(m/2);return[[p[0],p[0]+y],[p[0]+y,p[1]]]}{if(m===1)return[p,null];const y=Math.floor(m/2)-1;return[[p[0],p[0]+y],[p[0]+y+1,p[1]]]}}function vy(p,c){const m=[1/0,1/0,-1/0,-1/0];if(!Ap(c,p.length))return m;for(let y=c[0];y<=c[1];++y)tm(m,p[y]);return m}function _y(p){const c=[1/0,1/0,-1/0,-1/0];for(let m=0;mc[2]&&(y=p[0]-c[2]),p[1]>c[3]&&(k=p[1]-c[3]),p[3]=y)return y;if(eb(k,E)){if(GM(p,c))return 0}else if(GM(c,p))return 0;let P=y;for(const O of p)for(let B=0,W=O.length,J=W-1;B=E)continue;const J=W.range1;if(nb(J)<=O){if(!Ap(J,p.length))return NaN;if(c){const ee=Tce(p,J,m,y);if((E=Math.min(E,ee))===0)return E}else for(let ee=J[0];ee<=J[1];++ee){const ne=Mce(p[ee],m,y);if((E=Math.min(E,ne))===0)return E}}else{const ee=HM(J,c);if(ee[0]!==null){const ne=sx(vy(p,ee[0]),B,y);ne=P)continue;const ee=J.range1,ne=J.range2;if(nb(ee)<=B&&nb(ne)<=W){if(!Ap(ee,p.length)||!Ap(ne,m.length))return NaN;if(c&&y?P=Math.min(P,wa(p,ee,m,ne,k)):c||y?c&&!y?P=Math.min(P,WM(m,ne,p,ee,k)):!c&&y&&(P=Math.min(P,WM(p,ee,m,ne,k))):P=Math.min(P,Cce(p,ee,m,ne,k)),P===0)return P}else{const ie=HM(ee,c),ue=HM(ne,y);Qi(O,P,k,p,m,ie[0],ue[0]),Qi(O,P,k,p,m,ie[0],ue[1]),Qi(O,P,k,p,m,ie[1],ue[0]),Qi(O,P,k,p,m,ie[1],ue[1])}}return P}function KM(p,c,m,y,k=1/0){let E=k;const P=vy(p,[0,p.length-1]);for(const O of m)if(!(E!==1/0&&sx(P,vy(O,[0,O.length-1]),y)>=E)&&(E=Math.min(E,JL(p,c,O,!0,y,E)),E===0))return E;return E}function bS(p,c,m,y,k=1/0){let E=k;const P=vy(p,[0,p.length-1]);for(const O of m){if(E!==1/0&&sx(P,_y(O),y)>=E)continue;const B=Ece(p,c,O,y,E);if(isNaN(B))return B;if((E=Math.min(E,B))===0)return E}return E}function ZM(p){return p==="Point"||p==="MultiPoint"||p==="LineString"||p==="MultiLineString"||p==="Polygon"||p==="MultiPolygon"}class by{constructor(c,m){this.type=Dr,this.geojson=c,this.geometries=m}static parse(c,m){if(c.length!==2)return m.error(`'distance' expression requires either one argument, but found ' ${c.length-1} instead.`);if(nv(c[1])){const y=c[1];if(y.type==="FeatureCollection"){for(let k=0;k{c&&!cv(m)&&(c=!1)}),c}function ab(p){if(p instanceof Wd&&p.name==="feature-state")return!1;let c=!0;return p.eachChild(m=>{c&&!ab(m)&&(c=!1)}),c}function dv(p,c){if(p instanceof Wd&&c.indexOf(p.name)>=0)return!1;let m=!0;return p.eachChild(y=>{m&&!dv(y,c)&&(m=!1)}),m}function eD(p,c,m){return[p,c,m].filter(Boolean).join("")}function YM(p,c){switch(p){case"string":return em(c);case"number":return+c;case"boolean":return!!c;case"color":return Fr.parse(c);case"formatted":return Vd.fromString(em(c));case"resolvedImage":return Hd.build(em(c))}return c}function tD(p,c,m,y){return y!==void 0&&(p=y*Math.round(p/y)),c!==void 0&&pm&&(p=m),p}class uv{constructor(c,m,y,k=!1){this.type=c,this.key=m,this.scope=y,this.featureConstant=k}static parse(c,m){let y=m.expectedType;if(y==null&&(y=ti),c.length<2||c.length>3)return m.error("Invalid number of arguments for 'config' expression.");const k=m.parse(c[1],1);if(!(k instanceof Ef))return m.error("Key name of 'config' expression must be a string literal.");let E,P=!0;const O=em(k.value);if(c.length>=3){const B=m.parse(c[2],2);if(!(B instanceof Ef))return m.error("Scope of 'config' expression must be a string literal.");E=em(B.value)}if(m.options){const B=eD(O,E,m._scope),W=m.options.get(B);W&&(P=cv(W.value||W.default))}return new uv(y,O,E,P)}evaluate(c){const m=eD(this.key,this.scope,c.scope),y=c.getConfig(m);if(!y)return null;const{type:k,value:E,values:P,minValue:O,maxValue:B,stepValue:W}=y,J=y.default.evaluate(c);let ee=J;if(E){const ne=c.scope;c.scope=(ne||"").split("").slice(1).join(""),ee=E.evaluate(c),c.scope=ne}return k&&(ee=YM(k,ee)),ee===void 0||O===void 0&&B===void 0&&W===void 0||(typeof ee=="number"?ee=tD(ee,O,B,W):Array.isArray(ee)&&(ee=ee.map(ne=>typeof ne=="number"?tD(ne,O,B,W):ne))),E!==void 0&&ee!==void 0&&P&&!P.includes(ee)&&(ee=J,k&&(ee=YM(k,ee))),(k&&k!==this.type||ee!==void 0&&!oS(sc(ee),this.type))&&(ee=YM(this.type.kind,ee)),ee}eachChild(){}outputDefined(){return!1}serialize(){const c=["config",this.key];return this.scope&&c.concat(this.scope),c}}class wS{constructor(c,m){this.type=m.type,this.name=c,this.boundExpression=m}static parse(c,m){if(c.length!==2||typeof c[1]!="string")return m.error("'var' expression requires exactly one string literal argument.");const y=c[1];return m.scope.has(y)?new wS(y,m.scope.get(y)):m.error(`Unknown variable "${y}". Make sure "${y}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(c){return this.boundExpression.evaluate(c)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class jS{constructor(c,m=[],y,k=new rv,E=[],P,O,B){this.registry=c,this.path=m,this.key=m.map(W=>typeof W=="string"?`['${W}']`:`[${W}]`).join(""),this.scope=k,this.errors=E,this.expectedType=y,this._scope=P,this.options=O,this.iconImageUseTheme=B}parse(c,m,y,k,E={}){return m||y?this.concat(m,null,y,k)._parse(c,E):this._parse(c,E)}parseObjectValue(c,m,y,k,E,P={}){return this.concat(m,y,k,E)._parse(c,P)}_parse(c,m){function y(k,E,P){return P==="assert"?new zm(E,[k]):P==="coerce"?new Tp(E,[k]):k}if(c!==null&&typeof c!="string"&&typeof c!="boolean"&&typeof c!="number"||(c=["literal",c]),Array.isArray(c)){if(c.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const k=typeof c[0]=="string"?this.registry[c[0]]:void 0;if(k){let E=k.parse(c,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=y(E,P,m.typeAnnotation||"coerce");else E=y(E,P,m.typeAnnotation||"assert")}if(!(E instanceof Ef)&&E.type.kind!=="resolvedImage"&&XM(E)){const P=new uS(this._scope,this.options,this.iconImageUseTheme);try{E=new Ef(E.type,E.evaluate(P))}catch(O){return this.error(O.message),null}}return E}return Tp.parse(["to-array",c],this)}return this.error(c===void 0?"'undefined' value invalid. Use null instead.":typeof c=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof c} instead.`)}concat(c,m,y,k){let E=typeof c=="number"?this.path.concat(c):this.path;E=typeof m=="string"?E.concat(m):E;const P=k?this.scope.concat(k):this.scope;return new jS(this.registry,E,y||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(c,...m){const y=`${this.key}${m.map(k=>`[${k}]`).join("")}`;this.errors.push(new Jh(y,c))}checkSubtype(c,m){const y=Xg(c,m);return y&&this.error(y),y}}function XM(p){if(p instanceof wS)return XM(p.boundExpression);if(p instanceof Wd&&p.name==="error"||p instanceof gc||p instanceof tx||p instanceof by||p instanceof uv)return!1;const c=p instanceof Tp||p instanceof zm;let m=!0;return p.eachChild(y=>{m=c?m&&XM(y):m&&y instanceof Ef}),!!m&&cv(p)&&dv(p,["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 kS(p,c){const m=p.length-1;let y,k,E=0,P=m,O=0;for(;E<=P;)if(O=Math.floor((E+P)/2),y=p[O],k=p[O+1],y<=c){if(O===m||cc))throw new Ol("Input is not a number.");P=O-1}return 0}class ib{constructor(c,m,y){this.type=c,this.input=m,this.labels=[],this.outputs=[];for(const[k,E]of y)this.labels.push(k),this.outputs.push(E)}static parse(c,m){if(c.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if((c.length-1)%2!=0)return m.error("Expected an even number of arguments.");const y=m.parse(c[1],1,Dr);if(!y)return null;const k=[];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.',W);const ee=m.parse(B,J,E);if(!ee)return null;E=E||ee.type,k.push([O,ee])}return new ib(E,y,k)}evaluate(c){const m=this.labels,y=this.outputs;if(m.length===1)return y[0].evaluate(c);const k=this.input.evaluate(c);if(k<=m[0])return y[0].evaluate(c);const E=m.length;return k>=m[E-1]?y[E-1].evaluate(c):y[kS(m,k)].evaluate(c)}eachChild(c){c(this.input);for(const m of this.outputs)c(m)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){const c=["step",this.input.serialize()];for(let m=0;m0&&c.push(this.labels[m]),c.push(this.outputs[m].serialize());return c}}const sD=.95047,rD=1.08883,nD=4/29,hv=6/29,aD=3*hv*hv,Pce=hv*hv*hv,Ice=Math.PI/180,Lce=180/Math.PI;function QM(p){return p>Pce?Math.pow(p,1/3):p/aD+nD}function JM(p){return p>hv?p*p*p:aD*(p-nD)}function eT(p){return 255*(p<=.0031308?12.92*p:1.055*Math.pow(p,1/2.4)-.055)}function tT(p){return(p/=255)<=.04045?p/12.92:Math.pow((p+.055)/1.055,2.4)}function iD(p){const c=tT(p.r),m=tT(p.g),y=tT(p.b),k=QM((.4124564*c+.3575761*m+.1804375*y)/sD),E=QM((.2126729*c+.7151522*m+.072175*y)/1);return{l:116*E-16,a:500*(k-E),b:200*(E-QM((.0193339*c+.119192*m+.9503041*y)/rD)),alpha:p.a}}function NS(p){let c=(p.l+16)/116,m=isNaN(p.a)?c:c+p.a/500,y=isNaN(p.b)?c:c-p.b/200;return c=1*JM(c),m=sD*JM(m),y=rD*JM(y),new Fr(eT(3.2404542*m-1.5371385*c-.4985314*y),eT(-.969266*m+1.8760108*c+.041556*y),eT(.0556434*m-.2040259*c+1.0572252*y),p.alpha)}function SS(p,c,m){const y=c-p;return p+m*(y>180||y<-180?y-360*Math.round(y/360):y)}const mv={forward:iD,reverse:NS,interpolate:function(p,c,m){return{l:Ur(p.l,c.l,m),a:Ur(p.a,c.a,m),b:Ur(p.b,c.b,m),alpha:Ur(p.alpha,c.alpha,m)}}},ob={forward:function(p){const{l:c,a:m,b:y}=iD(p),k=Math.atan2(y,m)*Lce;return{h:k<0?k+360:k,c:Math.sqrt(m*m+y*y),l:c,alpha:p.a}},reverse:function(p){const c=p.h*Ice,m=p.c;return NS({l:p.l,a:Math.cos(c)*m,b:Math.sin(c)*m,alpha:p.alpha})},interpolate:function(p,c,m){return{h:SS(p.h,c.h,m),c:Ur(p.c,c.c,m),l:Ur(p.l,c.l,m),alpha:Ur(p.alpha,c.alpha,m)}}};var oD=Object.freeze({__proto__:null,hcl:ob,lab:mv});class dh{constructor(c,m,y,k,E){this.type=c,this.operator=m,this.interpolation=y,this.input=k,this.labels=[],this.outputs=[];for(const[P,O]of E)this.labels.push(P),this.outputs.push(O)}static interpolationFactor(c,m,y,k){let E=0;if(c.name==="exponential")E=CS(m,c.base,y,k);else if(c.name==="linear")E=CS(m,1,y,k);else if(c.name==="cubic-bezier"){const P=c.controlPoints;E=new Dn(P[0],P[1],P[2],P[3]).solve(CS(m,1,y,k))}return E}static parse(c,m){let[y,k,E,...P]=c;if(!Array.isArray(k)||k.length===0)return m.error("Expected an interpolation type expression.",1);if(k[0]==="linear")k={name:"linear"};else if(k[0]==="exponential"){const W=k[1];if(typeof W!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);k={name:"exponential",base:W}}else{if(k[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(k[0])}`,1,0);{const W=k.slice(1);if(W.length!==4||W.some(J=>typeof J!="number"||J<0||J>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);k={name:"cubic-bezier",controlPoints:W}}}if(c.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length-1>3&&(c.length-1)%2!=0)return m.error("Expected an even number of arguments.");if(E=m.parse(E,2,Dr),!E)return null;const O=[];let B=null;y==="interpolate-hcl"||y==="interpolate-lab"?B=xu:m.expectedType&&m.expectedType.kind!=="value"&&(B=m.expectedType);for(let W=0;W=J)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ne);const ue=m.parse(ee,ie,B);if(!ue)return null;B=B||ue.type,O.push([J,ue])}return B.kind==="number"||B.kind==="color"||B.kind==="array"&&B.itemType.kind==="number"&&typeof B.N=="number"?new dh(B,y,k,E,O):m.error(`Type ${rl(B)} is not interpolatable.`)}evaluate(c){const m=this.labels,y=this.outputs;if(m.length===1)return y[0].evaluate(c);const k=this.input.evaluate(c);if(k<=m[0])return y[0].evaluate(c);const E=m.length;if(k>=m[E-1])return y[E-1].evaluate(c);const P=kS(m,k),O=dh.interpolationFactor(this.interpolation,k,m[P],m[P+1]),B=y[P].evaluate(c),W=y[P+1].evaluate(c);return this.operator==="interpolate"?xy[this.type.kind.toLowerCase()](B,W,O):this.operator==="interpolate-hcl"?ob.reverse(ob.interpolate(ob.forward(B),ob.forward(W),O)):mv.reverse(mv.interpolate(mv.forward(B),mv.forward(W),O))}eachChild(c){c(this.input);for(const m of this.outputs)c(m)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){let c;c=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,c,this.input.serialize()];for(let y=0;yXg(k,O.type));return new lb(P?ti:y,E)}evaluate(c){let m,y=null,k=0;for(const E of this.args){if(k++,y=E.evaluate(c),y&&y instanceof Hd&&!y.available&&(m||(m=y),y=null,k===this.args.length))return m;if(y!==null)break}return y}eachChild(c){this.args.forEach(c)}outputDefined(){return this.args.every(c=>c.outputDefined())}serialize(){const c=["coalesce"];return this.eachChild(m=>{c.push(m.serialize())}),c}}class If{constructor(c,m){this.type=m.type,this.bindings=[].concat(c),this.result=m}evaluate(c){return this.result.evaluate(c)}eachChild(c){for(const m of this.bindings)c(m[1]);c(this.result)}static parse(c,m){if(c.length<4)return m.error(`Expected at least 3 arguments, but found ${c.length-1} instead.`);const y=[];for(let E=1;E=y.length)throw new Ol("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new Ol("Array index must be an integer. Use at-interpolated for fractional indices");return y[m]}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class TS{constructor(c,m,y){this.type=c,this.index=m,this.input=y}static parse(c,m){if(c.length!==3)return m.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const y=m.parse(c[1],1,Dr),k=m.parse(c[2],2,cd(m.expectedType||ti));return y&&k?new TS(k.type.itemType,y,k):null}evaluate(c){const m=this.index.evaluate(c),y=this.input.evaluate(c);if(m<0)throw new Ol(`Array index out of bounds: ${m} < 0.`);if(m>y.length-1)throw new Ol(`Array index out of bounds: ${m} > ${y.length-1}.`);if(m===Math.floor(m))return y[m];const k=Math.floor(m),E=Math.ceil(m),P=y[k],O=y[E];if(typeof P!="number"||typeof O!="number")throw new Ol(`Cannot interpolate between non-number values at index ${m}.`);const B=m-k;return P*(1-B)+O*B}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class sT{constructor(c,m){this.type=di,this.needle=c,this.haystack=m}static parse(c,m){if(c.length!==3)return m.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const y=m.parse(c[1],1,ti),k=m.parse(c[2],2,ti);return y&&k?DM(y.type,[di,va,Dr,Fm,ti])?new sT(y,k):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${rl(y.type)} instead`):null}evaluate(c){const m=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(y==null)return!1;if(!J_(m,["boolean","string","number","null"]))throw new Ol(`Expected first argument to be of type boolean, string, number or null, but found ${rl(sc(m))} instead.`);if(!J_(y,["string","array"]))throw new Ol(`Expected second argument to be of type array or string, but found ${rl(sc(y))} instead.`);return y.indexOf(m)>=0}eachChild(c){c(this.needle),c(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class pv{constructor(c,m,y){this.type=Dr,this.needle=c,this.haystack=m,this.fromIndex=y}static parse(c,m){if(c.length<=2||c.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`);const y=m.parse(c[1],1,ti),k=m.parse(c[2],2,ti);if(!y||!k)return null;if(!DM(y.type,[di,va,Dr,Fm,ti]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${rl(y.type)} instead`);if(c.length===4){const E=m.parse(c[3],3,Dr);return E?new pv(y,k,E):null}return new pv(y,k)}evaluate(c){const m=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(!J_(m,["boolean","string","number","null"]))throw new Ol(`Expected first argument to be of type boolean, string, number or null, but found ${rl(sc(m))} instead.`);if(!J_(y,["string","array"]))throw new Ol(`Expected second argument to be of type array or string, but found ${rl(sc(y))} instead.`);if(this.fromIndex){const k=this.fromIndex.evaluate(c);return y.indexOf(m,k)}return y.indexOf(m)}eachChild(c){c(this.needle),c(this.haystack),this.fromIndex&&c(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const c=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),c]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class cb{constructor(c,m,y,k,E,P){this.inputType=c,this.type=m,this.input=y,this.cases=k,this.outputs=E,this.otherwise=P}static parse(c,m){if(c.length<5)return m.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length%2!=1)return m.error("Expected an even number of arguments.");let y,k;m.expectedType&&m.expectedType.kind!=="value"&&(k=m.expectedType);const E={},P=[];for(let W=2;WNumber.MAX_SAFE_INTEGER)return ne.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof ue=="number"&&Math.floor(ue)!==ue)return ne.error("Numeric branch labels must be integer values.");if(y){if(ne.checkSubtype(y,sc(ue)))return null}else y=sc(ue);if(E[String(ue)]!==void 0)return ne.error("Branch labels must be unique.");E[String(ue)]=P.length}const ie=m.parse(ee,W,k);if(!ie)return null;k=k||ie.type,P.push(ie)}const O=m.parse(c[1],1,ti);if(!O)return null;const B=m.parse(c[c.length-1],c.length-1,k);return B?O.type.kind!=="value"&&m.concat(1).checkSubtype(y,O.type)?null:new cb(y,k,O,E,P,B):null}evaluate(c){const m=this.input.evaluate(c);return(oS(sc(m),this.inputType)&&this.outputs[this.cases[m]]||this.otherwise).evaluate(c)}eachChild(c){c(this.input),this.outputs.forEach(c),c(this.otherwise)}outputDefined(){return this.outputs.every(c=>c.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["match",this.input.serialize()],m=Object.keys(this.cases).sort(),y=[],k={};for(const P of m){const O=k[this.cases[P]];O===void 0?(k[this.cases[P]]=y.length,y.push([this.cases[P],[P]])):y[O][1].push(P)}const E=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,O]of y)c.push(O.length===1?E(O[0]):O.map(E)),c.push(this.outputs[P].serialize());return c.push(this.otherwise.serialize()),c}}class db{constructor(c,m,y){this.type=c,this.branches=m,this.otherwise=y}static parse(c,m){if(c.length<4)return m.error(`Expected at least 3 arguments, but found only ${c.length-1}.`);if(c.length%2!=0)return m.error("Expected an odd number of arguments.");let y;m.expectedType&&m.expectedType.kind!=="value"&&(y=m.expectedType);const k=[];for(let P=1;Pm.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["case"];return this.eachChild(m=>{c.push(m.serialize())}),c}}class AS{constructor(c,m,y,k){this.type=c,this.input=m,this.beginIndex=y,this.endIndex=k}static parse(c,m){if(c.length<=2||c.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`);const y=m.parse(c[1],1,ti),k=m.parse(c[2],2,Dr);if(!y||!k)return null;if(!DM(y.type,[cd(ti),va,ti]))return m.error(`Expected first argument to be of type array or string, but found ${rl(y.type)} instead`);if(c.length===4){const E=m.parse(c[3],3,Dr);return E?new AS(y.type,y,k,E):null}return new AS(y.type,y,k)}evaluate(c){const m=this.input.evaluate(c),y=this.beginIndex.evaluate(c);if(!J_(m,["string","array"]))throw new Ol(`Expected first argument to be of type array or string, but found ${rl(sc(m))} instead.`);if(this.endIndex){const k=this.endIndex.evaluate(c);return m.slice(y,k)}return m.slice(y)}eachChild(c){c(this.input),c(this.beginIndex),this.endIndex&&c(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const c=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),c]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class rT{constructor(c,m){this.type=cd(va),this.str=c,this.delimiter=m}static parse(c,m){if(c.length!==3)return m.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const y=m.parse(c[1],1,va),k=m.parse(c[2],2,va);return y&&k?new rT(y,k):void 0}evaluate(c){const m=this.str.evaluate(c),y=this.delimiter.evaluate(c);return m.split(y)}eachChild(c){c(this.str),c(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function nT(p,c){return p==="=="||p==="!="?c.kind==="boolean"||c.kind==="string"||c.kind==="number"||c.kind==="null"||c.kind==="value":c.kind==="string"||c.kind==="number"||c.kind==="value"}function aT(p,c,m,y){return y.compare(c,m)===0}function fv(p,c,m){const y=p!=="=="&&p!=="!=";return class sBe{constructor(E,P,O){this.type=di,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 B=P.parse(E[1],1,ti);if(!B)return null;if(!nT(O,B.type))return P.concat(1).error(`"${O}" comparisons are not supported for type '${rl(B.type)}'.`);let W=P.parse(E[2],2,ti);if(!W)return null;if(!nT(O,W.type))return P.concat(2).error(`"${O}" comparisons are not supported for type '${rl(W.type)}'.`);if(B.type.kind!==W.type.kind&&B.type.kind!=="value"&&W.type.kind!=="value")return P.error(`Cannot compare types '${rl(B.type)}' and '${rl(W.type)}'.`);y&&(B.type.kind==="value"&&W.type.kind!=="value"?B=new zm(W.type,[B]):B.type.kind!=="value"&&W.type.kind==="value"&&(W=new zm(B.type,[W])));let J=null;if(E.length===4){if(B.type.kind!=="string"&&W.type.kind!=="string"&&B.type.kind!=="value"&&W.type.kind!=="value")return P.error("Cannot use collator to compare non-string types.");if(J=P.parse(E[3],3,iS),!J)return null}return new sBe(B,W,J)}evaluate(E){const P=this.lhs.evaluate(E),O=this.rhs.evaluate(E);if(y&&this.hasUntypedArgument){const B=sc(P),W=sc(O);if(B.kind!==W.kind||B.kind!=="string"&&B.kind!=="number")throw new Ol(`Expected arguments for "${p}" to be (string, string) or (number, number), but found (${B.kind}, ${W.kind}) instead.`)}if(this.collator&&!y&&this.hasUntypedArgument){const B=sc(P),W=sc(O);if(B.kind!=="string"||W.kind!=="string")return c(E,P,O)}return this.collator?m(E,P,O,this.collator.evaluate(E)):c(E,P,O)}eachChild(E){E(this.lhs),E(this.rhs),this.collator&&E(this.collator)}outputDefined(){return!0}serialize(){const E=[p];return this.eachChild(P=>{E.push(P.serialize())}),E}}}const Dce=fv("==",function(p,c,m){return c===m},aT),Oce=fv("!=",function(p,c,m){return c!==m},function(p,c,m,y){return!aT(0,c,m,y)}),lD=fv("<",function(p,c,m){return c",function(p,c,m){return c>m},function(p,c,m,y){return y.compare(c,m)>0}),ES=fv("<=",function(p,c,m){return c<=m},function(p,c,m,y){return y.compare(c,m)<=0}),Rce=fv(">=",function(p,c,m){return c>=m},function(p,c,m,y){return y.compare(c,m)>=0});class PS{constructor(c,m,y,k,E,P){this.type=va,this.number=c,this.locale=m,this.currency=y,this.unit=k,this.minFractionDigits=E,this.maxFractionDigits=P}static parse(c,m){if(c.length!==3)return m.error("Expected two arguments.");const y=m.parse(c[1],1,Dr);if(!y)return null;const k=c[2];if(typeof k!="object"||Array.isArray(k))return m.error("NumberFormat options argument must be an object.");let E=null;if(k.locale&&(E=m.parseObjectValue(k.locale,2,"locale",va),!E))return null;let P=null;if(k.currency&&(P=m.parseObjectValue(k.currency,2,"currency",va),!P))return null;let O=null;if(k.unit&&(O=m.parseObjectValue(k.unit,2,"unit",va),!O))return null;let B=null;if(k["min-fraction-digits"]&&(B=m.parseObjectValue(k["min-fraction-digits"],2,"min-fraction-digits",Dr),!B))return null;let W=null;return k["max-fraction-digits"]&&(W=m.parseObjectValue(k["max-fraction-digits"],2,"max-fraction-digits",Dr),!W)?null:new PS(y,E,P,O,B,W)}evaluate(c){return new Intl.NumberFormat(this.locale?this.locale.evaluate(c):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(c):void 0,unit:this.unit?this.unit.evaluate(c):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(c):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(c):void 0}).format(this.number.evaluate(c))}eachChild(c){c(this.number),this.locale&&c(this.locale),this.currency&&c(this.currency),this.unit&&c(this.unit),this.minFractionDigits&&c(this.minFractionDigits),this.maxFractionDigits&&c(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const c={};return this.locale&&(c.locale=this.locale.serialize()),this.currency&&(c.currency=this.currency.serialize()),this.unit&&(c.unit=this.unit.serialize()),this.minFractionDigits&&(c["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(c["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),c]}}class iT{constructor(c){this.type=Dr,this.input=c}static parse(c,m){if(c.length!==2)return m.error(`Expected 1 argument, but found ${c.length-1} instead.`);const y=m.parse(c[1],1);return y?y.type.kind!=="array"&&y.type.kind!=="string"&&y.type.kind!=="value"?m.error(`Expected argument of type string or array, but found ${rl(y.type)} instead.`):new iT(y):null}evaluate(c){const m=this.input.evaluate(c);if(typeof m=="string"||Array.isArray(m))return m.length;throw new Ol(`Expected value to be of type string or array, but found ${rl(sc(m))} instead.`)}eachChild(c){c(this.input)}outputDefined(){return!1}serialize(){const c=["length"];return this.eachChild(m=>{c.push(m.serialize())}),c}}function dD(p){return function(){p=1831565813+(p|=0)|0;let c=Math.imul(p^p>>>15,1|p);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const gv={"==":Dce,"!=":Oce,">":cD,"<":lD,">=":Rce,"<=":ES,array:zm,at:MS,"at-interpolated":TS,boolean:zm,case:db,coalesce:lb,collator:gc,format:Mp,image:En,in:sT,"index-of":pv,interpolate:dh,"interpolate-hcl":dh,"interpolate-lab":dh,length:iT,let:If,literal:Ef,match:cb,number:zm,"number-format":PS,object:zm,slice:AS,step:ib,string:zm,"to-boolean":Tp,"to-color":Tp,"to-number":Tp,"to-string":Tp,var:wS,within:tx,distance:by,config:uv,split:rT};function oT(p,[c,m,y,k]){c=c.evaluate(p),m=m.evaluate(p),y=y.evaluate(p);const E=k?k.evaluate(p):1,P=yy(c,m,y,E);if(P)throw new Ol(P);return new Fr(c/255,m/255,y/255,E)}function lT(p,[c,m,y,k]){c=c.evaluate(p),m=m.evaluate(p),y=y.evaluate(p);const E=k?k.evaluate(p):1,P=function(W,J,ee,ne){return typeof W=="number"&&W>=0&&W<=360?typeof J=="number"&&J>=0&&J<=100&&typeof ee=="number"&&ee>=0&&ee<=100?ne===void 0||typeof ne=="number"&&ne>=0&&ne<=1?null:`Invalid hsla value [${[W,J,ee,ne].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ne=="number"?[W,J,ee,ne]:[W,J,ee]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ne=="number"?[W,J,ee,ne]:[W,J,ee]).join(", ")}]: 'h' must be between 0 and 360.`}(c,m,y,E);if(P)throw new Ol(P);const O=`hsla(${c}, ${m}%, ${y}%, ${E})`,B=Fr.parse(O);if(!B)throw new Ol(`Failed to parse HSLA color: ${O}`);return B}function uD(p,c){return p in c}function cT(p,c){const m=c[p];return m===void 0?null:m}function nx(p){return{type:p}}function wy(p){if(p instanceof uv)return new Set([p.key]);let c=new Set;return p.eachChild(m=>{c=new Set([...c,...wy(m)])}),c}function IS(p){if(p instanceof Wd&&p.name==="is-active-floor")return!0;let c=!1;return p.eachChild(m=>{!c&&IS(m)&&(c=!0)}),c}function hD(p){return{result:"success",value:p}}function ax(p){return{result:"error",value:p}}function dT(p,c){return!!p&&!!p.parameters&&p.parameters.indexOf(c)>-1}function ub(p){return p["property-type"]==="data-driven"}function mD(p){return dT(p.expression,"measure-light")}function pD(p){return dT(p.expression,"zoom")}function LS(p){return!!p.expression&&p.expression.interpolated}function DS(p){return typeof p=="object"&&p!==null&&!Array.isArray(p)}function fD(p){return p}function gD(p,c){const m=c.type==="color",y=p.stops&&typeof p.stops[0][0]=="object",k=y||!(y||p.property!==void 0),E=p.type||(LS(c)?"exponential":"interval");if(m&&((p=Object.assign({},p)).stops&&(p.stops=p.stops.map(W=>[W[0],Fr.parse(W[1])])),p.default=Fr.parse(p.default?p.default:c.default)),p.colorSpace&&p.colorSpace!=="rgb"&&!oD[p.colorSpace])throw new Error(`Unknown color space: ${p.colorSpace}`);let P,O,B;if(E==="exponential")P=xD;else if(E==="interval")P=zce;else if(E==="categorical"){P=Fce,O=Object.create(null);for(const W of p.stops)O[W[0]]=W[1];B=typeof p.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);P=yD}if(y){const W={},J=[];for(let ie=0;ieie[0]),evaluate:({zoom:ie},ue)=>xD({stops:ee,base:p.base},c,ie).evaluate(ie,ue)}}if(k){const W=E==="exponential"?{name:"exponential",base:p.base!==void 0?p.base:1}:null;return{kind:"camera",interpolationType:W,interpolationFactor:dh.interpolationFactor.bind(void 0,W),zoomStops:p.stops.map(J=>J[0]),evaluate:({zoom:J})=>P(p,c,J,O,B)}}return{kind:"source",evaluate(W,J){const ee=J&&J.properties?J.properties[p.property]:void 0;return ee===void 0?Ep(p.default,c.default):P(p,c,ee,O,B)}}}function Ep(p,c,m){return p!==void 0?p:c!==void 0?c:m!==void 0?m:void 0}function Fce(p,c,m,y,k){return Ep(typeof m===k?y[m]:void 0,p.default,c.default)}function zce(p,c,m){if(!av(m))return Ep(p.default,c.default);const y=p.stops.length;if(y===1||m<=p.stops[0][0])return p.stops[0][1];if(m>=p.stops[y-1][0])return p.stops[y-1][1];const k=kS(p.stops.map(E=>E[0]),m);return p.stops[k][1]}function xD(p,c,m){const y=p.base!==void 0?p.base:1;if(!av(m))return Ep(p.default,c.default);const k=p.stops.length;if(k===1||m<=p.stops[0][0])return p.stops[0][1];if(m>=p.stops[k-1][0])return p.stops[k-1][1];const E=kS(p.stops.map(J=>J[0]),m),P=function(J,ee,ne,ie){const ue=ie-ne,we=J-ne;return ue===0?0:ee===1?we/ue:(Math.pow(ee,we)-1)/(Math.pow(ee,ue)-1)}(m,y,p.stops[E][0],p.stops[E+1][0]),O=p.stops[E][1],B=p.stops[E+1][1];let W=xy[c.type]||fD;if(p.colorSpace&&p.colorSpace!=="rgb"){const J=oD[p.colorSpace];W=(ee,ne)=>J.reverse(J.interpolate(J.forward(ee),J.forward(ne),P))}return typeof O.evaluate=="function"?{evaluate(...J){const ee=O.evaluate.apply(void 0,J),ne=B.evaluate.apply(void 0,J);if(ee!==void 0&&ne!==void 0)return W(ee,ne,P)}}:W(O,B,P)}function yD(p,c,m){return c.type==="color"?m=Fr.parse(m):c.type==="formatted"?m=Vd.fromString(m.toString()):c.type==="resolvedImage"?m=Hd.build(m.toString()):Er(m)===c.type||c.type==="enum"&&c.values[m]||(m=void 0),Ep(m,p.default,c.default)}Wd.register(gv,{error:[{kind:"error"},[va],(p,[c])=>{throw new Ol(c.evaluate(p))}],typeof:[va,[ti],(p,[c])=>rl(sc(c.evaluate(p)))],"to-rgba":[cd(Dr,4),[xu],(p,[c])=>c.evaluate(p).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[cd(Dr,4),[xu],(p,[c])=>c.evaluate(p).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[xu,[Dr,Dr,Dr],oT],rgba:[xu,[Dr,Dr,Dr,Dr],oT],hsl:[xu,[Dr,Dr,Dr],lT],hsla:[xu,[Dr,Dr,Dr,Dr],lT],has:{type:di,overloads:[[[va],(p,[c])=>uD(c.evaluate(p),p.properties())],[[va,Cp],(p,[c,m])=>uD(c.evaluate(p),m.evaluate(p))]]},get:{type:ti,overloads:[[[va],(p,[c])=>cT(c.evaluate(p),p.properties())],[[va,Cp],(p,[c,m])=>cT(c.evaluate(p),m.evaluate(p))]]},"feature-state":[ti,[va],(p,[c])=>cT(c.evaluate(p),p.featureState||{})],properties:[Cp,[],p=>p.properties()],"geometry-type":[va,[],p=>p.geometryType()],worldview:[va,[],p=>p.globals.worldview||""],"is-active-floor":[di,nx(va),(p,c)=>{if(!(p.globals.activeFloors&&p.globals.activeFloors.size>0))return!1;const m=p.globals.activeFloors;return c.some(y=>{const k=y.evaluate(p);return m.has(k)})}],id:[ti,[],p=>p.id()],zoom:[Dr,[],p=>p.globals.zoom],pitch:[Dr,[],p=>p.globals.pitch||0],"distance-from-center":[Dr,[],p=>p.distanceFromCenter()],"measure-light":[Dr,[va],(p,[c])=>p.measureLight(c.evaluate(p))],"heatmap-density":[Dr,[],p=>p.globals.heatmapDensity||0],"line-progress":[Dr,[],p=>p.globals.lineProgress||0],"raster-value":[Dr,[],p=>p.globals.rasterValue||0],"raster-particle-speed":[Dr,[],p=>p.globals.rasterParticleSpeed||0],"sky-radial-progress":[Dr,[],p=>p.globals.skyRadialProgress||0],accumulated:[ti,[],p=>p.globals.accumulated===void 0?null:p.globals.accumulated],"+":[Dr,nx(Dr),(p,c)=>{let m=0;for(const y of c)m+=y.evaluate(p);return m}],"*":[Dr,nx(Dr),(p,c)=>{let m=1;for(const y of c)m*=y.evaluate(p);return m}],"-":{type:Dr,overloads:[[[Dr,Dr],(p,[c,m])=>c.evaluate(p)-m.evaluate(p)],[[Dr],(p,[c])=>-c.evaluate(p)]]},"/":[Dr,[Dr,Dr],(p,[c,m])=>c.evaluate(p)/m.evaluate(p)],"%":[Dr,[Dr,Dr],(p,[c,m])=>c.evaluate(p)%m.evaluate(p)],ln2:[Dr,[],()=>Math.LN2],pi:[Dr,[],()=>Math.PI],e:[Dr,[],()=>Math.E],"^":[Dr,[Dr,Dr],(p,[c,m])=>Math.pow(c.evaluate(p),m.evaluate(p))],sqrt:[Dr,[Dr],(p,[c])=>Math.sqrt(c.evaluate(p))],log10:[Dr,[Dr],(p,[c])=>Math.log(c.evaluate(p))/Math.LN10],ln:[Dr,[Dr],(p,[c])=>Math.log(c.evaluate(p))],log2:[Dr,[Dr],(p,[c])=>Math.log2(c.evaluate(p))],sin:[Dr,[Dr],(p,[c])=>Math.sin(c.evaluate(p))],cos:[Dr,[Dr],(p,[c])=>Math.cos(c.evaluate(p))],tan:[Dr,[Dr],(p,[c])=>Math.tan(c.evaluate(p))],asin:[Dr,[Dr],(p,[c])=>Math.asin(c.evaluate(p))],acos:[Dr,[Dr],(p,[c])=>Math.acos(c.evaluate(p))],atan:[Dr,[Dr],(p,[c])=>Math.atan(c.evaluate(p))],min:[Dr,nx(Dr),(p,c)=>Math.min(...c.map(m=>m.evaluate(p)))],max:[Dr,nx(Dr),(p,c)=>Math.max(...c.map(m=>m.evaluate(p)))],abs:[Dr,[Dr],(p,[c])=>Math.abs(c.evaluate(p))],round:[Dr,[Dr],(p,[c])=>{const m=c.evaluate(p);return m<0?-Math.round(-m):Math.round(m)}],floor:[Dr,[Dr],(p,[c])=>Math.floor(c.evaluate(p))],ceil:[Dr,[Dr],(p,[c])=>Math.ceil(c.evaluate(p))],"filter-==":[di,[va,ti],(p,[c,m])=>p.properties()[c.value]===m.value],"filter-id-==":[di,[ti],(p,[c])=>p.id()===c.value],"filter-type-==":[di,[va],(p,[c])=>p.geometryType()===c.value],"filter-<":[di,[va,ti],(p,[c,m])=>{const y=p.properties()[c.value],k=m.value;return typeof y==typeof k&&y{const m=p.id(),y=c.value;return typeof m==typeof y&&m":[di,[va,ti],(p,[c,m])=>{const y=p.properties()[c.value],k=m.value;return typeof y==typeof k&&y>k}],"filter-id->":[di,[ti],(p,[c])=>{const m=p.id(),y=c.value;return typeof m==typeof y&&m>y}],"filter-<=":[di,[va,ti],(p,[c,m])=>{const y=p.properties()[c.value],k=m.value;return typeof y==typeof k&&y<=k}],"filter-id-<=":[di,[ti],(p,[c])=>{const m=p.id(),y=c.value;return typeof m==typeof y&&m<=y}],"filter->=":[di,[va,ti],(p,[c,m])=>{const y=p.properties()[c.value],k=m.value;return typeof y==typeof k&&y>=k}],"filter-id->=":[di,[ti],(p,[c])=>{const m=p.id(),y=c.value;return typeof m==typeof y&&m>=y}],"filter-has":[di,[ti],(p,[c])=>c.value in p.properties()],"filter-has-id":[di,[],p=>p.id()!==null&&p.id()!==void 0],"filter-type-in":[di,[cd(va)],(p,[c])=>c.value.indexOf(p.geometryType())>=0],"filter-id-in":[di,[cd(ti)],(p,[c])=>c.value.indexOf(p.id())>=0],"filter-in-small":[di,[va,cd(ti)],(p,[c,m])=>m.value.indexOf(p.properties()[c.value])>=0],"filter-in-large":[di,[va,cd(ti)],(p,[c,m])=>function(y,k,E,P){for(;E<=P;){const O=E+P>>1;if(k[O]===y)return!0;k[O]>y?P=O-1:E=O+1}return!1}(p.properties()[c.value],m.value,0,m.value.length-1)],all:{type:di,overloads:[[[di,di],(p,[c,m])=>c.evaluate(p)&&m.evaluate(p)],[nx(di),(p,c)=>{for(const m of c)if(!m.evaluate(p))return!1;return!0}]]},any:{type:di,overloads:[[[di,di],(p,[c,m])=>c.evaluate(p)||m.evaluate(p)],[nx(di),(p,c)=>{for(const m of c)if(m.evaluate(p))return!0;return!1}]]},"!":[di,[di],(p,[c])=>!c.evaluate(p)],"is-supported-script":[di,[va],(p,[c])=>{const m=p.globals&&p.globals.isSupportedScript;return!m||m(c.evaluate(p))}],upcase:[va,[va],(p,[c])=>c.evaluate(p).toUpperCase()],downcase:[va,[va],(p,[c])=>c.evaluate(p).toLowerCase()],concat:[va,nx(ti),(p,c)=>c.map(m=>em(m.evaluate(p))).join("")],"resolved-locale":[va,[iS],(p,[c])=>c.evaluate(p).resolvedLocale()],random:[Dr,[Dr,Dr,ti],(p,c)=>{const[m,y,k]=c.map(P=>P.evaluate(p));if(m>y||m===y)return m;let E;if(typeof k=="string")E=function(P){let O=0;if(P.length===0)return O;for(let B=0;BJSON.stringify(ee)).join(", ")}, but found ${JSON.stringify(J)} instead.`);return J}catch(J){const ee=J;return this._warningHistory[ee.message]||(this._warningHistory[ee.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${ee.message}`)),this._defaultValue}}}function hb(p){return Array.isArray(p)&&p.length>0&&typeof p[0]=="string"&&p[0]in gv}function ix(p,c,m,y,k){const E=new jS(gv,[],c?function(O){const B={color:xu,string:va,number:Dr,enum:va,boolean:di,formatted:X_,resolvedImage:Q_};return O.type==="array"?cd(B[O.value]||ti,O.length):B[O.type]}(c):void 0,void 0,void 0,m,y,k),P=E.parse(p,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?hD(new OS(P,c,m,y,k)):ax(E.errors)}class xv{constructor(c,m,y,k){this.kind=c,this._styleExpression=m,this.isLightConstant=y,this.isLineProgressConstant=k,this.isStateDependent=c!=="constant"&&!ab(m.expression),this.configDependencies=wy(m.expression),this.isIndoorDependent=IS(m.expression)}evaluateWithoutErrorHandling(c,m,y,k,E,P){return this._styleExpression.evaluateWithoutErrorHandling(c,m,y,k,E,P)}evaluate(c,m,y,k,E,P,O){return this._styleExpression.evaluate(c,m,y,k,E,P,void 0,void 0,O)}}class jy{constructor(c,m,y,k,E,P){this.kind=c,this.zoomStops=y,this._styleExpression=m,this.isStateDependent=c!=="camera"&&!ab(m.expression),this.isIndoorDependent=IS(m.expression),this.isLightConstant=E,this.isLineProgressConstant=P,this.configDependencies=wy(m.expression),this.interpolationType=k}evaluateWithoutErrorHandling(c,m,y,k,E,P){return this._styleExpression.evaluateWithoutErrorHandling(c,m,y,k,E,P)}evaluate(c,m,y,k,E,P){return this._styleExpression.evaluate(c,m,y,k,E,P)}interpolationFactor(c,m,y){return this.interpolationType?dh.interpolationFactor(this.interpolationType,c,m,y):0}}function uT(p,c,m,y,k){if((p=ix(p,c,m,y,k)).result==="error")return p;const E=p.value.expression,P=cv(E);if(!P&&!ub(c))return ax([new Jh("","data expressions not supported")]);const O=dv(E,["zoom","pitch","distance-from-center"]);if(!O&&!pD(c))return ax([new Jh("","zoom expressions not supported")]);const B=dv(E,["measure-light"]);if(!B&&!mD(c))return ax([new Jh("","measure-light expression not supported")]);const W=dv(E,["line-progress"]);if(!W&&!function(ne){return dT(ne.expression,"line-progress")}(c))return ax([new Jh("","line-progress expression not supported")]);const J=c.expression&&c.expression.relaxZoomRestriction,ee=$m(E);return ee||O||J?ee instanceof Jh?ax([ee]):ee instanceof dh&&!LS(c)?ax([new Jh("",'"interpolate" expressions cannot be used with this property')]):hD(ee?new jy(P&&W?"camera":"composite",p.value,ee.labels,ee instanceof dh?ee.interpolation:void 0,B,W):new xv(P&&W?"constant":"source",p.value,B,W)):ax([new Jh("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class RS{constructor(c,m){this._parameters=c,this._specification=m,Object.assign(this,gD(this._parameters,this._specification))}static deserialize(c){return new RS(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function $m(p){let c=null;if(p instanceof If)c=$m(p.result);else if(p instanceof lb){for(const m of p.args)if(c=$m(m),c)break}else(p instanceof ib||p instanceof dh)&&p.input instanceof Wd&&p.input.name==="zoom"&&(c=p);return c instanceof Jh||p.eachChild(m=>{const y=$m(m);y instanceof Jh?c=y:c&&y&&c!==y&&(c=new Jh("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var hT,vD,_D=function(){if(vD)return hT;vD=1,hT=c;var p=3;function c(m,y,k){var E=this.cells=[];if(m instanceof ArrayBuffer){this.arrayBuffer=m;var P=new Int32Array(this.arrayBuffer);m=P[0],this.d=(y=P[1])+2*(k=P[2]);for(var O=0;O=ne[we+0]&&E>=ne[we+1])?(B[ue]=!0,O.push(ee[ue])):B[ue]=!1}}},c.prototype._forEachCell=function(m,y,k,E,P,O,B,W){for(var J=this._convertToCellCoord(m),ee=this._convertToCellCoord(y),ne=this._convertToCellCoord(k),ie=this._convertToCellCoord(E),ue=J;ue<=ne;ue++)for(var we=ee;we<=ie;we++){var Ee=this.d*we+ue;if((!W||W(this._convertFromCellCoord(ue),this._convertFromCellCoord(we),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(we+1)))&&P.call(this,m,y,k,E,Ee,O,B,W))return}},c.prototype._convertFromCellCoord=function(m){return(m-this.padding)/this.scale},c.prototype._convertToCellCoord=function(m){return Math.max(0,Math.min(this.d-1,Math.floor(m*this.scale)+this.padding))},c.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var m=this.cells,y=p+this.cells.length+1+1,k=0,E=0;E=0||(k[E]=Lf(p[E],c)));p instanceof Error&&(k.message=p.message)}if(k.$name)throw new Error("$name property is reserved for worker serialization logic.");return y!=="Object"&&(k.$name=y),k}throw new Error("can't serialize object of type "+typeof p)}function ox(p){if(p==null||typeof p=="boolean"||typeof p=="number"||typeof p=="string"||p instanceof Boolean||p instanceof Number||p instanceof String||p instanceof Date||p instanceof RegExp||mb(p)||p instanceof ImageBitmap||ArrayBuffer.isView(p)||p instanceof ImageData)return p;if(Array.isArray(p))return p.map(ox);if(typeof p=="object"){const c=p.$name||"Object";if(c==="Map"){const k=p.entries||[],E=new Map;for(let P=0;Pp>=128&&p<=255,Arabic:p=>p>=1536&&p<=1791,"Arabic Supplement":p=>p>=1872&&p<=1919,"Arabic Extended-A":p=>p>=2208&&p<=2303,"Hangul Jamo":p=>p>=4352&&p<=4607,"Unified Canadian Aboriginal Syllabics":p=>p>=5120&&p<=5759,Khmer:p=>p>=6016&&p<=6143,"Unified Canadian Aboriginal Syllabics Extended":p=>p>=6320&&p<=6399,"General Punctuation":p=>p>=8192&&p<=8303,"Letterlike Symbols":p=>p>=8448&&p<=8527,"Number Forms":p=>p>=8528&&p<=8591,"Miscellaneous Technical":p=>p>=8960&&p<=9215,"Control Pictures":p=>p>=9216&&p<=9279,"Optical Character Recognition":p=>p>=9280&&p<=9311,"Enclosed Alphanumerics":p=>p>=9312&&p<=9471,"Geometric Shapes":p=>p>=9632&&p<=9727,"Miscellaneous Symbols":p=>p>=9728&&p<=9983,"Miscellaneous Symbols and Arrows":p=>p>=11008&&p<=11263,"CJK Radicals Supplement":p=>p>=11904&&p<=12031,"Kangxi Radicals":p=>p>=12032&&p<=12255,"Ideographic Description Characters":p=>p>=12272&&p<=12287,"CJK Symbols and Punctuation":p=>p>=12288&&p<=12351,Hiragana:p=>p>=12352&&p<=12447,Katakana:p=>p>=12448&&p<=12543,Bopomofo:p=>p>=12544&&p<=12591,"Hangul Compatibility Jamo":p=>p>=12592&&p<=12687,Kanbun:p=>p>=12688&&p<=12703,"Bopomofo Extended":p=>p>=12704&&p<=12735,"CJK Strokes":p=>p>=12736&&p<=12783,"Katakana Phonetic Extensions":p=>p>=12784&&p<=12799,"Enclosed CJK Letters and Months":p=>p>=12800&&p<=13055,"CJK Compatibility":p=>p>=13056&&p<=13311,"CJK Unified Ideographs Extension A":p=>p>=13312&&p<=19903,"Yijing Hexagram Symbols":p=>p>=19904&&p<=19967,"CJK Unified Ideographs":p=>p>=19968&&p<=40959,"Yi Syllables":p=>p>=40960&&p<=42127,"Yi Radicals":p=>p>=42128&&p<=42191,"Hangul Jamo Extended-A":p=>p>=43360&&p<=43391,"Hangul Syllables":p=>p>=44032&&p<=55215,"Hangul Jamo Extended-B":p=>p>=55216&&p<=55295,"Private Use Area":p=>p>=57344&&p<=63743,"CJK Compatibility Ideographs":p=>p>=63744&&p<=64255,"Arabic Presentation Forms-A":p=>p>=64336&&p<=65023,"Vertical Forms":p=>p>=65040&&p<=65055,"CJK Compatibility Forms":p=>p>=65072&&p<=65103,"Small Form Variants":p=>p>=65104&&p<=65135,"Arabic Presentation Forms-B":p=>p>=65136&&p<=65279,"Halfwidth and Fullwidth Forms":p=>p>=65280&&p<=65519,Osage:p=>p>=66736&&p<=66815,"CJK Unified Ideographs Extension B":p=>p>=131072&&p<=173791};function pb(p){for(const c of p)if(FS(c.charCodeAt(0)))return!0;return!1}function mT(p){for(const c of p)if(!bD(c.charCodeAt(0)))return!1;return!0}function bD(p){return!(Zr.Arabic(p)||Zr["Arabic Supplement"](p)||Zr["Arabic Extended-A"](p)||Zr["Arabic Presentation Forms-A"](p)||Zr["Arabic Presentation Forms-B"](p))}function FS(p){return!(p!==746&&p!==747&&(p<4352||!(Zr["Bopomofo Extended"](p)||Zr.Bopomofo(p)||Zr["CJK Compatibility Forms"](p)&&!(p>=65097&&p<=65103)||Zr["CJK Compatibility Ideographs"](p)||Zr["CJK Compatibility"](p)||Zr["CJK Radicals Supplement"](p)||Zr["CJK Strokes"](p)||!(!Zr["CJK Symbols and Punctuation"](p)||p>=12296&&p<=12305||p>=12308&&p<=12319||p===12336)||Zr["CJK Unified Ideographs Extension A"](p)||Zr["CJK Unified Ideographs"](p)||Zr["Enclosed CJK Letters and Months"](p)||Zr["Hangul Compatibility Jamo"](p)||Zr["Hangul Jamo Extended-A"](p)||Zr["Hangul Jamo Extended-B"](p)||Zr["Hangul Jamo"](p)||Zr["Hangul Syllables"](p)||Zr.Hiragana(p)||Zr["Ideographic Description Characters"](p)||Zr.Kanbun(p)||Zr["Kangxi Radicals"](p)||Zr["Katakana Phonetic Extensions"](p)||Zr.Katakana(p)&&p!==12540||!(!Zr["Halfwidth and Fullwidth Forms"](p)||p===65288||p===65289||p===65293||p>=65306&&p<=65310||p===65339||p===65341||p===65343||p>=65371&&p<=65503||p===65507||p>=65512&&p<=65519)||!(!Zr["Small Form Variants"](p)||p>=65112&&p<=65118||p>=65123&&p<=65126)||Zr["Unified Canadian Aboriginal Syllabics"](p)||Zr["Unified Canadian Aboriginal Syllabics Extended"](p)||Zr["Vertical Forms"](p)||Zr["Yijing Hexagram Symbols"](p)||Zr["Yi Syllables"](p)||Zr["Yi Radicals"](p))))}function zS(p){return!(FS(p)||function(c){return!!(Zr["Latin-1 Supplement"](c)&&(c===167||c===169||c===174||c===177||c===188||c===189||c===190||c===215||c===247)||Zr["General Punctuation"](c)&&(c===8214||c===8224||c===8225||c===8240||c===8241||c===8251||c===8252||c===8258||c===8263||c===8264||c===8265||c===8273)||Zr["Letterlike Symbols"](c)||Zr["Number Forms"](c)||Zr["Miscellaneous Technical"](c)&&(c>=8960&&c<=8967||c>=8972&&c<=8991||c>=8996&&c<=9e3||c===9003||c>=9085&&c<=9114||c>=9150&&c<=9165||c===9167||c>=9169&&c<=9179||c>=9186&&c<=9215)||Zr["Control Pictures"](c)&&c!==9251||Zr["Optical Character Recognition"](c)||Zr["Enclosed Alphanumerics"](c)||Zr["Geometric Shapes"](c)||Zr["Miscellaneous Symbols"](c)&&!(c>=9754&&c<=9759)||Zr["Miscellaneous Symbols and Arrows"](c)&&(c>=11026&&c<=11055||c>=11088&&c<=11097||c>=11192&&c<=11243)||Zr["CJK Symbols and Punctuation"](c)||Zr.Katakana(c)||Zr["Private Use Area"](c)||Zr["CJK Compatibility Forms"](c)||Zr["Small Form Variants"](c)||Zr["Halfwidth and Fullwidth Forms"](c)||c===8734||c===8756||c===8757||c>=9984&&c<=10087||c>=10102&&c<=10131||c===65532||c===65533)}(p))}function BS(p){return Zr.Arabic(p)||Zr["Arabic Supplement"](p)||Zr["Arabic Extended-A"](p)||Zr["Arabic Presentation Forms-A"](p)||Zr["Arabic Presentation Forms-B"](p)}function pT(p){return p>=1424&&p<=2303||Zr["Arabic Presentation Forms-A"](p)||Zr["Arabic Presentation Forms-B"](p)}function Df(p,c){return!(!c&&pT(p)||p>=2304&&p<=3583||p>=3840&&p<=4255||Zr.Khmer(p))}function Bce(p){for(const c of p)if(pT(c.charCodeAt(0)))return!0;return!1}const Fu={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let fT=null,Gd=Fu.unavailable,Of=null;const fb=function(p){p&&typeof p=="string"&&p.indexOf("NetworkError")>-1&&(Gd=Fu.error),fT&&fT(p)};function $S(){qS.fire(new Qh("pluginStateChange",{pluginStatus:Gd,pluginURL:Of}))}const qS=new Ns,gb=function(){return Gd},wD=function(){if(Gd!==Fu.deferred||!Of)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Gd=Fu.loading,$S(),Of&&Ru({url:Of},p=>{p?fb(p):(Gd=Fu.loaded,$S())})},Rf={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Gd===Fu.loaded||Rf.applyArabicShaping!=null,isLoading:()=>Gd===Fu.loading,setState(p){Gd=p.pluginStatus,Of=p.pluginURL},isParsing:()=>Gd===Fu.parsing,isParsed:()=>Gd===Fu.parsed,getPluginURL:()=>Of};class Ii{constructor(c,m){this.zoom=c,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(c){return function(m,y){for(const k of m)if(!Df(k.charCodeAt(0),y))return!1;return!0}(c,Rf.isLoaded())}}class US{constructor(c,m,y,k,E){this.property=c,this.value=m,this.expression=function(P,O,B,W,J){if(DS(P))return new RS(P,O);if(hb(P)||Array.isArray(P)&&P.length>0){const ee=uT(P,O,B,W,J);if(ee.result==="error")throw new Error(ee.value.map(ne=>`${ne.key}: ${ne.message}`).join(", "));return ee.value}{let ee=P;return typeof P=="string"&&O.type==="color"&&(ee=Fr.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>ee}}}(m===void 0?c.specification.default:m,c.specification,y,k,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(c,m,y,k){return this.property.possiblyEvaluate(this,c,m,y,k)}}class gT{constructor(c,m,y,k){this.property=c,this.value=new US(c,void 0,m,y,k)}transitioned(c,m){return new kD(this.property,this.value,m,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new kD(this.property,this.value,null,{},0)}}class jD{constructor(c,m,y,k){this._properties=c,this._values=Object.create(c.defaultTransitionablePropertyValues),this._scope=m,this._options=y,this._iconImageUseTheme=k,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(c){return xs(this._values[c].value.value)}setValue(c,m){this._values.hasOwnProperty(c)||(this._values[c]=new gT(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new US(this._values[c].property,m===null?void 0:xs(m),this._scope,this._options,this._iconImageUseTheme),this._values[c].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[c].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[c].value.isIndoorDependent())}setTransitionOrValue(c,m){m&&(this._options=m);const y=this._properties.properties;if(c)for(const k in c){const E=c[k];if(k.endsWith("-transition")){const P=k.slice(0,-11);y[P]&&this.setTransition(P,E)}else y.hasOwnProperty(k)&&this.setValue(k,E)}}getTransition(c){return xs(this._values[c].transition)}setTransition(c,m){this._values.hasOwnProperty(c)||(this._values[c]=new gT(this._values[c].property)),this._values[c].transition=xs(m)||void 0}serialize(){const c={};for(const m of Object.keys(this._values)){const y=this.getValue(m);y!==void 0&&(c[m]=y);const k=this.getTransition(m);k!==void 0&&(c[`${m}-transition`]=k)}return c}transitioned(c,m){const y=new ND(this._properties);for(const k of Object.keys(this._values))y._values[k]=this._values[k].transitioned(c,m._values[k]);return y}untransitioned(){const c=new ND(this._properties);for(const m of Object.keys(this._values))c._values[m]=this._values[m].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class kD{constructor(c,m,y,k,E){const P=k.delay||0,O=k.duration||0;E=E||0,this.property=c,this.value=m,this.begin=E+P,this.end=this.begin+O,c.specification.transition&&(k.delay||k.duration)&&(this.prior=y)}possiblyEvaluate(c,m,y){const k=c.now||0,E=this.value.possiblyEvaluate(c,m,y),P=this.prior;if(P){if(k>this.end)return this.prior=null,E;if(this.value.isDataDriven())return this.prior=null,E;if(k":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 CD(p){return p instanceof Number||p instanceof String||p instanceof Boolean?p.valueOf():p}function VS(p){if(Array.isArray(p))return p.map(VS);if(p instanceof Object&&!(p instanceof Number||p instanceof String||p instanceof Boolean)){const c={};for(const m in p)c[m]=VS(p[m]);return c}return CD(p)}function Pp(p){if(p===!0||p===!1)return!0;if(!Array.isArray(p)||p.length===0)return!1;switch(p[0]){case"has":return p.length>=2&&p[1]!=="$id"&&p[1]!=="$type";case"in":return p.length>=3&&(typeof p[1]!="string"||Array.isArray(p[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return p.length!==3||Array.isArray(p[1])||Array.isArray(p[2]);case"any":case"all":for(const c of p.slice(1))if(!Pp(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function HS(p,c="",m=null,y="fill"){if(p==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Pp(p)||(p=WS(p));const k=p;let E=!0;try{E=function(J){if(!vv(J))return J;let ee=VS(J);return MD(ee),ee=My(ee),ee}(k)}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(k,null,2)} `)}let P=null,O=null;if(y!=="background"&&y!=="sky"&&y!=="slot"){O=Gt[`filter_${y}`];const J=ix(E,O,c,m);if(J.result==="error")throw new Error(J.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));P=(ee,ne,ie)=>J.value.evaluate(ee,ne,{},ie)}let B=null,W=null;if(E!==k){const J=ix(k,O,c,m);if(J.result==="error")throw new Error(J.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));B=(ee,ne,ie,ue,we)=>J.value.evaluate(ee,ne,{},ie,void 0,void 0,ue,we),W=!cv(J.value.expression)}return{filter:P,dynamicFilter:B||void 0,needGeometry:TD(E),needFeature:!!W}}function My(p){if(!Array.isArray(p))return p;const c=function(m){if($ce.has(m[0])){for(let y=1;yMy(m))}function MD(p){let c=!1;const m=[];if(p[0]==="case"){for(let y=1;y",">=","<","<=","to-boolean"]);function qce(p,c){return pc?1:0}function TD(p){if(!Array.isArray(p))return!1;if(p[0]==="within"||p[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?GS(p[1],p[2],c):c==="any"?(m=p.slice(1),["any"].concat(m.map(WS))):c==="all"?["all"].concat(p.slice(1).map(WS)):c==="none"?["all"].concat(p.slice(1).map(WS).map(xb)):c==="in"?KS(p[1],p.slice(2)):c==="!in"?xb(KS(p[1],p.slice(2))):c==="has"?ZS(p[1]):c!=="!has"||xb(ZS(p[1]));var m}function GS(p,c,m){switch(p){case"$type":return[`filter-type-${m}`,c];case"$id":return[`filter-id-${m}`,c];default:return[`filter-${m}`,p,c]}}function KS(p,c){if(c.length===0)return!1;switch(p){case"$type":return["filter-type-in",["literal",c]];case"$id":return["filter-id-in",["literal",c]];default:return c.length>200&&!c.some(m=>typeof m!=typeof c[0])?["filter-in-large",p,["literal",c.sort(qce)]]:["filter-in-small",p,["literal",c]]}}function ZS(p){switch(p){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",p]}}function xb(p){return["!",p]}const Ty="";function qm(p,c){return c?`${p}${Ty}${c}`:p}let AD;const ED=()=>AD||(AD=new _o({"icon-size":new sr(Gt.layout_symbol["icon-size"]),"icon-image":new sr(Gt.layout_symbol["icon-image"]),"icon-rotate":new sr(Gt.layout_symbol["icon-rotate"]),"icon-offset":new sr(Gt.layout_symbol["icon-offset"]),"text-size":new sr(Gt.layout_symbol["text-size"]),"text-rotate":new sr(Gt.layout_symbol["text-rotate"]),"text-offset":new sr(Gt.layout_symbol["text-offset"])}));class PD{constructor(c,m,y,k,E,P){const O=ix(c,Gt.appearance.condition);if(O.result==="success"&&(this.condition=O.value),this.name=m,y){this.properties=new Sy(ED()),this.unevaluatedLayout=new SD(ED(),k,E,P);for(const B in y)this.unevaluatedLayout.setValue(B,y[B])}}isActive(c){return!(this.condition||!c.isHidden||this.name!=="hidden")||this.condition.evaluate(c.globals,c.feature,c.featureState,c.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(c){return this.properties.get(c)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(c){return this.unevaluatedLayout._values[c]}recalculate(c,m,y){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(c,void 0,m,y))}serialize(){const c={};return c.condition=this.condition.expression.serialize(),this.name&&(c.name=this.name),this.unevaluatedLayout&&(c.properties=this.unevaluatedLayout.serialize()),c}hasIconProperties(){const c=this.hasProperty("icon-image"),m=this.hasProperty("icon-size"),y=this.hasProperty("icon-offset"),k=this.hasProperty("icon-rotate");return c||m||y||k}hasTextProperties(){const c=this.hasProperty("text-size"),m=this.hasProperty("text-offset"),y=this.hasProperty("text-rotate");return c||m||y}hasProperty(c){return this.getUnevaluatedProperty(c).value!==void 0}}const ID="-transition",Ip=new Set(["fill","line","background","hillshade","raster"]);class Kd extends Ns{constructor(c,m,y,k,E,P){if(super(),this.id=c.id,this.fqid=qm(this.id,y),this.type=c.type,this.scope=y,this.lut=k,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},c.type!=="custom"){if(this.metadata=c.metadata,this.minzoom=c.minzoom,this.maxzoom=c.maxzoom,c.type&&c.type!=="background"&&c.type!=="sky"&&c.type!=="slot"){this.source=c.source,this.sourceLayer=c["source-layer"],this.filter=c.filter;const O=ix(this.filter,Gt[`filter_${c.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(c.slot&&(this.slot=c.slot),c.appearances&&this.setAppearances(c.appearances),m.layout&&(this._unevaluatedLayout=new SD(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 jD(m.paint,this.scope,E);for(const O in c.paint)this.setPaintProperty(O,c.paint[O]);for(const O in c.layout)this.setLayoutProperty(O,c.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 Sy(m.paint)}}}onAdd(c){}onRemove(c){}isDraped(c){return!this.is3D(!0)&&Ip.has(this.type)}getLayoutProperty(c){return c==="visibility"?this.visibility:this._unevaluatedLayout.getValue(c)}setLayoutProperty(c,m){if(this.type==="custom"&&c==="visibility")return void(this.visibility=m);const y=this._unevaluatedLayout;y._properties.properties[c]&&(y.setValue(c,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...y.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||y.isIndoorDependent(),c==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(c){this.appearances=[],c.forEach(m=>{this.appearances.push(new PD(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(c){return c.endsWith(ID)?this._transitionablePaint.getTransition(c.slice(0,-11)):this._transitionablePaint.getValue(c)}isPaintProperty(c){return!!this._transitionablePaint._properties.properties[c]}setPaintProperty(c,m){const y=this._transitionablePaint,k=y._properties.properties;if(c.endsWith(ID)){const ee=c.slice(0,-11);return k[ee]&&y.setTransition(ee,m||void 0),!1}if(!k[c])return!1;const E=y._values[c],P=E.value.isDataDriven(),O=E.value;y.setValue(c,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...y.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||y.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(c);const B=y._values[c].value,W=B.isDataDriven(),J=c.endsWith("pattern")||c==="line-dasharray";return W||P||J||this._handleOverridablePaintPropertyUpdate(c,O,B)}_handleSpecialPaintPropertyUpdate(c){}getProgramIds(){return null}getDefaultProgramParams(c,m,y){return null}_handleOverridablePaintPropertyUpdate(c,m,y){return!1}isHidden(c){return!!(this.minzoom&&c=this.maxzoom)||this.visibility==="none"}updateTransitions(c){this._transitioningPaint=this._transitionablePaint.transitioned(c,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(c,m){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(c,void 0,m,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(c,void 0,m)}serialize(){const c={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&&(c.appearances=this.appearances.map(m=>m.serialize())),Ps(c,(m,y)=>!(m===void 0||y==="layout"&&!Object.keys(m).length||y==="paint"&&!Object.keys(m).length))}is3D(c){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 c in this.paint._values){const m=this.paint.get(c);if(m instanceof Ny&&ub(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const c of this.appearances)if(!ab(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=HS(this.filter,this.scope,c),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(c){this._stats&&(c.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(c,m,y){return{}}queryRadius(c){}queryIntersectsFeature(c,m,y,k,E,P,O,B,W){}}const LD={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class yb{constructor(c,m){this._structArray=c,this._pos1=m*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Uce=new ArrayBuffer(0);class Ui{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(c,m){return c._trim(),m&&c.arrayBuffer&&m.add(c.arrayBuffer),{length:c.length,arrayBuffer:c.arrayBuffer}}static deserialize(c){const m=Object.create(this.prototype);return m.arrayBuffer=c.arrayBuffer,m.length=c.length,c.arrayBuffer?m.capacity=c.arrayBuffer.byteLength/m.bytesPerElement:(m.capacity=0,m.arrayBuffer=Uce),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(c){this.reserve(c),this.length=c}reserve(c){if(c>this.capacity){this._reallocCount++,this.capacity=Math.max(c,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(c){this.reserve(this.length+c)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...c){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...c){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 ra(p,c=1){let m=0,y=0;return{members:p.map(k=>{const E=LD[k.type].BYTES_PER_ELEMENT,P=m=DD(m,Math.max(c,E)),O=k.components||1;return y=Math.max(y,E),m+=E*O,{name:k.name,type:k.type,components:O,offset:P}}),size:DD(m,Math.max(y,c)),alignment:c}}function DD(p,c){return Math.ceil(p/c)*c}class lx extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m){const y=this.length;return this.resize(y+1),this.emplace(y,c,m)}emplace(c,m,y){const k=2*c;return this.int16[k+0]=m,this.int16[k+1]=y,c}}lx.prototype.bytesPerElement=4,vr(lx,"StructArrayLayout2i4");class _v extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=3*c;return this.int16[E+0]=m,this.int16[E+1]=y,this.int16[E+2]=k,c}}_v.prototype.bytesPerElement=6,vr(_v,"StructArrayLayout3i6");class bv extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,y,k)}emplace(c,m,y,k,E){const P=4*c;return this.int16[P+0]=m,this.int16[P+1]=y,this.int16[P+2]=k,this.int16[P+3]=E,c}}bv.prototype.bytesPerElement=8,vr(bv,"StructArrayLayout4i8");class Ff extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.float32[1*c+0]=m,c}}Ff.prototype.bytesPerElement=4,vr(Ff,"StructArrayLayout1f4");class xT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=4*c,P=2*c;return this.int16[E+0]=m,this.int16[E+1]=y,this.float32[P+1]=k,c}}xT.prototype.bytesPerElement=8,vr(xT,"StructArrayLayout2i1f8");class yT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=4*c;return this.int16[E+0]=m,this.int16[E+1]=y,this.int16[E+2]=k,c}}yT.prototype.bytesPerElement=8,vr(yT,"StructArrayLayout3i8");class vT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,y,k,E)}emplace(c,m,y,k,E,P){const O=5*c;return this.int16[O+0]=m,this.int16[O+1]=y,this.int16[O+2]=k,this.int16[O+3]=E,this.int16[O+4]=P,c}}vT.prototype.bytesPerElement=10,vr(vT,"StructArrayLayout5i10");class YS extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,y,k,E,P,O)}emplace(c,m,y,k,E,P,O,B){const W=6*c,J=12*c,ee=3*c;return this.int16[W+0]=m,this.int16[W+1]=y,this.uint8[J+4]=k,this.uint8[J+5]=E,this.uint8[J+6]=P,this.uint8[J+7]=O,this.float32[ee+2]=B,c}}YS.prototype.bytesPerElement=12,vr(YS,"StructArrayLayout2i4ub1f12");class uh extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=3*c;return this.float32[E+0]=m,this.float32[E+1]=y,this.float32[E+2]=k,c}}uh.prototype.bytesPerElement=12,vr(uh,"StructArrayLayout3f12");class yu extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,y,k,E)}emplace(c,m,y,k,E,P){const O=6*c,B=3*c;return this.uint16[O+0]=m,this.uint16[O+1]=y,this.uint16[O+2]=k,this.uint16[O+3]=E,this.float32[B+2]=P,c}}yu.prototype.bytesPerElement=12,vr(yu,"StructArrayLayout4ui1f12");class Ay extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,k){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,y,k)}emplace(c,m,y,k,E){const P=4*c;return this.uint16[P+0]=m,this.uint16[P+1]=y,this.uint16[P+2]=k,this.uint16[P+3]=E,c}}Ay.prototype.bytesPerElement=8,vr(Ay,"StructArrayLayout4ui8");class XS extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,k,E,P)}emplace(c,m,y,k,E,P,O){const B=6*c;return this.int16[B+0]=m,this.int16[B+1]=y,this.int16[B+2]=k,this.int16[B+3]=E,this.int16[B+4]=P,this.int16[B+5]=O,c}}XS.prototype.bytesPerElement=12,vr(XS,"StructArrayLayout6i12");class _T extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O,B,W,J,ee,ne){const ie=this.length;return this.resize(ie+1),this.emplace(ie,c,m,y,k,E,P,O,B,W,J,ee,ne)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ie){const ue=12*c;return this.int16[ue+0]=m,this.int16[ue+1]=y,this.int16[ue+2]=k,this.int16[ue+3]=E,this.uint16[ue+4]=P,this.uint16[ue+5]=O,this.uint16[ue+6]=B,this.uint16[ue+7]=W,this.int16[ue+8]=J,this.int16[ue+9]=ee,this.int16[ue+10]=ne,this.int16[ue+11]=ie,c}}_T.prototype.bytesPerElement=24,vr(_T,"StructArrayLayout4i4ui4i24");class bT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,k,E,P)}emplace(c,m,y,k,E,P,O){const B=10*c,W=5*c;return this.int16[B+0]=m,this.int16[B+1]=y,this.int16[B+2]=k,this.float32[W+2]=E,this.float32[W+3]=P,this.float32[W+4]=O,c}}bT.prototype.bytesPerElement=20,vr(bT,"StructArrayLayout3i3f20");class cx extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,y,k)}emplace(c,m,y,k,E){const P=4*c;return this.float32[P+0]=m,this.float32[P+1]=y,this.float32[P+2]=k,this.float32[P+3]=E,c}}cx.prototype.bytesPerElement=16,vr(cx,"StructArrayLayout4f16");class QS extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.uint32[1*c+0]=m,c}}QS.prototype.bytesPerElement=4,vr(QS,"StructArrayLayout1ul4");class hh extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m){const y=this.length;return this.resize(y+1),this.emplace(y,c,m)}emplace(c,m,y){const k=2*c;return this.uint16[k+0]=m,this.uint16[k+1]=y,c}}hh.prototype.bytesPerElement=4,vr(hh,"StructArrayLayout2ui4");class JS extends Ui{_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(c,m,y,k,E,P,O,B,W,J,ee,ne,ie){const ue=this.length;return this.resize(ue+1),this.emplace(ue,c,m,y,k,E,P,O,B,W,J,ee,ne,ie)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue){const we=20*c,Ee=10*c;return this.int16[we+0]=m,this.int16[we+1]=y,this.int16[we+2]=k,this.int16[we+3]=E,this.int16[we+4]=P,this.float32[Ee+3]=O,this.float32[Ee+4]=B,this.float32[Ee+5]=W,this.float32[Ee+6]=J,this.int16[we+14]=ee,this.uint32[Ee+8]=ne,this.uint16[we+18]=ie,this.uint16[we+19]=ue,c}}JS.prototype.bytesPerElement=40,vr(JS,"StructArrayLayout5i4f1i1ul2ui40");class eC extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,y,k,E,P,O)}emplace(c,m,y,k,E,P,O,B){const W=8*c;return this.int16[W+0]=m,this.int16[W+1]=y,this.int16[W+2]=k,this.int16[W+4]=E,this.int16[W+5]=P,this.int16[W+6]=O,this.int16[W+7]=B,c}}eC.prototype.bytesPerElement=16,vr(eC,"StructArrayLayout3i2i2i16");class tC extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,y,k,E)}emplace(c,m,y,k,E,P){const O=4*c,B=8*c;return this.float32[O+0]=m,this.float32[O+1]=y,this.float32[O+2]=k,this.int16[B+6]=E,this.int16[B+7]=P,c}}tC.prototype.bytesPerElement=16,vr(tC,"StructArrayLayout2f1f2i16");class wT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,k,E,P)}emplace(c,m,y,k,E,P,O){const B=20*c,W=5*c;return this.uint8[B+0]=m,this.uint8[B+1]=y,this.float32[W+1]=k,this.float32[W+2]=E,this.float32[W+3]=P,this.float32[W+4]=O,c}}wT.prototype.bytesPerElement=20,vr(wT,"StructArrayLayout2ub4f20");class yl extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=3*c;return this.uint16[E+0]=m,this.uint16[E+1]=y,this.uint16[E+2]=k,c}}yl.prototype.bytesPerElement=6,vr(yl,"StructArrayLayout3ui6");class wv extends Ui{_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(c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue,Ye,st,_t){const ft=this.length;return this.resize(ft+1),this.emplace(ft,c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue,Ye,st,_t)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue,Ye,st,_t,ft){const St=30*c,Pt=15*c,Ft=60*c;return this.int16[St+0]=m,this.int16[St+1]=y,this.int16[St+2]=k,this.float32[Pt+2]=E,this.float32[Pt+3]=P,this.uint16[St+8]=O,this.uint16[St+9]=B,this.uint32[Pt+5]=W,this.uint32[Pt+6]=J,this.uint32[Pt+7]=ee,this.uint16[St+16]=ne,this.uint16[St+17]=ie,this.uint16[St+18]=ue,this.float32[Pt+10]=we,this.float32[Pt+11]=Ee,this.uint8[Ft+48]=Te,this.uint8[Ft+49]=Ue,this.uint8[Ft+50]=Ye,this.uint32[Pt+13]=st,this.int16[St+28]=_t,this.uint8[Ft+58]=ft,c}}wv.prototype.bytesPerElement=60,vr(wv,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class jT extends Ui{_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(c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue,Ye,st,_t,ft,St,Pt,Ft,ns,Wt,hs,ys,vs,Ds,Fs,Es){const Is=this.length;return this.resize(Is+1),this.emplace(Is,c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue,Ye,st,_t,ft,St,Pt,Ft,ns,Wt,hs,ys,vs,Ds,Fs,Es)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue,Ye,st,_t,ft,St,Pt,Ft,ns,Wt,hs,ys,vs,Ds,Fs,Es,Is){const us=20*c,as=40*c,Ls=80*c;return this.float32[us+0]=m,this.float32[us+1]=y,this.int16[as+4]=k,this.int16[as+5]=E,this.int16[as+6]=P,this.int16[as+7]=O,this.int16[as+8]=B,this.int16[as+9]=W,this.int16[as+10]=J,this.int16[as+11]=ee,this.int16[as+12]=ne,this.uint16[as+13]=ie,this.uint16[as+14]=ue,this.uint16[as+15]=we,this.uint16[as+16]=Ee,this.uint16[as+17]=Te,this.uint16[as+18]=Ue,this.uint16[as+19]=Ye,this.uint16[as+20]=st,this.uint16[as+21]=_t,this.uint16[as+22]=ft,this.uint16[as+23]=St,this.uint16[as+24]=Pt,this.uint16[as+25]=Ft,this.uint16[as+26]=ns,this.uint16[as+27]=Wt,this.uint32[us+14]=hs,this.float32[us+15]=ys,this.float32[us+16]=vs,this.float32[us+17]=Ds,this.float32[us+18]=Fs,this.uint8[Ls+76]=Es,this.uint16[as+39]=Is,c}}jT.prototype.bytesPerElement=80,vr(jT,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class kT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,k,E,P)}emplace(c,m,y,k,E,P,O){const B=6*c;return this.float32[B+0]=m,this.float32[B+1]=y,this.float32[B+2]=k,this.float32[B+3]=E,this.float32[B+4]=P,this.float32[B+5]=O,c}}kT.prototype.bytesPerElement=24,vr(kT,"StructArrayLayout6f24");class Ey extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,y,k,E)}emplace(c,m,y,k,E,P){const O=5*c;return this.float32[O+0]=m,this.float32[O+1]=y,this.float32[O+2]=k,this.float32[O+3]=E,this.float32[O+4]=P,c}}Ey.prototype.bytesPerElement=20,vr(Ey,"StructArrayLayout5f20");class NT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,y,k,E,P,O)}emplace(c,m,y,k,E,P,O,B){const W=7*c;return this.float32[W+0]=m,this.float32[W+1]=y,this.float32[W+2]=k,this.float32[W+3]=E,this.float32[W+4]=P,this.float32[W+5]=O,this.float32[W+6]=B,c}}NT.prototype.bytesPerElement=28,vr(NT,"StructArrayLayout7f28");class ST extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O,B,W,J,ee){const ne=this.length;return this.resize(ne+1),this.emplace(ne,c,m,y,k,E,P,O,B,W,J,ee)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne){const ie=11*c;return this.float32[ie+0]=m,this.float32[ie+1]=y,this.float32[ie+2]=k,this.float32[ie+3]=E,this.float32[ie+4]=P,this.float32[ie+5]=O,this.float32[ie+6]=B,this.float32[ie+7]=W,this.float32[ie+8]=J,this.float32[ie+9]=ee,this.float32[ie+10]=ne,c}}ST.prototype.bytesPerElement=44,vr(ST,"StructArrayLayout11f44");class jv extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O,B,W){const J=this.length;return this.resize(J+1),this.emplace(J,c,m,y,k,E,P,O,B,W)}emplace(c,m,y,k,E,P,O,B,W,J){const ee=9*c;return this.float32[ee+0]=m,this.float32[ee+1]=y,this.float32[ee+2]=k,this.float32[ee+3]=E,this.float32[ee+4]=P,this.float32[ee+5]=O,this.float32[ee+6]=B,this.float32[ee+7]=W,this.float32[ee+8]=J,c}}jv.prototype.bytesPerElement=36,vr(jv,"StructArrayLayout9f36");class Lp extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m){const y=this.length;return this.resize(y+1),this.emplace(y,c,m)}emplace(c,m,y){const k=2*c;return this.float32[k+0]=m,this.float32[k+1]=y,c}}Lp.prototype.bytesPerElement=8,vr(Lp,"StructArrayLayout2f8");class vu extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,k){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,y,k)}emplace(c,m,y,k,E){const P=6*c;return this.uint32[3*c+0]=m,this.uint16[P+2]=y,this.uint16[P+3]=k,this.uint16[P+4]=E,c}}vu.prototype.bytesPerElement=12,vr(vu,"StructArrayLayout1ul3ui12");class dx extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.uint16[1*c+0]=m,c}}dx.prototype.bytesPerElement=2,vr(dx,"StructArrayLayout1ui2");class CT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee){const Te=this.length;return this.resize(Te+1),this.emplace(Te,c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te){const Ue=16*c;return this.float32[Ue+0]=m,this.float32[Ue+1]=y,this.float32[Ue+2]=k,this.float32[Ue+3]=E,this.float32[Ue+4]=P,this.float32[Ue+5]=O,this.float32[Ue+6]=B,this.float32[Ue+7]=W,this.float32[Ue+8]=J,this.float32[Ue+9]=ee,this.float32[Ue+10]=ne,this.float32[Ue+11]=ie,this.float32[Ue+12]=ue,this.float32[Ue+13]=we,this.float32[Ue+14]=Ee,this.float32[Ue+15]=Te,c}}CT.prototype.bytesPerElement=64,vr(CT,"StructArrayLayout16f64");class sC extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,y,k,E,P,O)}emplace(c,m,y,k,E,P,O,B){const W=10*c,J=5*c;return this.uint16[W+0]=m,this.uint16[W+1]=y,this.uint16[W+2]=k,this.uint16[W+3]=E,this.float32[J+2]=P,this.float32[J+3]=O,this.float32[J+4]=B,c}}sC.prototype.bytesPerElement=20,vr(sC,"StructArrayLayout4ui3f20");class MT extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.int16[1*c+0]=m,c}}MT.prototype.bytesPerElement=2,vr(MT,"StructArrayLayout1i2");class rC extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.uint8[1*c+0]=m,c}}rC.prototype.bytesPerElement=1,vr(rC,"StructArrayLayout1ub1");class nC extends yb{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]}}nC.prototype.size=40;class OD extends JS{get(c){return new nC(this,c)}}vr(OD,"CollisionBoxArray");class aC extends yb{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(c){this._structArray.uint8[this._pos1+49]=c}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(c){this._structArray.uint8[this._pos1+50]=c}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(c){this._structArray.uint32[this._pos4+13]=c}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(c){this._structArray.uint8[this._pos1+58]=c}}aC.prototype.size=60;class RD extends wv{get(c){return new aC(this,c)}}vr(RD,"PlacedSymbolArray");class FD extends yb{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(c){this._structArray.uint32[this._pos4+14]=c}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(c){this._structArray.float32[this._pos4+18]=c}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}FD.prototype.size=80;class TT extends jT{get(c){return new FD(this,c)}}vr(TT,"SymbolInstanceArray");class iC extends Ff{getoffsetX(c){return this.float32[1*c+0]}}vr(iC,"GlyphOffsetArray");class zD extends lx{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}vr(zD,"SymbolLineVertexArray");class AT extends yb{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]}}AT.prototype.size=12;class ET extends vu{get(c){return new AT(this,c)}}vr(ET,"FeatureIndexArray");class BD extends hh{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}vr(BD,"FillExtrusionCentroidArray");class oC extends yb{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]}}oC.prototype.size=6;class vb extends _v{get(c){return new oC(this,c)}}vr(vb,"FillExtrusionWallArray");const $D=ra([{name:"a_pos",components:2,type:"Int16"}],4),Vce=ra([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),qD=ra([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class io{constructor(c=[]){this.segments=c}_prepareSegment(c,m,y,k){let E=this.segments[this.segments.length-1];return c>io.MAX_VERTEX_ARRAY_LENGTH&&cr(`Max vertices per segment is ${io.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!E||E.vertexLength+c>io.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==k)&&(E={vertexOffset:m,primitiveOffset:y,vertexLength:0,primitiveLength:0},k!==void 0&&(E.sortKey=k),this.segments.push(E)),E}prepareSegment(c,m,y,k){return this._prepareSegment(c,m.length,y.length,k)}get(){return this.segments}destroy(){for(const c of this.segments)for(const m in c.vaos)c.vaos[m].destroy()}static simpleSegment(c,m,y,k){return new io([{vertexOffset:c,primitiveOffset:m,vertexLength:y,primitiveLength:k,vaos:{},sortKey:0}])}}function lC(p,c){return 256*(p=Se(Math.floor(p),0,255))+Se(Math.floor(c),0,255)}io.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,vr(io,"SegmentVector");const Hce=ra([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Wce=ra([{name:"a_pattern_b",components:4,type:"Uint16"}]),Gce=ra([{name:"a_dash",components:4,type:"Uint16"}]);class _b{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,m,y,k){this.ids.push(PT(c)),this.positions.push(m,y,k)}eachPosition(c,m){const y=PT(c);let k=0,E=this.ids.length-1;for(;k>1;this.ids[P]>=y?E=P:k=P+1}for(;this.ids[k]===y;)m(this.positions[3*k],this.positions[3*k+1],this.positions[3*k+2]),k++}static serialize(c,m){const y=new Float64Array(c.ids),k=new Uint32Array(c.positions);return IT(y,k,0,y.length-1),m&&(m.add(y.buffer),m.add(k.buffer)),{ids:y,positions:k}}static deserialize(c){const m=new _b;let y;m.ids=c.ids,m.positions=c.positions;for(const k of m.ids)k!==y&&m.uniqueIds.push(k),y=k;return m.indexed=!0,m}}function PT(p){const c=+p;return Number.isSafeInteger(c)?c:sv(String(p))}function IT(p,c,m,y){for(;m>1];let E=m-1,P=y+1;for(;;){do E++;while(p[E]k);if(E>=P)break;cC(p,E,P),cC(c,3*E,3*P),cC(c,3*E+1,3*P+1),cC(c,3*E+2,3*P+2)}P-m`u_${E}`),this.type=y,this.context=k}setUniform(c,m,y,k,E){const P=k.constantOr(this.value);m.set(c,E,P instanceof Fr?P.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):P)}getBinding(c,m){return this.type==="color"?new wb(c):new vl(c)}}class kv{constructor(c,m){this.uniformNames=m.map(y=>`u_${y}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(c,m){this.pixelRatio=c.pixelRatio||1,this.pattern=c.tl.concat(c.br),this.patternTransition=m?m.tl.concat(m.br):this.pattern}setUniform(c,m,y,k,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(c,E,P)}getBinding(c,m){return m==="u_pattern"||m==="u_pattern_b"||m==="u_dash"?new uC(c):new vl(c)}}class Bf{constructor(c,m,y,k){this.expression=c,this.type=y,this.maxValue=0,this.paintVertexAttributes=m.map(E=>({name:`a_${E}`,type:"Float32",components:y==="color"?2:1,offset:0})),this.paintVertexArray=new k}populatePaintArray(c,m,y,k,E,P,O,B){const W=this.paintVertexArray.length,J=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Ii(0,{brightness:P,worldview:B}),m,{},E,k,O):this.expression.kind==="constant"&&this.expression.value,ee=kb(this.lutExpression,m,{},k,E,P,O,B);this.paintVertexArray.resize(c),this._setPaintValue(W,c,J,ee?null:this.context.lut)}updatePaintArray(c,m,y,k,E,P,O,B){const W=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:O,worldview:B},y,k,void 0,E):this.expression.kind==="constant"&&this.expression.value,J=kb(this.lutExpression,y,k,E,void 0,O,void 0,B);this._setPaintValue(c,m,W,J?null:this.context.lut)}_setPaintValue(c,m,y,k){if(this.type==="color"){const E=LT(y.toPremultipliedRenderColor(k));for(let P=c;P`u_${O}_t`),this.type=y,this.useIntegerZoom=k,this.context=E,this.maxValue=0,this.paintVertexAttributes=m.map(O=>({name:`a_${O}`,type:"Float32",components:y==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(c,m,y,k,E,P,O,B){const W=this.expression.evaluate(new Ii(this.context.zoom,{brightness:P,worldview:B}),m,{},E,k,O),J=this.expression.evaluate(new Ii(this.context.zoom+1,{brightness:P,worldview:B}),m,{},E,k,O),ee=kb(this.lutExpression,m,{},k,E,P,O,B),ne=this.paintVertexArray.length;this.paintVertexArray.resize(c),this._setPaintValue(ne,c,W,J,ee?null:this.context.lut)}updatePaintArray(c,m,y,k,E,P,O,B){const W=this.expression.evaluate({zoom:this.context.zoom,brightness:O,worldview:B},y,k,void 0,E),J=this.expression.evaluate({zoom:this.context.zoom+1,brightness:O,worldview:B},y,k,void 0,E),ee=kb(this.lutExpression,y,k,E,void 0,O,void 0,B);this._setPaintValue(c,m,W,J,ee?null:this.context.lut)}_setPaintValue(c,m,y,k,E){if(this.type==="color"){const P=LT(y.toPremultipliedRenderColor(E)),O=LT(y.toPremultipliedRenderColor(E));for(let B=c;B!0){this.binders={},this._buffers=[],this.context=m;const k=[];for(const E in c.paint._values){const P=c.paint.get(E);if(E.endsWith("-use-theme")||!y(E)||!(P instanceof Ny&&ub(P.property.specification)))continue;const O=Xce(E,c.type),B=P.value,W=P.property.specification.type,J=!!P.property.useIntegerZoom,ee=E==="line-dasharray"||E.endsWith("pattern"),ne=c.paint.get(`${E}-use-theme`),ie=E==="line-dasharray"&&c.layout.get("line-cap").value.kind!=="constant"||ne&&ne.value.kind!=="constant";if(B.kind!=="constant"||ie)if(B.kind==="source"||ie||ee){const ue=DT(E,W,"source");this.binders[E]=ee?new qf(B,O,W,ue,c.id):new Bf(B,O,W,ue),k.push(`/a_${E}`)}else{const ue=DT(E,W,"composite");this.binders[E]=new $f(B,O,W,J,m,ue),k.push(`/z_${E}`)}else this.binders[E]=ee?new kv(B.value,O):new Nb(B.value,O,W,m),k.push(`/u_${E}`);ne&&(this.binders[E].lutExpression=ne.value)}this.cacheKey=k.sort().join("")}getMaxValue(c){const m=this.binders[c];return m instanceof Bf||m instanceof $f?m.maxValue:0}populatePaintArrays(c,m,y,k,E,P,O,B){for(const W in this.binders){const J=this.binders[W];J.context=this.context,(J instanceof Bf||J instanceof $f||J instanceof qf)&&J.populatePaintArray(c,m,y,k,E,P,O,B)}}setConstantPatternPositions(c,m){for(const y in this.binders){const k=this.binders[y];k instanceof kv&&k.setConstantPatternPositions(c,m)}}getPatternTransitionVertexBuffer(c){const m=this.binders[c];return m instanceof qf?m.paintTransitionVertexBuffer:null}updatePaintArrays(c,m,y,k,E,P,O,B,W,J){let ee=!1;const ne=Object.keys(c),ie=ne.length!==0&&!B,ue=ie?ne:m.uniqueIds;this.context.lut=E.lut;for(const we in this.binders){const Ee=this.binders[we];if(Ee.context=this.context,(Ee instanceof Bf||Ee instanceof $f||Ee instanceof qf)&&Ee.expression&&Ee.expression.kind&&Ee.expression.kind!=="constant"&&(Ee.expression.isStateDependent===!0||Ee.expression.isLightConstant===!1)){const Te=E.paint.get(we);Ee.expression=Te.value;for(const Ue of ue){const Ye=c[Ue.toString()];m.eachPosition(Ue,(st,_t,ft)=>{const St=k.feature(st);Ee.updatePaintArray(_t,ft,St,Ye,P,O,W,J)})}if(!ie)for(const Ue of y.uniqueIds){const Ye=c[Ue.toString()];y.eachPosition(Ue,(st,_t,ft)=>{const St=k.feature(st);Ee.updatePaintArray(_t,ft,St,Ye,P,O,W,J)})}ee=!0}}return ee}defines(){const c=[];for(const m in this.binders){const y=this.binders[m];(y instanceof Nb||y instanceof kv)&&c.push(...y.uniformNames.map(k=>`#define HAS_UNIFORM_${k}`))}return c}getPaintVertexBuffers(){return this._buffers}getUniforms(c){const m=[];for(const y in this.binders){const k=this.binders[y];if(k instanceof Nb||k instanceof kv||k instanceof $f)for(const E of k.uniformNames)m.push({name:E,property:y,binding:k.getBinding(c,E)})}return m}setUniforms(c,m,y,k,E){for(const{name:P,property:O,binding:B}of y)this.binders[O].setUniform(c,B,E,k.get(O),P)}updatePaintBuffers(){this._buffers=[];for(const c in this.binders){const m=this.binders[c];(m instanceof Bf||m instanceof $f||m instanceof qf)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof qf&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(c){for(const m in this.binders){const y=this.binders[m];(y instanceof Bf||y instanceof $f||y instanceof qf)&&y.upload(c)}this.updatePaintBuffers()}destroy(){for(const c in this.binders){const m=this.binders[c];(m instanceof Bf||m instanceof $f||m instanceof qf)&&m.destroy()}}}class Um{constructor(c,m,y=()=>!0){this.programConfigurations={};for(const k of c)this.programConfigurations[k.id]=new ux(k,m,y);this.needsUpload=!1,this._featureMap=new _b,this._featureMapWithoutIds=new _b,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(c,m,y,k,E,P,O,B,W){for(const J in this.programConfigurations)this.programConfigurations[J].populatePaintArrays(c,m,k,E,P,O,B,W);m.id!==void 0?this._featureMap.add(m.id,y,this._bufferOffset,c):(this._featureMapWithoutIds.add(this._idlessCounter,y,this._bufferOffset,c),this._idlessCounter+=1),this._bufferOffset=c,this.needsUpload=!0}updatePaintArrays(c,m,y,k,E,P,O,B){for(const W of y)this.needsUpload=this.programConfigurations[W.id].updatePaintArrays(c,this._featureMap,this._featureMapWithoutIds,m,W,k,E,P,O||0,B)||this.needsUpload}get(c){return this.programConfigurations[c]}upload(c){if(this.needsUpload){for(const m in this.programConfigurations)this.programConfigurations[m].upload(c);this.needsUpload=!1}}destroy(){for(const c in this.programConfigurations)this.programConfigurations[c].destroy()}}const Yce={"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 Xce(p,c){return Yce[p]||[p.replace(`${c}-`,"").replace(/-/g,"_")]}const Qce={"line-pattern":{source:yu,composite:yu},"fill-pattern":{source:yu,composite:yu},"fill-extrusion-pattern":{source:yu,composite:yu},"line-dasharray":{source:Ay,composite:Ay}},Jce={color:{source:Lp,composite:cx},number:{source:Ff,composite:Lp}};function DT(p,c,m){const y=Qce[p];return y&&y[m]||Jce[c][m]}vr(Nb,"ConstantBinder"),vr(kv,"PatternConstantBinder"),vr(Bf,"SourceExpressionBinder"),vr(qf,"PatternCompositeBinder"),vr($f,"CompositeExpressionBinder"),vr(ux,"ProgramConfiguration",{omit:["_buffers"]}),vr(Um,"ProgramConfigurationSet");const dd=Gs/Math.PI/2,rm=5,pC=6,ede=16383,Nv=64,OT=[Nv,32,16],nm=-dd,am=dd;function Py(p,c,m,y=dd){return m=Jr(m),[p*Math.sin(m)*y,-c*y,p*Math.cos(m)*y]}function Sv(p,c,m){return Py(Math.cos(Jr(p)),Math.sin(Jr(p)),c,m)}const C=63710088e-1,h=2*Math.PI*C;class x{constructor(c,m){if(isNaN(c)||isNaN(m))throw new Error(`Invalid LngLat object: (${c}, ${m})`);if(this.lng=+c,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 x(tt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(c){const m=Math.PI/180,y=this.lat*m,k=c.lat*m,E=Math.sin(y)*Math.sin(k)+Math.cos(y)*Math.cos(k)*Math.cos((c.lng-this.lng)*m);return C*Math.acos(Math.min(E,1))}toBounds(c=0){const m=360*c/40075017,y=m/Math.cos(Math.PI/180*this.lat);return new T({lng:this.lng-y,lat:this.lat-m},{lng:this.lng+y,lat:this.lat+m})}toEcef(c){return Sv(this.lat,this.lng,dd+c*dd/C)}static convert(c){if(c instanceof x)return c;if(Array.isArray(c)&&(c.length===2||c.length===3))return new x(Number(c[0]),Number(c[1]));if(!Array.isArray(c)&&typeof c=="object"&&c!==null)return new x(Number("lng"in c?c.lng:c.lon),Number(c.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 T{constructor(c,m){c&&(m?this.setSouthWest(c).setNorthEast(m):Array.isArray(c)&&c.length===4?this.setSouthWest([c[0],c[1]]).setNorthEast([c[2],c[3]]):this.setSouthWest(c[0]).setNorthEast(c[1]))}setNorthEast(c){return this._ne=c instanceof x?new x(c.lng,c.lat):x.convert(c),this}setSouthWest(c){return this._sw=c instanceof x?new x(c.lng,c.lat):x.convert(c),this}extend(c){const m=this._sw,y=this._ne;let k,E;if(c instanceof x)k=c,E=c;else{if(!(c instanceof T))return Array.isArray(c)?c.length===4||c.every(Array.isArray)?this.extend(T.convert(c)):this.extend(x.convert(c)):typeof c=="object"&&c!==null&&c.hasOwnProperty("lat")&&(c.hasOwnProperty("lon")||c.hasOwnProperty("lng"))?this.extend(x.convert(c)):this;if(k=c._sw,E=c._ne,!k||!E)return this}return m||y?(m.lng=Math.min(k.lng,m.lng),m.lat=Math.min(k.lat,m.lat),y.lng=Math.max(E.lng,y.lng),y.lat=Math.max(E.lat,y.lat)):(this._sw=new x(k.lng,k.lat),this._ne=new x(E.lng,E.lat)),this}getCenter(){return new x((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 x(this.getWest(),this.getNorth())}getSouthEast(){return new x(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(c){const{lng:m,lat:y}=x.convert(c);let k=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(k=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=y&&y<=this._ne.lat&&k}static convert(c){if(c)return c instanceof T?c:new T(c)}}const D=0,R=25.5;function z(p){return h*Math.cos(p*Math.PI/180)}function V(p){return(180+p)/360}function X(p){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+p*Math.PI/360)))/360}function re(p,c){return p/z(c)}function ae(p){return 360*p-180}function me(p){return 360/Math.PI*Math.atan(Math.exp((180-360*p)*Math.PI/180))-90}function he(p,c){return p*z(me(c))}const pe=85.051129;function Me(p){return Math.cos(Jr(Se(p,-pe,pe)))}function Ce(p,c){const m=Se(c,D,R),y=Math.pow(2,m);return Me(p)*h/(512*y)}function $e(p){return 1/Math.cos(p*Math.PI/180)}function Be(p,c=0){const m=Math.exp(Math.PI*(1-(p.y+c/Gs)/(1<=B?(ot(p,c,m,W,J,E,ee,O,B),ot(p,W,J,y,k,ee,P,O,B)):p.push(P)}function et(p,c,m){let y=p[0],k=y.x,E=y.y;c(y);const P=[y];for(let O=1;Op.x+1||yp.y+1)&&cr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),p}function Et(p,c,m){const y=p.loadGeometry(),k=p.extent,E=Gs/k;if(c&&m&&m.projection.isReprojectedInTileSpace){const P=1<{const ie=ae((c.x+ne.x/k)/P),ue=me((c.y+ne.y/k)/P),we=J.project(ie,ue);ne.x=(we.x*O-B)*k,ne.y=(we.y*O-W)*k};for(let ne=0;ne=k||ue.y<0||ue.y>=k||(ee(ue),ie.push(ue));y[ne]=ie}}for(const P of y)for(const O of P)pt(O,E);return y}function Ht(p,c){return{type:p.type,id:p.id,properties:p.properties,geometry:c?Et(p):[]}}class Ut{constructor(c,m,y,k,E){this.properties={},this.extent=y,this.type=0,this.id=void 0,this._pbf=c,this._geometry=-1,this._keys=k,this._values=E,c.readFields(ts,this,m)}loadGeometry(){const c=this._pbf;c.pos=this._geometry;const m=c.readVarint()+c.pos,y=[];let k,E=1,P=0,O=0,B=0;for(;c.pos>3}if(P--,E===1||E===2)O+=c.readSVarint(),B+=c.readSVarint(),E===1&&(k&&y.push(k),k=[]),k&&k.push(new rs(O,B));else{if(E!==7)throw new Error(`unknown command ${E}`);k&&k.push(k[0].clone())}}return k&&y.push(k),y}bbox(){const c=this._pbf;c.pos=this._geometry;const m=c.readVarint()+c.pos;let y=1,k=0,E=0,P=0,O=1/0,B=-1/0,W=1/0,J=-1/0;for(;c.pos>3}if(k--,y===1||y===2)E+=c.readSVarint(),P+=c.readSVarint(),EB&&(B=E),PJ&&(J=P);else if(y!==7)throw new Error(`unknown command ${y}`)}return[O,W,B,J]}toGeoJSON(c,m,y){const k=this.extent*Math.pow(2,y),E=this.extent*c,P=this.extent*m,O=this.loadGeometry();function B(ne){return[360*(ne.x+E)/k-180,360/Math.PI*Math.atan(Math.exp((1-2*(ne.y+P)/k)*Math.PI))-90]}function W(ne){return ne.map(B)}let J;if(this.type===1){const ne=[];for(const ue of O)ne.push(ue[0]);const ie=W(ne);J=ne.length===1?{type:"Point",coordinates:ie[0]}:{type:"MultiPoint",coordinates:ie}}else if(this.type===2){const ne=O.map(W);J=ne.length===1?{type:"LineString",coordinates:ne[0]}:{type:"MultiLineString",coordinates:ne}}else{if(this.type!==3)throw new Error("unknown feature type");{const ne=function(ue){const we=ue.length;if(we<=1)return[ue];const Ee=[];let Te,Ue;for(let Ye=0;Ye=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[c];const m=this._pbf.readVarint()+this._pbf.pos;return new Ut(this._pbf,m,this.extent,this._keys,this._values)}}function zs(p,c,m){p===15?c.version=m.readVarint():p===1?c.name=m.readString():p===5?c.extent=m.readVarint():p===2?c._features.push(m.pos):p===3?c._keys.push(m.readString()):p===4&&c._values.push(function(y){let k=null;const E=y.readVarint()+y.pos;for(;y.pos>3;k=P===1?y.readString():P===2?y.readFloat():P===3?y.readDouble():P===4?y.readVarint64():P===5?y.readVarint():P===6?y.readSVarint():P===7?y.readBoolean():null}if(k==null)throw new Error("unknown feature value");return k}(m))}class Xt{constructor(c,m){this.layers=c.readFields(Dt,{},m)}}function Dt(p,c,m){if(p===3){const y=new ps(m,m.readVarint()+m.pos);y.length&&(c[y.name]=y)}}const ls="3d_elevation_id",es="level";class As{constructor(){this._valid=!1}reset(c){return this.feature=c,this._valid=!0,this._geometry=c.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(c,m){return this._valid&&c(m(this._geometry)),this}require(c,m,y){return this.get(c,!0,m,y)}optional(c,m,y){return this.get(c,!1,m,y)}success(){return this._valid}get(c,m,y,k){const E=this.feature.properties.hasOwnProperty(c)?+this.feature.properties[c]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?y(k?k(E):E):m&&(this._valid=!1),this}}class Xs{constructor(c,m){this.featureFunc=c,this.vertexFunc=m}parseFeature(c,m,y){return this.featureFunc(c,m,y)}parseVertex(c,m,y){return this.vertexFunc(c,m,y)}}const ur=new Xs((p,c,m)=>p.reset(c).require(ls,y=>{m.id=y}).optional("fixed_height_relative",y=>{m.constantHeight=y},Bs.decodeRelativeHeight).geometry(y=>{m.bounds=y},Pf).success(),(p,c,m)=>p.reset(c).require(ls,y=>{m.id=y}).require("elevation_idx",y=>{m.idx=y}).require("extent",y=>{m.extent=y}).require("height_relative",y=>{m.height=y},Bs.decodeRelativeHeight).geometry(y=>{m.position=y},Bs.getPoint).success()),Ws=new Xs((p,c,m)=>p.reset(c).require(ls,y=>{m.id=y}).optional("fixed_height",y=>{m.constantHeight=y},Bs.decodeMetricHeight).geometry(y=>{m.bounds=y},Pf).success(),(p,c,m)=>p.reset(c).require(ls,y=>{m.id=y}).require("elevation_idx",y=>{m.idx=y}).require("extent",y=>{m.extent=y}).require("height",y=>{m.height=y},Bs.decodeMetricHeight).geometry(y=>{m.position=y},Bs.getPoint).success());class Bs{static getPoint(c){return bt(c[0][0].x,c[0][0].y)}static decodeRelativeHeight(c){return 1e-4*c*5}static decodeMetricHeight(c){return 1e-4*c}static getVersionSchema(c){return c?c==="1.0.1"?Ws:void 0:ur}static parse(c){const m=[],y=[],k=c.length,E=new As;for(let P=0;P=0);if(E===0)return 0;E!==c.length&&(m=!1)}return m?2:1}function jn(p,c){for(const m of p.projections){const y=mr(c,p.points[0],m.axis);if(m.projection[1]y[1])return 0}return 1}function da(p,c){let m=0;const y=[0,0,0,0];for(let P=0;P=0&&m++;var k,E;return m}class Va{constructor(c,m){this.points=c||new Array(8).fill([0,0,0]),this.planes=m||new Array(6).fill([0,0,0,0]),this.bounds=Tr.fromPoints(this.points),this.projections=[],this.frustumEdges=[je([],this.points[2],this.points[3]),je([],this.points[0],this.points[3]),je([],this.points[4],this.points[0]),je([],this.points[5],this.points[1]),je([],this.points[6],this.points[2]),je([],this.points[7],this.points[3])];for(const y of this.frustumEdges){const k=[0,-y[2],y[1]],E=[y[2],0,-y[0]];this.projections.push({axis:k,projection:mr(this.points,this.points[0],k)}),this.projections.push({axis:E,projection:mr(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(c,m,y,k){const E=Math.pow(2,y),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(W=>{const J=ht([],W,c),ee=1/J[3]/m*E;return(ne=J)[0]=(ie=J)[0]*(ue=[ee,ee,k?1/J[3]:ee,ee])[0],ne[1]=ie[1]*ue[1],ne[2]=ie[2]*ue[2],ne[3]=ie[3]*ue[3],ne;var ne,ie,ue}),O=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(W=>{const J=Ie([],dt([],je([],P[W[0]],P[W[1]]),je([],P[W[2]],P[W[1]]))),ee=-Ve(J,P[W[1]]);return J.concat(ee)}),B=[];for(let W=0;WW[1]||W[0]>B[1])return 0}return 1}containsPoint(c){for(const m of this.planes){const y=m[3];if(Ve([m[0],m[1],m[2]],c)+y<0)return!1}return!0}}class Tr{static fromPoints(c){const m=[1/0,1/0,1/0],y=[-1/0,-1/0,-1/0];for(const k of c)ye(m,m,k),ve(y,y,k);return new Tr(m,y)}static fromTileIdAndHeight(c,m,y){const k=1<c.max[m]||c.min[m]>this.max[m])return!1;return!0}intersectsAabbXY(c){return!(this.min[0]>c.max[0]||c.min[0]>this.max[0]||this.min[1]>c.max[1]||c.min[1]>this.max[1])}encapsulate(c){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],c.min[m]),this.max[m]=Math.max(this.max[m],c.max[m])}encapsulatePoint(c){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],c[m]),this.max[m]=Math.max(this.max[m],c[m])}closestPoint(c){return[Math.max(Math.min(this.max[0],c[0]),this.min[0]),Math.max(Math.min(this.max[1],c[1]),this.min[1]),Math.max(Math.min(this.max[2],c[2]),this.min[2])]}}vr(Tr,"Aabb");class Oa{constructor(c,m){this.feature=c,this.metersToTile=m,this.index=0}get(){const c=this.feature.vertices[this.index],m=this.feature.vertexProps[this.index].dir,y=m[1],k=-m[0],E=(c.extent+1)*this.metersToTile;return[new rs(Math.trunc(c.position[0]+y*E),Math.trunc(c.position[1]+k*E)),new rs(Math.trunc(c.position[0]-y*E),Math.trunc(c.position[1]-k*E))]}next(){this.index++}valid(){return this.index{return O.a0?ke(B,B,1/W):le(B,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(c){if(this.edges.length===0)return;let m=0,y=Number.POSITIVE_INFINITY,k=0;const[E,P,O,B,W,J,ee]=this._tmpVec2;ws(ee,c.x,c.y);const ne=new kr(ee,null);for(let ie=0;ie0?Da(B,O)/st:0,ft=Se(_t,0,1),St=Math.abs((_t-ft)*this.edgeProps[ie].len);Rr(W,ee,Ee),ws(J,we[1],-we[0]);const Pt=St+Math.abs(Da(W,J));Pt=0;--P){const O=this.edges[P].a,B=this.edges[P].b,{position:W,height:J,extent:ee}=this.vertices[O],{position:ne,height:ie,extent:ue}=this.vertices[B],we=this.vertexProps[O].dir,Ee=this.vertexProps[B].dir;if(le(m,W[0]/c,W[1]/c,J),le(y,ne[0]/c,ne[1]/c,ie),le(k,we[1],-we[0],0),ke(k,k,ee),le(E,Ee[1],-Ee[0],0),ke(E,E,ue),this.distSqLines(oe(m[0]+.5*k[0],m[1]+.5*k[1],m[2]+.5*k[2]),oe(y[0]-.5*E[0],y[1]-.5*E[1],y[2]-.5*E[2]),oe(m[0]-.5*k[0],m[1]-.5*k[1],m[2]-.5*k[2]),oe(y[0]+.5*E[0],y[1]+.5*E[1],y[2]+.5*E[2]))<=.0025000000000000005)continue;const Te=this.vertices.length,Ue=ir(dr(),W,ne);this.vertices.push({position:oa(Ue,Ue,.5),height:.5*(J+ie),extent:.5*(ee+ue)});const Ye=ir(dr(),we,Ee);this.vertexProps.push({dir:no(Ye,Ye)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:O,b:Te}),this.edges.push({a:Te,b:B});const st=Rr(dr(),this.vertices[Te].position,W),_t=ri(st),ft={vec:st,dir:oa(dr(),st,1/_t),len:_t};this.edgeProps.push(ft),this.edgeProps.push(ft)}}distSqLines(c,m,y,k){const E=xe(te(),m,c),P=xe(te(),k,y),O=xe(te(),c,y),B=Ve(E,E),W=Ve(E,P),J=Ve(E,O),ee=Ve(P,P),ne=Ve(P,O),ie=B*ee-W*W;if(ie===0)return Ae(Le(E,y,k,Ve(O,P)/Ve(P,P)),c);const ue=(B*ne-W*J)/ie;return Ae(Le(E,c,m,(W*ne-J*ee)/ie),Le(P,y,k,ue))}}class Ya{static parseFrom(c,m){const y=Bs.parse(c);if(!y)return[];let{vertices:k,features:E}=y;const P=1/Be(m);E.sort((J,ee)=>J.id-ee.id),k.sort((J,ee)=>J.id-ee.id||J.idx-ee.idx),k=k.filter((J,ee,ne)=>ee===ne.findIndex(ie=>ie.id===J.id&&ie.idx===J.idx));const O=new Array;let B=0;const W=k.length;for(const J of E){if(J.constantHeight){O.push(new vn(J.id,J.bounds,J.constantHeight));continue}for(;B!==W&&k[B].idk.id===y)}}class ui{constructor(c,m){this.zScale=1,this.xOffset=0,this.yOffset=0,c.equals(m)||(this.zScale=Math.pow(2,m.z-c.z),this.xOffset=(c.x*this.zScale-m.x)*Gs,this.yOffset=(c.y*this.zScale-m.y)*Gs)}constantElevation(c,m){if(c.constantHeight!=null)return this.computeBiasedHeight(c.constantHeight,m)}pointElevation(c,m,y){const k=this.constantElevation(m,y);return k??(c.x=c.x*this.zScale+this.xOffset,c.y=c.y*this.zScale+this.yOffset,this.computeBiasedHeight(m.pointElevation(c),y))}computeBiasedHeight(c,m){return m<=0?c:c+m*ze(0,m,c>=0?c:Math.abs(.5*c))}}vr(vn,"ElevationFeature");class ni{constructor(c){this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=c.index,this.hasPattern=!1,this.projection=c.projection,this.layoutVertexArray=new lx,this.indexArray=new yl,this.segments=new io,this.programConfigurations=new Um(c.layers,{zoom:c.zoom,lut:c.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 Ff),this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){const E=this.layers[0],P=[];let O=null;E.type==="circle"&&(O=E.layout.get("circle-sort-key"));for(const{feature:W,id:J,index:ee,sourceLayerIndex:ne}of c){const ie=this.layers[0]._featureFilter.needGeometry,ue=Ht(W,ie);if(!this.layers[0]._featureFilter.filter(new Ii(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ue,y))continue;const we=O?O.evaluate(ue,{},y):void 0,Ee={id:J,properties:W.properties,type:W.type,sourceLayerIndex:ne,index:ee,geometry:ie?ue.geometry:Et(W,y,k),patterns:{},sortKey:we};P.push(Ee)}O&&P.sort((W,J)=>W.sortKey-J.sortKey);let B=null;k.projection.name==="globe"&&(this.globeExtVertexArray=new XS,B=k.projection);for(const W of P){const{geometry:J,index:ee,sourceLayerIndex:ne}=W,ie=c[ee].feature;this.addFeature(W,J,ee,m.availableImages,y,B,m.brightness,m.elevationFeatures),m.featureIndex.insert(ie,J,ee,ne,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(c,m,y,k,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,$D.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,qD.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,Vce.members))),this.programConfigurations.upload(c),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(c,m,y,k,E,P,O,B){let W;this.elevationMode!=="none"&&(W=Ya.getElevationFeature(c,B));for(const J of m)for(const ee of J){const ne=ee.x,ie=ee.y;if(ne<0||ne>=Gs||ie<0||ie>=Gs)continue;if(P){const Ee=P.projectTilePoint(ne,ie,E),Te=P.upVector(E,ne,ie);this.addGlobeExtVertex(Ee,Te),this.addGlobeExtVertex(Ee,Te),this.addGlobeExtVertex(Ee,Te),this.addGlobeExtVertex(Ee,Te)}const ue=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,c.sortKey),we=ue.vertexLength;if(this.addCircleVertex(ne,ie,-1,-1),this.addCircleVertex(ne,ie,1,-1),this.addCircleVertex(ne,ie,1,1),this.addCircleVertex(ne,ie,-1,1),this.elevationMode!=="none"){const Ee=W?W.pointElevation(new rs(ne,ie)):0;this.hasElevation=this.hasElevation||Ee!==0;for(let Te=0;Te<4;Te++)this.elevatedLayoutVertexArray.emplaceBack(Ee)}this.indexArray.emplaceBack(we,we+1,we+2),this.indexArray.emplaceBack(we,we+2,we+3),ue.vertexLength+=4,ue.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,y,{},k,E,O,void 0,this.worldview)}addCircleVertex(c,m,y,k){this.layoutVertexArray.emplaceBack(2*c+(y+1)/2,2*m+(k+1)/2)}addGlobeExtVertex(c,m){this.globeExtVertexArray.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function Ea(p,c){for(let m=0;m1){if(Vi(p,c))return!0;for(let y=0;y1?m:m.sub(c)._mult(k)._add(c))}function oo(p,c){let m,y,k,E=!1;for(let P=0;Pc.y!=k.y>c.y&&c.x<(k.x-y.x)*(c.y-y.y)/(k.y-y.y)+y.x&&(E=!E)}return E}function _i(p,c){let m=!1;for(let y=0,k=p.length-1;yc.y!=P.y>c.y&&c.x<(P.x-E.x)*(c.y-E.y)/(P.y-E.y)+E.x&&(m=!m)}return m}function Zd(p,c,m,y,k){for(const P of p)if(c<=P.x&&m<=P.y&&y>=P.x&&k>=P.y)return!0;const E=[new rs(c,m),new rs(c,k),new rs(y,k),new rs(y,m)];if(p.length>2){for(const P of E)if(_i(p,P))return!0}for(let P=0;Pk.x&&c.x>k.x||p.yk.y&&c.y>k.y)return!1;const E=Nn(p,c,m[0]);return E!==Nn(p,c,m[1])||E!==Nn(p,c,m[2])||E!==Nn(p,c,m[3])}function _l(p,c,m,y,k,E){let P=c.y-p.y,O=p.x-c.x;if(E=E||0){const B=P*P+O*O;if(B===0)return!0;const W=Math.sqrt(B);P/=W,O/=W}return!((m.x-p.x)*P+(m.y-p.y)*O-E<0||(y.x-p.x)*P+(y.y-p.y)*O-E<0||(k.x-p.x)*P+(k.y-p.y)*O-E<0)}function ud(p,c,m,y,k,E,P){return!(_l(p,c,y,k,E,P)||_l(c,m,y,k,E,P)||_l(m,p,y,k,E,P)||_l(y,k,p,c,m,P)||_l(k,E,p,c,m,P)||_l(E,y,p,c,m,P))}function hd(p,c,m){const y=c.paint.get(p).value;return y.kind==="constant"?y.value:m.programConfigurations.get(c.id).getMaxValue(p)}function Mc(p){return Math.sqrt(p[0]*p[0]+p[1]*p[1])}function mh(p,c,m,y,k){if(!c[0]&&!c[1])return p;const E=rs.convert(c)._mult(k);m==="viewport"&&E._rotate(-y);const P=[];for(let O=0;O>m&&c.y===this.y>>m}url(c,m){const y=function(E,P,O){var B=Do(256*E,256*(P=Math.pow(2,O)-P-1),O),W=Do(256*(E+1),256*(P+1),O);return B[0]+","+B[1]+","+W[0]+","+W[1]}(this.x,this.y,this.z),k=function(E,P,O){let B,W="";for(let J=E;J>0;J--)B=1<this.canonical.z?new fo(c,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fo(c,this.wrap,c,this.canonical.x>>m,this.canonical.y>>m)}calculateScaledKey(c,m=!0){if(this.overscaledZ===c&&m)return this.key;if(c>this.canonical.z)return lo(this.wrap*+m,c,this.canonical.z,this.canonical.x,this.canonical.y);{const y=this.canonical.z-c;return lo(this.wrap*+m,c,c,this.canonical.x>>y,this.canonical.y>>y)}}isChildOf(c){if(c.wrap!==this.wrap)return!1;const m=this.canonical.z-c.canonical.z;return c.overscaledZ===0||c.overscaledZ>m&&c.canonical.y===this.canonical.y>>m}children(c){if(this.overscaledZ>=c)return[new fo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const m=this.canonical.z+1,y=2*this.canonical.x,k=2*this.canonical.y;return[new fo(m,this.wrap,m,y,k),new fo(m,this.wrap,m,y+1,k),new fo(m,this.wrap,m,y,k+1),new fo(m,this.wrap,m,y+1,k+1)]}isLessThan(c){return this.wrapc.wrap)&&(this.overscaledZc.overscaledZ)&&(this.canonical.xc.canonical.x)&&this.canonical.y{let c=p.canonical.x-1,m=p.wrap;return c<0&&(c=(1<{let c=p.canonical.x+1,m=p.wrap;return c===1<new fo(p.overscaledZ,p.wrap,p.canonical.z,p.canonical.x,(p.canonical.y===0?1<new fo(p.overscaledZ,p.wrap,p.canonical.z,p.canonical.x,p.canonical.y===(1<1?null:function(y,k,E,P){const O=Math.sin(E);return y*(Math.sin((1-P)*E)/O)+k*(Math.sin(P*E)/O)}(p.a[c],p.b[c],p.angle,Se(m,0,1))+p.center[c]}function Hm(p){if(p.z<=1)return Uf[p.z+2*p.y+p.x];const c=tde(UD(p));return Tr.fromPoints(c)}function Hf(p,c,m){return ke(p,p,1-m),Ge(p,p,c,m)}function C2e(p,c,m){for(const y of p)Rt(y,y,c),ke(y,y,m)}function M2e(p,c,m,y){const k=c/p.worldSize,E=p.globeMatrix;if(m.z<=1){const Ft=Hm(m).getCorners();return C2e(Ft,E,k),Tr.fromPoints(Ft)}const P=UD(m,y),O=tde(P,dd+Op(p._tileCoverLift));C2e(O,E,k);const B=Number.MAX_VALUE,W=[-B,-B,-B],J=[B,B,B];if(P.contains(p.center)){for(const Wt of O)ye(J,J,Wt),ve(W,W,Wt);W[2]=0;const Ft=p.point,ns=[Ft.x*k,Ft.y*k,0];return ye(J,J,ns),ve(W,W,ns),new Tr(J,W)}if(p._tileCoverLift>0){for(const Ft of O)ye(J,J,Ft),ve(W,W,Ft);return new Tr(J,W)}const ee=[E[12]*k,E[13]*k,E[14]*k],ne=P.getCenter(),ie=Se(p.center.lat,-pe,pe),ue=Se(ne.lat,-pe,pe),we=V(p.center.lng),Ee=X(ie);let Te=we-V(ne.lng);const Ue=Ee-X(ue);Te>.5?Te-=1:Te<-.5&&(Te+=1);let Ye=0;Math.abs(Te)>Math.abs(Ue)?Ye=Te>=0?1:3:(Ye=Ue>=0?0:2,Ge(ee,ee,[E[4]*k,E[5]*k,E[6]*k],-Math.sin(Jr(Ue>=0?P.getSouth():P.getNorth()))*dd));const st=O[Ye],_t=O[(Ye+1)%4],ft=new hx(st,_t,ee),St=[Vf(ft,0)||st[0],Vf(ft,1)||st[1],Vf(ft,2)||st[2]],Pt=Tv(p.zoom);if(Pt>0){const Ft=function({x:Wt,y:hs,z:ys},vs,Ds,Fs,Es){const Is=1/(1<.5?$s=-1:Pr<-.5&&($s=1),us=((us+$s)*vs-(Fs*=vs))*Ds+Fs,as=((as+$s)*vs-Fs)*Ds+Fs,Ls=(Ls*vs-(Es*=vs))*Ds+Es,Ks=(Ks*vs-Es)*Ds+Es,[[us,Ks,0],[as,Ks,0],[as,Ls,0],[us,Ls,0]]}(m,c,p._pixelsPerMercatorPixel,we,Ee);for(let Wt=0;WtMath.PI/2*1.01}const I2e=Jr(85),eet=Math.cos(I2e),tet=Math.sin(I2e),set=b(),L2e=p=>{const c=[];return p.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),p.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function D2e(p,c,m,y,k,E,P,O,B){if(E&&p.queryGeometry.isAboveHorizon)return!1;E&&(B*=p.pixelToTileUnitsFactor);const W=p.tileID.canonical,J=m.projection.upVectorScale(W,m.center.lat,m.worldSize).metersToTile;for(const ee of c)for(const ne of ee){const ie=ne.add(O),ue=k&&m.elevation?m.elevation.exaggeration()*k.getElevationAt(ie.x,ie.y,!0):0,we=m.projection.projectTilePoint(ie.x,ie.y,W);if(ue>0){const Ye=m.projection.upVector(W,ie.x,ie.y);we.x+=Ye[0]*J*ue,we.y+=Ye[1]*J*ue,we.z+=Ye[2]*J*ue}const Ee=E?ie:ret(we.x,we.y,we.z,y),Te=E?p.tilespaceRays.map(Ye=>aet(Ye,ue)):p.queryGeometry.screenGeometry,Ue=ht([],[we.x,we.y,we.z,1],y);if(!P&&E?B*=Ue[3]/m.cameraToCenterDistance:P&&!E&&(B*=m.cameraToCenterDistance/Ue[3]),E){const Ye=me((ne.y/Gs+W.y)/(1<p.width||k.height>p.height||m.x>p.width-k.width||m.y>p.height-k.height)throw new RangeError("out of range source coordinates for image copy");if(k.width>c.width||k.height>c.height||y.x>c.width-k.width||y.y>c.height-k.height)throw new RangeError("out of range destination coordinates for image copy");const B=p.data,W=c.data,J=E===4&&O;for(let ee=0;ee{c[p.evaluationKey]=B;const W=p.expression.evaluate(c),J=W?W.toNonPremultipliedRenderColor(null):null;J&&(k.data[P+O+0]=Math.floor(255*J.r),k.data[P+O+1]=Math.floor(255*J.g),k.data[P+O+2]=Math.floor(255*J.b),k.data[P+O+3]=Math.floor(255*J.a))};if(p.clips)for(let P=0,O=0;P80*m){O=p[0],B=p[1];let J=O,ee=B;for(let ne=m;neJ&&(J=ie),ue>ee&&(ee=ue)}W=Math.max(J-O,ee-B),W=W!==0?32767/W:0}return zT(E,P,m,O,B,W,0),P}function H2e(p,c,m,y,k){let E;if(k===function(P,O,B,W){let J=0;for(let ee=O,ne=B-W;ee0)for(let P=c;P=c;P-=y)E=Z2e(P/y|0,p[P],p[P+1],E);return E&&gC(E,E.next)&&(qT(E),E=E.next),E}function Mb(p,c){if(!p)return p;c||(c=p);let m,y=p;do if(m=!1,y.steiner||!gC(y,y.next)&&xc(y.prev,y,y.next)!==0)y=y.next;else{if(qT(y),y=c=y.prev,y===y.next)break;m=!0}while(m||y!==c);return c}function zT(p,c,m,y,k,E,P){if(!p)return;!P&&E&&function(B,W,J,ee){let ne=B;do ne.z===0&&(ne.z=ide(ne.x,ne.y,W,J,ee)),ne.prevZ=ne.prev,ne.nextZ=ne.next,ne=ne.next;while(ne!==B);ne.prevZ.nextZ=null,ne.prevZ=null,function(ie){let ue,we=1;do{let Ee,Te=ie;ie=null;let Ue=null;for(ue=0;Te;){ue++;let Ye=Te,st=0;for(let ft=0;ft0||_t>0&&Ye;)st!==0&&(_t===0||!Ye||Te.z<=Ye.z)?(Ee=Te,Te=Te.nextZ,st--):(Ee=Ye,Ye=Ye.nextZ,_t--),Ue?Ue.nextZ=Ee:ie=Ee,Ee.prevZ=Ue,Ue=Ee;Te=Ye}Ue.nextZ=null,we*=2}while(ue>1)}(ne)}(p,y,k,E);let O=p;for(;p.prev!==p.next;){const B=p.prev,W=p.next;if(E?het(p,y,k,E):uet(p))c.push(B.i,p.i,W.i),qT(p),p=W.next,O=W.next;else if((p=W)===O){P?P===1?zT(p=met(Mb(p),c),c,m,y,k,E,2):P===2&&pet(p,c,m,y,k,E):zT(Mb(p),c,m,y,k,E,1);break}}}function uet(p){const c=p.prev,m=p,y=p.next;if(xc(c,m,y)>=0)return!1;const k=c.x,E=m.x,P=y.x,O=c.y,B=m.y,W=y.y,J=Math.min(k,E,P),ee=Math.min(O,B,W),ne=Math.max(k,E,P),ie=Math.max(O,B,W);let ue=y.next;for(;ue!==c;){if(ue.x>=J&&ue.x<=ne&&ue.y>=ee&&ue.y<=ie&&BT(k,O,E,B,P,W,ue.x,ue.y)&&xc(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function het(p,c,m,y){const k=p.prev,E=p,P=p.next;if(xc(k,E,P)>=0)return!1;const O=k.x,B=E.x,W=P.x,J=k.y,ee=E.y,ne=P.y,ie=Math.min(O,B,W),ue=Math.min(J,ee,ne),we=Math.max(O,B,W),Ee=Math.max(J,ee,ne),Te=ide(ie,ue,c,m,y),Ue=ide(we,Ee,c,m,y);let Ye=p.prevZ,st=p.nextZ;for(;Ye&&Ye.z>=Te&&st&&st.z<=Ue;){if(Ye.x>=ie&&Ye.x<=we&&Ye.y>=ue&&Ye.y<=Ee&&Ye!==k&&Ye!==P&&BT(O,J,B,ee,W,ne,Ye.x,Ye.y)&&xc(Ye.prev,Ye,Ye.next)>=0||(Ye=Ye.prevZ,st.x>=ie&&st.x<=we&&st.y>=ue&&st.y<=Ee&&st!==k&&st!==P&&BT(O,J,B,ee,W,ne,st.x,st.y)&&xc(st.prev,st,st.next)>=0))return!1;st=st.nextZ}for(;Ye&&Ye.z>=Te;){if(Ye.x>=ie&&Ye.x<=we&&Ye.y>=ue&&Ye.y<=Ee&&Ye!==k&&Ye!==P&&BT(O,J,B,ee,W,ne,Ye.x,Ye.y)&&xc(Ye.prev,Ye,Ye.next)>=0)return!1;Ye=Ye.prevZ}for(;st&&st.z<=Ue;){if(st.x>=ie&&st.x<=we&&st.y>=ue&&st.y<=Ee&&st!==k&&st!==P&&BT(O,J,B,ee,W,ne,st.x,st.y)&&xc(st.prev,st,st.next)>=0)return!1;st=st.nextZ}return!0}function met(p,c){let m=p;do{const y=m.prev,k=m.next.next;!gC(y,k)&&G2e(y,m,m.next,k)&&$T(y,k)&&$T(k,y)&&(c.push(y.i,m.i,k.i),qT(m),qT(m.next),m=p=k),m=m.next}while(m!==p);return Mb(m)}function pet(p,c,m,y,k,E){let P=p;do{let O=P.next.next;for(;O!==P.prev;){if(P.i!==O.i&&vet(P,O)){let B=K2e(P,O);return P=Mb(P,P.next),B=Mb(B,B.next),zT(P,c,m,y,k,E,0),void zT(B,c,m,y,k,E,0)}O=O.next}P=P.next}while(P!==p)}function fet(p,c){let m=p.x-c.x;return m===0&&(m=p.y-c.y,m===0)&&(m=(p.next.y-p.y)/(p.next.x-p.x)-(c.next.y-c.y)/(c.next.x-c.x)),m}function get(p,c){const m=function(k,E){let P=E;const O=k.x,B=k.y;let W,J=-1/0;if(gC(k,P))return P;do{if(gC(k,P.next))return P.next;if(B<=P.y&&B>=P.next.y&&P.next.y!==P.y){const we=P.x+(B-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(we<=O&&we>J&&(J=we,W=P.x=P.x&&P.x>=ne&&O!==P.x&&W2e(BW.x||P.x===W.x&&xet(W,P)))&&(W=P,ue=we)}P=P.next}while(P!==ee);return W}(p,c);if(!m)return c;const y=K2e(m,p);return Mb(y,y.next),Mb(m,m.next)}function xet(p,c){return xc(p.prev,p,c.prev)<0&&xc(c.next,p,p.next)<0}function ide(p,c,m,y,k){return(p=1431655765&((p=858993459&((p=252645135&((p=16711935&((p=(p-m)*k|0)|p<<8))|p<<4))|p<<2))|p<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-y)*k|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function yet(p){let c=p,m=p;do(c.x=(p-P)*(E-O)&&(p-P)*(y-O)>=(m-P)*(c-O)&&(m-P)*(E-O)>=(k-P)*(y-O)}function BT(p,c,m,y,k,E,P,O){return!(p===P&&c===O)&&W2e(p,c,m,y,k,E,P,O)}function vet(p,c){return p.next.i!==c.i&&p.prev.i!==c.i&&!function(m,y){let k=m;do{if(k.i!==m.i&&k.next.i!==m.i&&k.i!==y.i&&k.next.i!==y.i&&G2e(k,k.next,m,y))return!0;k=k.next}while(k!==m);return!1}(p,c)&&($T(p,c)&&$T(c,p)&&function(m,y){let k=m,E=!1;const P=(m.x+y.x)/2,O=(m.y+y.y)/2;do k.y>O!=k.next.y>O&&k.next.y!==k.y&&P<(k.next.x-k.x)*(O-k.y)/(k.next.y-k.y)+k.x&&(E=!E),k=k.next;while(k!==m);return E}(p,c)&&(xc(p.prev,p,c.prev)||xc(p,c.prev,c))||gC(p,c)&&xc(p.prev,p,p.next)>0&&xc(c.prev,c,c.next)>0)}function xc(p,c,m){return(c.y-p.y)*(m.x-c.x)-(c.x-p.x)*(m.y-c.y)}function gC(p,c){return p.x===c.x&&p.y===c.y}function G2e(p,c,m,y){const k=GD(xc(p,c,m)),E=GD(xc(p,c,y)),P=GD(xc(m,y,p)),O=GD(xc(m,y,c));return k!==E&&P!==O||!(k!==0||!WD(p,m,c))||!(E!==0||!WD(p,y,c))||!(P!==0||!WD(m,p,y))||!(O!==0||!WD(m,c,y))}function WD(p,c,m){return c.x<=Math.max(p.x,m.x)&&c.x>=Math.min(p.x,m.x)&&c.y<=Math.max(p.y,m.y)&&c.y>=Math.min(p.y,m.y)}function GD(p){return p>0?1:p<0?-1:0}function $T(p,c){return xc(p.prev,p,p.next)<0?xc(p,c,p.next)>=0&&xc(p,p.prev,c)>=0:xc(p,c,p.prev)<0||xc(p,p.next,c)<0}function K2e(p,c){const m=ode(p.i,p.x,p.y),y=ode(c.i,c.x,c.y),k=p.next,E=c.prev;return p.next=c,c.prev=p,m.next=k,k.prev=m,y.next=m,m.prev=y,E.next=y,y.prev=E,y}function Z2e(p,c,m,y){const k=ode(p,c,m);return y?(k.next=y.next,k.prev=y,y.next.prev=k,y.next=k):(k.prev=k,k.next=k),k}function qT(p){p.next.prev=p.prev,p.prev.next=p.next,p.prevZ&&(p.prevZ.nextZ=p.nextZ),p.nextZ&&(p.nextZ.prevZ=p.prevZ)}function ode(p,c,m){return{i:p,x:c,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function UT(p,c){const m=p.length;if(m<=1)return[p];const y=[];let k,E;for(let P=0;P1)for(let P=0;P=Gs&&m>=Gs}static evaluate(c){if(c.length===0)return new Iy;let m=[];for(const B of c)m.push(...B.portals);if(m.length===0)return new Iy;for(const B of m){const W=B.va,J=B.vb;(Iy.isOnBorder(W.x,J.x)||Iy.isOnBorder(W.y,J.y))&&(B.type="border")}const y=m.filter(B=>B.type!=="unevaluated"),k=m.filter(B=>B.type==="unevaluated");if(k.length===0)return new Iy;k.sort((B,W)=>B.hash===W.hash?B.isTunnel===W.isTunnel?0:B.isTunnel?-1:1:B.hashB.hashE!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new Um(m,{zoom:y,lut:k},E=>E!=="fill-bridge-guard-rail-color")}addVertices(c,m){const y=this.unevalVertices.length;for(let k=0;k=E.min.x&&ee.x<=E.max.x&&ee.y>=E.min.y&&ee.y<=E.max.y||ne.x>=E.min.x&&ne.x<=E.max.x&&ne.y>=E.min.y&&ne.y<=E.max.y||Qc(ee,ne,O))||this.isOnBorder(ee.x,ne.x)||this.isOnBorder(ee.y,ne.y))continue;const ie=ph.computeEdgeHash(this.unevalVertices[W],this.unevalVertices[J]);let ue,we=this.vertexHashLookup.get(ph.computePosHash(ee));we!=null?ue=we.next:(we=this.vertexHashLookup.get(ph.computePosHash(ne)),ue=we!=null?we.prev:ie),this.unevalEdges.push({polygonIdx:c,a:W,b:J,hash:ie,portalHash:ue,isTunnel:k,type:"unevaluated",featureInfo:P})}}addPortalCandidates(c,m,y,k,E){if(m.length===0)return;this.portalPolygons.add(c,{geometry:m,zLevel:E});const P=m[0];this.vertexHashLookup.clear();let O=ph.computeEdgeHash(P[P.length-2],P[P.length-1]);for(let B=0;B({vertexOffset:0,primitiveOffset:this.indexArray.length}),y=ne=>{ne.primitiveLength=this.indexArray.length-ne.primitiveOffset},k=new bet(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const E=m(),P=m(),O=m(),B=(ne,ie)=>{ne.sort((we,Ee)=>we.type===ie&&Ee.type!==ie?-1:we.type!==ie&&Ee.type===ie?1:0);const ue=ne.findIndex(we=>we.type!==ie);return ue>=0?ue:ne.length};let W=0;this.unevalEdges.length>0&&(W=B(this.unevalEdges,"none"),this.constructBridgeStructures(k,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},this.tileToMeters)),y(O);const J=m(),ee=m();if(this.unevalEdges.length>0){const ne=this.unevalEdges.splice(W),ie=B(ne,"tunnel")+W;this.unevalEdges.push(...ne),this.constructTunnelStructures(k,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},{min:W,max:ie})}y(J),k.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),y(ee),k.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),y(P),k.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),y(E),this.maskSegments=io.simpleSegment(0,ee.primitiveOffset,0,ee.primitiveLength),this.depthSegments=io.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=io.simpleSegment(0,O.primitiveOffset,0,O.primitiveLength),this.renderableTunnelSegments=io.simpleSegment(0,J.primitiveOffset,0,J.primitiveLength),this.shadowCasterSegments=io.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(c,m,y,k,E,P,O,B){this.bridgeProgramConfigurations.updatePaintArrays(c,m,E,y,k,P,O,B),this.tunnelProgramConfigurations.updatePaintArrays(c,m,E,y,k,P,O,B)}upload(c){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=c.createVertexBuffer(this.vertexPositions,cet.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,det.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(c),this.tunnelProgramConfigurations.upload(c))}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(c,m,y,k,E){const P=(O,B)=>{for(let W=0;Wle(Ds,m[Fs].x,m[Fs].y,y[Fs]*B),ee=te(),ne=te(),ie=te(),ue=te(),we=te(),Ee=(Ds,Fs)=>{const Es=O.get(ph.computePosHash(m[Fs])),Is=Es.from,us=Es.to;if(!Is||!us)return;J(ee,Is),J(ne,Fs),J(ie,us),at(ue),rt(ee,ne)||(je(we,ne,ee),Ie(ue,we)),rt(ie,ne)||(je(we,ie,ne),de(ue,ue,Ie(we,we)));const as=He(ue);return as>0?ke(Ds,ue,1/as):void 0};let Te=Number.POSITIVE_INFINITY;this.sortSubarray(k,E.min,E.max,(Ds,Fs)=>Ds.featureInfo.featureIndex-Fs.featureInfo.featureIndex);const Ue=te(),Ye=te(),st=te(),_t=te(),ft=te(),St=te(),Pt=te(),Ft=te(),ns=te(),Wt=[te(),te(),te(),te()],hs=[te(),te(),te(),te()],ys=[{coord:new rs(0,0),height:0},{coord:new rs(0,0),height:0}],vs=(Ds,Fs)=>Ds>Fs;for(let Ds=E.min;DsTe.featureInfo.featureIndex-Ue.featureInfo.featureIndex;this.sortSubarray(k,E.min,E.max,B),this.sortSubarray(k,P.min,P.max,B);const W=Te=>Ie(Te,Te),J=[{coord:new rs(0,0),height:0},{coord:new rs(0,0),height:0}],ee=(Te,Ue)=>TeO.hash===B.hash?B.polygonIdx-O.polygonIdx:B.hash>O.hash?1:-1);let y=0,k=0,E=0,P=m[y].polygonIdx;do k++,(k===m.length||m[y].hash!==m[k].hash)&&((k-y==1||m[k-1].polygonIdx!==P)&&(EW.portalHashJ.hash?O++:J.hash>W.portalHash?B++:(W.type=J.type,O++)}}}isOnBorder(c,m){return c<=0&&m<=0||c>=Gs&&m>=Gs}addFeatureSection(c,m,y,k){return c!==m&&(m=c,y.push({featureIndex:c,vertexStart:k.getVertexCount()}),k.clearVertexLookup()),m}sortSubarray(c,m,y,k){const E=c.slice(m,y);E.sort(k),c.splice(m,E.length,...E)}static computeEdgeHash(c,m){return(c.y===m.y&&c.x>m.x||c.y>m.y)&&([c,m]=[m,c]),BigInt(ph.computePosHash(c))<<32n|BigInt(ph.computePosHash(m))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}var Q2e,J2e={exports:{}},eje=(Q2e||(Q2e=1,function(p){function c(gt,wt){return gt>wt?1:gt0){var Ir=Os+Math.floor(ar/2),zr={key:wt[Ir],data:ms[Ir],parent:gt};return zr.left=k(zr,wt,ms,Os,Ir),zr.right=k(zr,wt,ms,Ir+1,nr),zr}return null}function E(gt,wt,ms,Os,nr){if(!(ms>=Os)){for(var ar=gt[ms+Os>>1],Ir=ms-1,zr=Os+1;;){do Ir++;while(nr(gt[Ir],ar)<0);do zr--;while(nr(gt[zr],ar)>0);if(Ir>=zr)break;var kn=gt[Ir];gt[Ir]=gt[zr],gt[zr]=kn,kn=wt[Ir],wt[Ir]=wt[zr],wt[zr]=kn}E(gt,wt,ms,zr,nr),E(gt,wt,zr+1,Os,nr)}}m.prototype.rotateLeft=function(gt){var wt=gt.right;wt&&(gt.right=wt.left,wt.left&&(wt.left.parent=gt),wt.parent=gt.parent),gt.parent?gt===gt.parent.left?gt.parent.left=wt:gt.parent.right=wt:this._root=wt,wt&&(wt.left=gt),gt.parent=wt},m.prototype.rotateRight=function(gt){var wt=gt.left;wt&&(gt.left=wt.right,wt.right&&(wt.right.parent=gt),wt.parent=gt.parent),gt.parent?gt===gt.parent.left?gt.parent.left=wt:gt.parent.right=wt:this._root=wt,wt&&(wt.right=gt),gt.parent=wt},m.prototype._splay=function(gt){for(;gt.parent;){var wt=gt.parent;wt.parent?wt.left===gt&&wt.parent.left===wt?(this.rotateRight(wt.parent),this.rotateRight(wt)):wt.right===gt&&wt.parent.right===wt?(this.rotateLeft(wt.parent),this.rotateLeft(wt)):wt.left===gt&&wt.parent.right===wt?(this.rotateRight(wt),this.rotateLeft(wt)):(this.rotateLeft(wt),this.rotateRight(wt)):wt.left===gt?this.rotateRight(wt):this.rotateLeft(wt)}},m.prototype.splay=function(gt){for(var wt,ms,Os,nr,ar;gt.parent;)(ms=(wt=gt.parent).parent)&&ms.parent?((Os=ms.parent).left===ms?Os.left=gt:Os.right=gt,gt.parent=Os):(gt.parent=null,this._root=gt),nr=gt.left,ar=gt.right,gt===wt.left?(ms&&(ms.left===wt?(wt.right?(ms.left=wt.right,ms.left.parent=ms):ms.left=null,wt.right=ms,ms.parent=wt):(nr?(ms.right=nr,nr.parent=ms):ms.right=null,gt.left=ms,ms.parent=gt)),ar?(wt.left=ar,ar.parent=wt):wt.left=null,gt.right=wt,wt.parent=gt):(ms&&(ms.right===wt?(wt.left?(ms.right=wt.left,ms.right.parent=ms):ms.right=null,wt.left=ms,ms.parent=wt):(ar?(ms.left=ar,ar.parent=ms):ms.left=null,gt.right=ms,ms.parent=gt)),nr?(wt.right=nr,nr.parent=wt):wt.right=null,gt.left=wt,wt.parent=gt)},m.prototype.replace=function(gt,wt){gt.parent?gt===gt.parent.left?gt.parent.left=wt:gt.parent.right=wt:this._root=wt,wt&&(wt.parent=gt.parent)},m.prototype.minNode=function(gt){if(gt===void 0&&(gt=this._root),gt)for(;gt.left;)gt=gt.left;return gt},m.prototype.maxNode=function(gt){if(gt===void 0&&(gt=this._root),gt)for(;gt.right;)gt=gt.right;return gt},m.prototype.insert=function(gt,wt){var ms=this._root,Os=null,nr=this._compare;if(this._noDuplicates)for(;ms;){if(Os=ms,nr(ms.key,gt)===0)return;ms=nr(ms.key,gt)<0?ms.right:ms.left}else for(;ms;)Os=ms,ms=nr(ms.key,gt)<0?ms.right:ms.left;return ms={key:gt,data:wt,left:null,right:null,parent:Os},Os?nr(Os.key,ms.key)<0?Os.right=ms:Os.left=ms:this._root=ms,this.splay(ms),this._size++,ms},m.prototype.find=function(gt){for(var wt=this._root,ms=this._compare;wt;){var Os=ms(wt.key,gt);if(Os<0)wt=wt.right;else{if(!(Os>0))return wt;wt=wt.left}}return null},m.prototype.contains=function(gt){for(var wt=this._root,ms=this._compare;wt;){var Os=ms(gt,wt.key);if(Os===0)return!0;wt=Os<0?wt.left:wt.right}return!1},m.prototype.remove=function(gt){var wt=this.find(gt);if(!wt)return!1;if(this.splay(wt),wt.left)if(wt.right){var ms=this.minNode(wt.right);ms.parent!==wt&&(this.replace(ms,ms.right),ms.right=wt.right,ms.right.parent=ms),this.replace(wt,ms),ms.left=wt.left,ms.left.parent=ms}else this.replace(wt,wt.left);else this.replace(wt,wt.right);return this._size--,!0},m.prototype.removeNode=function(gt){if(!gt)return!1;if(this.splay(gt),gt.left)if(gt.right){var wt=this.minNode(gt.right);wt.parent!==gt&&(this.replace(wt,wt.right),wt.right=gt.right,wt.right.parent=wt),this.replace(gt,wt),wt.left=gt.left,wt.left.parent=wt}else this.replace(gt,gt.left);else this.replace(gt,gt.right);return this._size--,!0},m.prototype.erase=function(gt){var wt=this.find(gt);if(wt){this.splay(wt);var ms=wt.left,Os=wt.right,nr=null;ms&&(ms.parent=null,nr=this.maxNode(ms),this.splay(nr),this._root=nr),Os&&(ms?nr.right=Os:this._root=Os,Os.parent=nr),this._size--}},m.prototype.pop=function(){var gt=this._root,wt=null;if(gt){for(;gt.left;)gt=gt.left;wt={key:gt.key,data:gt.data},this.remove(gt.key)}return wt},m.prototype.next=function(gt){var wt=gt;if(wt)if(wt.right)for(wt=wt.right;wt&&wt.left;)wt=wt.left;else for(wt=gt.parent;wt&&wt.right===gt;)gt=wt,wt=wt.parent;return wt},m.prototype.prev=function(gt){var wt=gt;if(wt)if(wt.left)for(wt=wt.left;wt&&wt.right;)wt=wt.right;else for(wt=gt.parent;wt&&wt.left===gt;)gt=wt,wt=wt.parent;return wt},m.prototype.forEach=function(gt){for(var wt=this._root,ms=[],Os=!1,nr=0;!Os;)wt?(ms.push(wt),wt=wt.left):ms.length>0?(gt(wt=ms.pop(),nr++),wt=wt.right):Os=!0;return this},m.prototype.range=function(gt,wt,ms,Os){for(var nr=[],ar=this._compare,Ir=this._root;nr.length!==0||Ir;)if(Ir)nr.push(Ir),Ir=Ir.left;else{if(ar((Ir=nr.pop()).key,wt)>0)break;if(ar(Ir.key,gt)>=0&&ms.call(Os,Ir))return this;Ir=Ir.right}return this},m.prototype.keys=function(){for(var gt=this._root,wt=[],ms=[],Os=!1;!Os;)gt?(wt.push(gt),gt=gt.left):wt.length>0?(gt=wt.pop(),ms.push(gt.key),gt=gt.right):Os=!0;return ms},m.prototype.values=function(){for(var gt=this._root,wt=[],ms=[],Os=!1;!Os;)gt?(wt.push(gt),gt=gt.left):wt.length>0?(gt=wt.pop(),ms.push(gt.data),gt=gt.right):Os=!0;return ms},m.prototype.at=function(gt){for(var wt=this._root,ms=[],Os=!1,nr=0;!Os;)if(wt)ms.push(wt),wt=wt.left;else if(ms.length>0){if(wt=ms.pop(),nr===gt)return wt;nr++,wt=wt.right}else Os=!0;return null},m.prototype.load=function(gt,wt,ms){if(gt===void 0&&(gt=[]),wt===void 0&&(wt=[]),ms===void 0&&(ms=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var Os=gt.length;return ms&&E(gt,wt,0,Os-1,this._compare),this._root=k(null,gt,wt,0,Os),this._size=Os,this},m.prototype.min=function(){var gt=this.minNode(this._root);return gt?gt.key:null},m.prototype.max=function(){var gt=this.maxNode(this._root);return gt?gt.key:null},m.prototype.isEmpty=function(){return this._root===null},y.size.get=function(){return this._size},m.createTree=function(gt,wt,ms,Os,nr){return new m(ms,nr).load(gt,wt,Os)},Object.defineProperties(m.prototype,y);var P=0,O=1,B=2,W=3,J=0,ee=1,ne=2,ie=3;function ue(gt,wt,ms){wt===null?(gt.inOut=!1,gt.otherInOut=!0):(gt.isSubject===wt.isSubject?(gt.inOut=!wt.inOut,gt.otherInOut=wt.otherInOut):(gt.inOut=!wt.otherInOut,gt.otherInOut=wt.isVertical()?!wt.inOut:wt.inOut),wt&&(gt.prevInResult=!we(wt,ms)||wt.isVertical()?wt.prevInResult:wt));var Os=we(gt,ms);gt.resultTransition=Os?function(nr,ar){var Ir,zr=!nr.inOut,kn=!nr.otherInOut;switch(ar){case J:Ir=zr&&kn;break;case ee:Ir=zr||kn;break;case ie:Ir=zr^kn;break;case ne:Ir=nr.isSubject?zr&&!kn:kn&&!zr}return Ir?1:-1}(gt,ms):0}function we(gt,wt){switch(gt.type){case P:switch(wt){case J:return!gt.otherInOut;case ee:return gt.otherInOut;case ne:return gt.isSubject&>.otherInOut||!gt.isSubject&&!gt.otherInOut;case ie:return!0}break;case B:return wt===J||wt===ee;case W:return wt===ne;case O:return!1}return!1}var Ee=function(gt,wt,ms,Os,nr){this.left=wt,this.point=gt,this.otherEvent=ms,this.isSubject=Os,this.type=nr||P,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},Te={inResult:{configurable:!0}};function Ue(gt,wt){return gt[0]===wt[0]&>[1]===wt[1]}Ee.prototype.isBelow=function(gt){var wt=this.point,ms=this.otherEvent.point;return this.left?(wt[0]-gt[0])*(ms[1]-gt[1])-(ms[0]-gt[0])*(wt[1]-gt[1])>0:(ms[0]-gt[0])*(wt[1]-gt[1])-(wt[0]-gt[0])*(ms[1]-gt[1])>0},Ee.prototype.isAbove=function(gt){return!this.isBelow(gt)},Ee.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Te.inResult.get=function(){return this.resultTransition!==0},Ee.prototype.clone=function(){var gt=new Ee(this.point,this.left,this.otherEvent,this.isSubject,this.type);return gt.contourId=this.contourId,gt.resultTransition=this.resultTransition,gt.prevInResult=this.prevInResult,gt.isExteriorRing=this.isExteriorRing,gt.inOut=this.inOut,gt.otherInOut=this.otherInOut,gt},Object.defineProperties(Ee.prototype,Te);var Ye=11102230246251565e-32,st=134217729,_t=(3+8*Ye)*Ye;function ft(gt,wt,ms,Os,nr){var ar,Ir,zr,kn,Fn=wt[0],Vn=Os[0],na=0,en=0;Vn>Fn==Vn>-Fn?(ar=Fn,Fn=wt[++na]):(ar=Vn,Vn=Os[++en]);var cn=0;if(naFn==Vn>-Fn?(zr=ar-((Ir=Fn+ar)-Fn),Fn=wt[++na]):(zr=ar-((Ir=Vn+ar)-Vn),Vn=Os[++en]),ar=Ir,zr!==0&&(nr[cn++]=zr);naFn==Vn>-Fn?(zr=ar-((Ir=ar+Fn)-(kn=Ir-ar))+(Fn-kn),Fn=wt[++na]):(zr=ar-((Ir=ar+Vn)-(kn=Ir-ar))+(Vn-kn),Vn=Os[++en]),ar=Ir,zr!==0&&(nr[cn++]=zr);for(;na0!=na>0)return en;var cn=Math.abs(Vn+na);return Math.abs(en)>=Pt*cn?en:-function(Ca,Ra,Fa,ai,wi,fi,Ha){var Qa,zn,pa,Ji,Yr,aa,yi,Ci,Li,Oo,Mi,Xr,co,ii,Hi,bl,nc,nl,al=Ca-wi,Fl=Fa-wi,bu=Ra-fi,Ti=ai-fi;Wt[0]=(Hi=(Ci=al-(yi=(aa=st*al)-(aa-al)))*(Oo=Ti-(Li=(aa=st*Ti)-(aa-Ti)))-((ii=al*Ti)-yi*Li-Ci*Li-yi*Oo))-((Mi=Hi-(nc=(Ci=bu-(yi=(aa=st*bu)-(aa-bu)))*(Oo=Fl-(Li=(aa=st*Fl)-(aa-Fl)))-((bl=bu*Fl)-yi*Li-Ci*Li-yi*Oo)))+(Yr=Hi-Mi))+(Yr-nc),Wt[1]=(co=ii-((Xr=ii+Mi)-(Yr=Xr-ii))+(Mi-Yr))-((Mi=co-bl)+(Yr=co-Mi))+(Yr-bl),Wt[2]=Xr-((nl=Xr+Mi)-(Yr=nl-Xr))+(Mi-Yr),Wt[3]=nl;var To=function(fx,Jc){for(var Yd=Jc[0],gh=1;gh<4;gh++)Yd+=Jc[gh];return Yd}(0,Wt),Ro=Ft*Ha;if(To>=Ro||-To>=Ro||(Qa=Ca-(al+(Yr=Ca-al))+(Yr-wi),pa=Fa-(Fl+(Yr=Fa-Fl))+(Yr-wi),zn=Ra-(bu+(Yr=Ra-bu))+(Yr-fi),Ji=ai-(Ti+(Yr=ai-Ti))+(Yr-fi),Qa===0&&zn===0&&pa===0&&Ji===0)||(Ro=ns*Ha+_t*Math.abs(To),(To+=al*Ji+Ti*Qa-(bu*pa+Fl*zn))>=Ro||-To>=Ro))return To;Ds[0]=(Hi=(Ci=Qa-(yi=(aa=st*Qa)-(aa-Qa)))*(Oo=Ti-(Li=(aa=st*Ti)-(aa-Ti)))-((ii=Qa*Ti)-yi*Li-Ci*Li-yi*Oo))-((Mi=Hi-(nc=(Ci=zn-(yi=(aa=st*zn)-(aa-zn)))*(Oo=Fl-(Li=(aa=st*Fl)-(aa-Fl)))-((bl=zn*Fl)-yi*Li-Ci*Li-yi*Oo)))+(Yr=Hi-Mi))+(Yr-nc),Ds[1]=(co=ii-((Xr=ii+Mi)-(Yr=Xr-ii))+(Mi-Yr))-((Mi=co-bl)+(Yr=co-Mi))+(Yr-bl),Ds[2]=Xr-((nl=Xr+Mi)-(Yr=nl-Xr))+(Mi-Yr),Ds[3]=nl;var zu=ft(4,Wt,4,Ds,hs);Ds[0]=(Hi=(Ci=al-(yi=(aa=st*al)-(aa-al)))*(Oo=Ji-(Li=(aa=st*Ji)-(aa-Ji)))-((ii=al*Ji)-yi*Li-Ci*Li-yi*Oo))-((Mi=Hi-(nc=(Ci=bu-(yi=(aa=st*bu)-(aa-bu)))*(Oo=pa-(Li=(aa=st*pa)-(aa-pa)))-((bl=bu*pa)-yi*Li-Ci*Li-yi*Oo)))+(Yr=Hi-Mi))+(Yr-nc),Ds[1]=(co=ii-((Xr=ii+Mi)-(Yr=Xr-ii))+(Mi-Yr))-((Mi=co-bl)+(Yr=co-Mi))+(Yr-bl),Ds[2]=Xr-((nl=Xr+Mi)-(Yr=nl-Xr))+(Mi-Yr),Ds[3]=nl;var wl=ft(zu,hs,4,Ds,ys);Ds[0]=(Hi=(Ci=Qa-(yi=(aa=st*Qa)-(aa-Qa)))*(Oo=Ji-(Li=(aa=st*Ji)-(aa-Ji)))-((ii=Qa*Ji)-yi*Li-Ci*Li-yi*Oo))-((Mi=Hi-(nc=(Ci=zn-(yi=(aa=st*zn)-(aa-zn)))*(Oo=pa-(Li=(aa=st*pa)-(aa-pa)))-((bl=zn*pa)-yi*Li-Ci*Li-yi*Oo)))+(Yr=Hi-Mi))+(Yr-nc),Ds[1]=(co=ii-((Xr=ii+Mi)-(Yr=Xr-ii))+(Mi-Yr))-((Mi=co-bl)+(Yr=co-Mi))+(Yr-bl),Ds[2]=Xr-((nl=Xr+Mi)-(Yr=nl-Xr))+(Mi-Yr),Ds[3]=nl;var Fp=ft(wl,ys,4,Ds,vs);return vs[Fp-1]}(nr,ar,Ir,zr,kn,Fn,cn)}(gt[0],gt[1],wt[0],wt[1],ms[0],ms[1]);return Os>0?-1:Os<0?1:0}function Es(gt,wt){var ms=gt.point,Os=wt.point;return ms[0]>Os[0]?1:ms[0]Os[1]?1:-1:function(nr,ar,Ir,zr){return nr.left!==ar.left?nr.left?1:-1:Fs(Ir,nr.otherEvent.point,ar.otherEvent.point)!==0?nr.isBelow(ar.otherEvent.point)?-1:1:!nr.isSubject&&ar.isSubject?1:-1}(gt,wt,ms)}function Is(gt,wt,ms){var Os=new Ee(wt,!1,gt,gt.isSubject),nr=new Ee(wt,!0,gt.otherEvent,gt.isSubject);return Ue(gt.point,gt.otherEvent.point)&&console.warn("what is that, a collapsed segment?",gt),Os.contourId=nr.contourId=gt.contourId,Es(nr,gt.otherEvent)>0&&(gt.otherEvent.left=!0,nr.left=!1),gt.otherEvent.otherEvent=nr,gt.otherEvent=Os,ms.push(nr),ms.push(Os),ms}function us(gt,wt){return gt[0]*wt[1]-gt[1]*wt[0]}function as(gt,wt){return gt[0]*wt[0]+gt[1]*wt[1]}function Ls(gt,wt,ms){var Os=function(kn,Fn,Vn,na,en){var cn=[Fn[0]-kn[0],Fn[1]-kn[1]],Ca=[na[0]-Vn[0],na[1]-Vn[1]];function Ra(aa,yi,Ci){return[aa[0]+yi*Ci[0],aa[1]+yi*Ci[1]]}var Fa=[Vn[0]-kn[0],Vn[1]-kn[1]],ai=us(cn,Ca),wi=ai*ai,fi=as(cn,cn);if(wi>0){var Ha=us(Fa,Ca)/ai;if(Ha<0||Ha>1)return null;var Qa=us(Fa,cn)/ai;return Qa<0||Qa>1?null:Ha===0||Ha===1?[Ra(kn,Ha,cn)]:Qa===0||Qa===1?[Ra(Vn,Qa,Ca)]:[Ra(kn,Ha,cn)]}if((wi=(ai=us(Fa,cn))*ai)>0)return null;var zn=as(cn,Fa)/fi,pa=zn+as(cn,Ca)/fi,Ji=Math.min(zn,pa),Yr=Math.max(zn,pa);return Ji<=1&&Yr>=0?Ji===1?[Ra(kn,Ji>0?Ji:0,cn)]:Yr===0?[Ra(kn,Yr<1?Yr:1,cn)]:[Ra(kn,Ji>0?Ji:0,cn),Ra(kn,Yr<1?Yr:1,cn)]:null}(gt.point,gt.otherEvent.point,wt.point,wt.otherEvent.point),nr=Os?Os.length:0;if(nr===0||nr===1&&(Ue(gt.point,wt.point)||Ue(gt.otherEvent.point,wt.otherEvent.point))||nr===2&>.isSubject===wt.isSubject)return 0;if(nr===1)return Ue(gt.point,Os[0])||Ue(gt.otherEvent.point,Os[0])||Is(gt,Os[0],ms),Ue(wt.point,Os[0])||Ue(wt.otherEvent.point,Os[0])||Is(wt,Os[0],ms),1;var ar=[],Ir=!1,zr=!1;return Ue(gt.point,wt.point)?Ir=!0:Es(gt,wt)===1?ar.push(wt,gt):ar.push(gt,wt),Ue(gt.otherEvent.point,wt.otherEvent.point)?zr=!0:Es(gt.otherEvent,wt.otherEvent)===1?ar.push(wt.otherEvent,gt.otherEvent):ar.push(gt.otherEvent,wt.otherEvent),Ir&&zr||Ir?(wt.type=O,gt.type=wt.inOut===gt.inOut?B:W,Ir&&!zr&&Is(ar[1].otherEvent,ar[0].point,ms),2):zr?(Is(ar[0],ar[1].point,ms),3):ar[0]!==ar[3].otherEvent?(Is(ar[0],ar[1].point,ms),Is(ar[1],ar[2].point,ms),3):(Is(ar[0],ar[1].point,ms),Is(ar[3].otherEvent,ar[2].point,ms),3)}function Ks(gt,wt){if(gt===wt)return 0;if(Fs(gt.point,gt.otherEvent.point,wt.point)!==0||Fs(gt.point,gt.otherEvent.point,wt.otherEvent.point)!==0)return Ue(gt.point,wt.point)?gt.isBelow(wt.otherEvent.point)?-1:1:gt.point[0]===wt.point[0]?gt.point[1]wt.contourId?1:-1:Es(gt,wt)===1?1:-1}var $s=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function Pr(gt,wt,ms,Os){var nr,ar=gt+1,Ir=wt[gt].point,zr=wt.length;for(arOs;)ar--;return ar}$s.prototype.isExterior=function(){return this.holeOf==null};var lr=wr,pr=wr;function wr(gt,wt){if(!(this instanceof wr))return new wr(gt,wt);if(this.data=gt||[],this.length=this.data.length,this.compare=wt||Wn,this.length>0)for(var ms=(this.length>>1)-1;ms>=0;ms--)this._down(ms)}function Wn(gt,wt){return gtwt?1:0}wr.prototype={push:function(gt){this.data.push(gt),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var gt=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),gt}},peek:function(){return this.data[0]},_up:function(gt){for(var wt=this.data,ms=this.compare,Os=wt[gt];gt>0;){var nr=gt-1>>1,ar=wt[nr];if(ms(Os,ar)>=0)break;wt[gt]=ar,gt=nr}wt[gt]=Os},_down:function(gt){for(var wt=this.data,ms=this.compare,Os=this.length>>1,nr=wt[gt];gt=0)break;wt[gt]=zr,gt=ar}wt[gt]=nr}},lr.default=pr;var qs=Math.max,jr=Math.min,hn=0;function ua(gt,wt,ms,Os,nr,ar){var Ir,zr,kn,Fn,Vn,na;for(Ir=0,zr=gt.length-1;Ir0?na.left=!0:Vn.left=!0;var en=kn[0],cn=kn[1];nr[0]=jr(nr[0],en),nr[1]=jr(nr[1],cn),nr[2]=qs(nr[2],en),nr[3]=qs(nr[3],cn),Os.push(Vn),Os.push(na)}}var fa=[];function Mn(gt,wt,ms){typeof gt[0][0][0]=="number"&&(gt=[gt]),typeof wt[0][0][0]=="number"&&(wt=[wt]);var Os=function(cn,Ca,Ra){var Fa=null;return cn.length*Ca.length==0&&(Ra===J?Fa=fa:Ra===ne?Fa=cn:Ra!==ee&&Ra!==ie||(Fa=cn.length===0?Ca:cn)),Fa}(gt,wt,ms);if(Os)return Os===fa?null:Os;var nr=[1/0,1/0,-1/0,-1/0],ar=[1/0,1/0,-1/0,-1/0],Ir=function(cn,Ca,Ra,Fa,ai){var wi,fi,Ha,Qa,zn,pa,Ji=new lr(null,Es);for(Ha=0,Qa=cn.length;HaFa[2]||Fa[0]>Ra[2]||Ra[1]>Fa[3]||Fa[1]>Ra[3])&&(ai===J?wi=fa:ai===ne?wi=cn:ai!==ee&&ai!==ie||(wi=cn.concat(Ca))),wi}(gt,wt,nr,ar,ms))return Os===fa?null:Os;for(var zr=function(cn){var Ca,Ra,Fa=function(Ha){var Qa,zn,pa,Ji,Yr=[];for(zn=0,pa=Ha.length;zn0){var Mi=aa[Oo];if(Mi.holeOf!=null){var Xr=Mi.holeOf;aa[Xr].holeIds.push(yi),Ci.holeOf=Xr,Ci.depth=aa[Oo].depth}else aa[Oo].holeIds.push(yi),Ci.holeOf=Oo,Ci.depth=aa[Oo].depth+1}else Ci.holeOf=null,Ci.depth=aa[Oo].depth}else Ci.holeOf=null,Ci.depth=0;return Ci}(Fa[Ca],wi,Ha),zn=function(Yr){ai[Yr]=!0,Yr=Fa.length)&&Fa[pa];);wi.push(Qa)}};for(Ca=0,Ra=Fa.length;CaJi||wi===ne&&Yr.point[0]>Fa[2])break;if(Yr.left){Ha=fi=zn.insert(Yr),fi=fi!==(Qa=zn.minNode())?zn.prev(fi):null,Ha=zn.next(Ha);var aa=fi?fi.key:null;if(ue(Yr,aa,wi),Ha&&Ls(Yr,Ha.key,cn)===2&&(ue(Yr,aa,wi),ue(Ha.key,Yr,wi)),fi&&Ls(fi.key,Yr,cn)===2){var yi=fi;ue(aa,(yi=yi!==Qa?zn.prev(yi):null)?yi.key:null,wi),ue(Yr,aa,wi)}}else Ha=fi=zn.find(Yr=Yr.otherEvent),fi&&Ha&&(fi=fi!==Qa?zn.prev(fi):null,Ha=zn.next(Ha),zn.remove(Yr),Ha&&fi&&Ls(fi.key,Ha.key,cn))}return pa}(Ir,0,0,nr,ar,ms)),kn=[],Fn=0;Fn * @license MIT * @preserve */function KD(p,c,m,y){const k=[],E=y===0?(P,O,B,W,J,ee)=>{P.push(new rs(ee,B+(ee-O)/(W-O)*(J-B)))}:(P,O,B,W,J,ee)=>{P.push(new rs(O+(ee-B)/(J-B)*(W-O),ee))};for(const P of p){const O=[];for(const B of P){if(B.length<=2)continue;const W=[];for(let ne=0;nec&&E(W,ie,ue,we,Ee,c):Te>m?Ue=c&&E(W,ie,ue,we,Ee,c),Ue>m&&Te<=m&&E(W,ie,ue,we,Ee,m)}let J=B[B.length-1];const ee=y===0?J.x:J.y;ee>=c&&ee<=m&&W.push(J),W.length&&(J=W[W.length-1],W[0].x===J.x&&W[0].y===J.y||W.push(W[0]),O.push(W))}O.length&&k.push(O)}return k}function wet(p,c){const m=dde(p),y=dde([c]),k=eje.intersection(m,y);return k==null?[]:tje(k)}function jet(p,c){let y=dde(p,65536);const k=[];for(;c.valid();c.next()){const[E,P]=c.get(),O=E.x*65536,B=E.y*65536,W=P.x*65536,J=P.y*65536,ee=W-O,ne=J-B,ie=Math.hypot(ee,ne);if(ie===0)continue;const ue=Math.trunc(ne/ie*3),we=-Math.trunc(ee/ie*3);k.push([[[O,B],[W,J],[W+ue,J+we],[O+ue,B+we],[O,B]]])}return k.length>0&&(y=eje.diff(y,k)),tje(y,1/65536)}function dde(p,c=1){return[p.map(m=>m.map(y=>[y.x*c,y.y*c]))]}function tje(p,c=1){return p.map(m=>m.map((y,k)=>{const E=y.map(P=>new rs(P[0]*c,P[1]*c).round());return k>0&&E.reverse(),E}))}class ude{constructor(c,m){this.layoutVertexArray=new lx,this.indexArray=new yl,this.lineIndexArray=new hh,this.triangleSegments=new io,this.lineSegments=new io,this.programConfigurations=new Um(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new Ff)}update(c,m,y,k,E,P,O,B){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,B)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,iet.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.lineIndexBuffer=c.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,oet.members))),this.programConfigurations.upload(c),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(c,m,y,k,E,P,O){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,m,y,k,E,P,void 0,O)}}class hde{constructor(c){this.zoom=c.zoom,this.pixelRatio=c.pixelRatio,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=c.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=c.lut,this.bufferData=new ude(c,!1),this.elevationBufferData=new ude(c,!0),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=c.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=c.sourceLayerIndex,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){this.hasPattern=lde("fill",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("fill-sort-key"),P=[];for(const{feature:O,id:B,index:W,sourceLayerIndex:J}of c){const ee=this.layers[0]._featureFilter.needGeometry,ne=Ht(O,ee);if(!this.layers[0]._featureFilter.filter(new Ii(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ne,y))continue;const ie=E?E.evaluate(ne,{},y,m.availableImages):void 0,ue={id:B,properties:O.properties,type:O.type,sourceLayerIndex:J,index:W,geometry:ee?ne.geometry:Et(O,y,k),patterns:{},sortKey:ie};P.push(ue)}E&&P.sort((O,B)=>O.sortKey-B.sortKey);for(const O of P){const{geometry:B,index:W,sourceLayerIndex:J}=O;if(this.hasPattern){const ee=cde("fill",this.layers,O,this.zoom,this.pixelRatio,m);this.patternFeatures.push(ee)}else this.addFeature(O,B,W,y,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(c[W].feature,B,W,J,this.index)}}update(c,m,y,k,E,P,O){this.bufferData.update(c,m,y,k,E,P,O,this.worldview),this.elevationBufferData.update(c,m,y,k,E,P,O,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(c,m,y,k,E,P,O,this.worldview)}addFeatures(c,m,y,k,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,y,k,P,c.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(c){this.bufferData.upload(c),this.elevationBufferData.upload(c),this.elevatedStructures&&this.elevatedStructures.upload(c)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(c,m,y,k,E,P=[],O,B){const W=UT(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(c,W,k,y,B):this.addGeometry(W,this.bufferData),this.bufferData.populatePaintArrays(c,y,E,P,k,O,this.worldview),this.elevationBufferData.populatePaintArrays(c,y,E,P,k,O,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(c,m,y,k,E){this.elevatedStructures&&(this.elevatedStructures.construct(c),this.elevatedStructures.populatePaintArrays(m,y,k,E,this.worldview))}addElevatedRoadFeature(c,m,y,k,E){const P=new Array,O=Ya.getElevationFeature(c,E);if(!O)return void this.addGeometry(m,this.bufferData);{const W=this.clipPolygonsToTile(m,1);W.length>0&&P.push({polygons:W,elevationFeature:O,elevationTileID:y})}const B={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(c,{},y),featureIndex:k};for(const W of P)if(W.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new ph(W.elevationTileID,this.layers,this.zoom,this.lut));const ee=W.elevationFeature.isTunnel();let ne=0;c.properties.hasOwnProperty(es)&&(ne=+c.properties[es]);for(const ie of W.polygons)this.elevatedStructures.addPortalCandidates(W.elevationFeature.id,ie,ee,W.elevationFeature,ne)}W.elevationFeature.constantHeight==null&&(W.polygons=this.prepareElevatedPolygons(W.polygons,W.elevationFeature,W.elevationTileID));const J=new ui(y,W.elevationTileID);this.addElevatedGeometry(W.polygons,J,W.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,k,B)}}addElevatedGeometry(c,m,y,k,E,P){const O={elevation:y,elevationSampler:m,bias:k,index:E,featureInfo:P},[B,W]=this.addGeometry(c,this.elevationBufferData,O);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:B,max:W}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,B),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,W))}addGeometry(c,m,y){let k=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,P=null;y&&(P=y.elevationSampler.constantElevation(y.elevation,y.bias),P!=null&&(k=P,E=P));const O=(B,W,J)=>{if(y!=null)if(W.push(B),P!=null)m.elevatedLayoutVertexArray.emplaceBack(P),J.push(P);else{const ee=y.elevationSampler.pointElevation(B,y.elevation,y.bias);m.elevatedLayoutVertexArray.emplaceBack(ee),J.push(ee),k=Math.min(k,ee),E=Math.max(E,ee)}};for(const B of c){let W=0;for(const Ye of B)W+=Ye.length;const J=m.triangleSegments.prepareSegment(W,m.layoutVertexArray,m.indexArray),ee=J.vertexLength,ne=[],ie=[],ue=[],we=[],Ee=[],Te=m.layoutVertexArray.length;for(const Ye of B){if(Ye.length===0)continue;Ye!==B[0]&&ie.push(ne.length/2);const st=m.lineSegments.prepareSegment(Ye.length,m.layoutVertexArray,m.lineIndexArray),_t=st.vertexLength;y&&Ee.push(m.layoutVertexArray.length-Te),O(Ye[0],ue,we),m.layoutVertexArray.emplaceBack(Ye[0].x,Ye[0].y),m.lineIndexArray.emplaceBack(_t+Ye.length-1,_t),ne.push(Ye[0].x),ne.push(Ye[0].y);for(let ft=1;ft0&&y&&this.elevationMode==="hd-road-base"){const Ye=y.elevation.isTunnel(),st=y.elevation.safeArea,_t=this.elevatedStructures.addVertices(ue,we);this.elevatedStructures.addTriangles(Ue,_t,Ye);const ft=Ee.length;if(ft>0){for(let St=0;St=y&&ie.max.x<=E&&ie.min.y>=k&&ie.max.y<=P?B:W).push(ne)}if(B.length===c.length)return c;const J=[new rs(y,k),new rs(E,k),new rs(E,P),new rs(y,P),new rs(y,k)],ee=B;for(const ne of W)ee.push(...wet(ne,J));return ee}}let sje,rje,nje,aje;vr(hde,"FillBucket",{omit:["layers","patternFeatures"]}),vr(ude,"FillBufferData"),vr(ph,"ElevatedStructures");class ZD{constructor(c,m,y,k){if(this.triangleCount=m.length/3,this.min=new rs(0,0),this.max=new rs(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||c.length===0)return;const[E,P]=[c[0].clone(),c[0].clone()];for(let ee=1;eeee.cellIdx-ne.cellIdx||ee.triIdx-ne.triIdx);let J=0;for(;Jthis.max.x||this.min.x>c.x||c.y>this.max.y||this.min.y>c.y)return;const y=mx(c.x-this.min.x,this.xScale,this.cellsX),k=mx(c.y-this.min.y,this.yScale,this.cellsY),E=this.cells[k*this.cellsX+y];if(E){this._lazyInitLookup();for(let P=0;Pthis.max.x||this.min.x>m.x||c.y>this.max.y||this.min.y>m.y)return;this._lazyInitLookup();const k=mx(c.x-this.min.x,this.xScale,this.cellsX),E=mx(m.x-this.min.x,this.xScale,this.cellsX),P=mx(c.y-this.min.y,this.yScale,this.cellsY),O=mx(m.y-this.min.y,this.yScale,this.cellsY);for(let B=P;B<=O;B++)for(let W=k;W<=E;W++){const J=this.cells[B*this.cellsX+W];if(J)for(let ee=0;eem.fqid),this.index=c.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.footprints=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){for(const y of this.footprints)m.push({footprint:y,id:c})}updateAppearances(c,m,y,k){}populate(c,m,y,k){const E=[];for(const{feature:P,id:O,index:B,sourceLayerIndex:W}of c){const J=this.layers[0]._featureFilter.needGeometry,ee=Ht(P,J);if(!this.layers[0]._featureFilter.filter(new Ii(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ee,y))continue;const ne={id:O,properties:P.properties,type:P.type,sourceLayerIndex:W,index:B,geometry:J?ee.geometry:Et(P,y,k),patterns:{}};E.push(ne)}for(const P of E){const{geometry:O,index:B,sourceLayerIndex:W}=P;this.addFeature(P,O,B,y,{},m.availableImages,m.brightness),m.featureIndex.insert(c[B].feature,O,B,W,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(c){}update(c,m,y,k,E,P,O){}destroy(){}addFeature(c,m,y,k,E,P=[],O){for(const B of UT(m,2)){const W=[],J=[],ee=[],ne=new rs(1/0,1/0),ie=new rs(-1/0,-1/0);for(const Ee of B)if(Ee.length!==0){Ee!==B[0]&&ee.push(J.length/2);for(let Te=0;TeP===k)===void 0}(y,p.clipScope)}function YD(p,c){return p.x-c.x||p.y-c.y}function cje(p,c){return YD(p.min,c.min)===0&&YD(p.max,c.max)===0}function mde(p,c){return!(p.min.x>c.max.x||p.max.xc.max.y||p.max.ynew rs((B.x+E.x*Gs)*O-P.x*Gs,(B.y+E.y*Gs)*O-P.y*Gs))}return pde(m,k,p.indices,0,p.indices.length,0,0)}function hje(p,c,m,y){const k=Math.pow(2,y.z-m.z);return new rs((p+m.x*Gs)*k-y.x*Gs,(c+m.y*Gs)*k-y.y*Gs)}function mje(p,c){const m=[];c.grid.queryPoint(p,m);const y=c.indices,k=c.vertices;for(let E=0;E0&&(y.length>1&&m.push(y),y=[])}return y.length>1&&m.push(y),m}const gde=Ut.types,Let=["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"],Det=["fill-extrusion-flood-light-ground-radius"],Oet=Math.pow(2,13),Ret=Math.pow(2,15)-1,fje=new rs(0,1),Ly=2147483648,gje=7,xje=450;function HT(p,c,m,y,k,E,P,O){p.emplaceBack((c<<1)+P,(m<<1)+E,(Math.floor(y*Oet)<<1)+k,Math.round(O))}function WT(p,c,m){p.emplaceBack(c.x*Gs,c.y*Gs,m?1:0)}function QD(p,c,m,y,k,E){p.emplaceBack(c.x,c.y,(m.x<<1)+y,(m.y<<1)+k,E)}function GT(p,c,m){p.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}class yje{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class vje{constructor(){this.centroidXY=new rs(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 rs(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new rs(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new rs(this.max.x-this.min.x,this.max.y-this.min.y)}}class _je{constructor(){this.acc=new rs(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(c,m){c.min.x===Number.MAX_VALUE&&(c.min.x=c.max.x=m.x,c.min.y=c.max.y=m.y)}appendEdge(c,m,y){this.accCount++,this.acc._add(m);let k=!!this.borders;m.xc.max.x&&(c.max.x=m.x,k=!0),m.yc.max.y&&(c.max.y=m.y,k=!0),((m.x===0||m.x===Gs)&&m.x===y.x)!=((m.y===0||m.y===Gs)&&m.y===y.y)&&this.processBorderOverlap(m,y),k&&this.checkBorderIntersection(m,y)}checkBorderIntersection(c,m){m.x<0!=c.x<0&&this.addBorderIntersection(0,Ur(m.y,c.y,(0-m.x)/(c.x-m.x))),m.x>Gs!=c.x>Gs&&this.addBorderIntersection(1,Ur(m.y,c.y,(Gs-m.x)/(c.x-m.x))),m.y<0!=c.y<0&&this.addBorderIntersection(2,Ur(m.x,c.x,(0-m.y)/(c.y-m.y))),m.y>Gs!=c.y>Gs&&this.addBorderIntersection(3,Ur(m.x,c.x,(Gs-m.y)/(c.y-m.y)))}addBorderIntersection(c,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 y=this.borders[c];my[1]&&(y[1]=m)}processBorderOverlap(c,m){if(c.x===m.x){if(c.y===m.y)return;const y=c.x===0?0:1;this.addBorderIntersection(y,m.y),this.addBorderIntersection(y,c.y)}else{const y=c.y===0?2:3;this.addBorderIntersection(y,m.x),this.addBorderIntersection(y,c.x)}}centroid(){return this.accCount===0?new rs(0,0):new rs(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((c,m)=>c+ +(m[0]!==Number.MAX_VALUE),0):0}}function bje(p,c){const m=p.add(c)._unit(),y=Se(p.x*m.x+p.y*m.y,-1,1);var k,E,P;return k=Math.acos(y),Math.min(4,Math.max(-4,Math.tan(k)))/4*Ret*((E=p).x*(P=c).y-E.y*P.x<0?-1:1)}const Fet=[p=>p.x<0,p=>p.x>Gs,p=>p.y<0,p=>p.y>Gs];function zet(p,c,m,y){const k=[4];if(y===0)return k;m._mult(y);const E=p.sub(m),P=c.sub(m),O=[p,c,E,P];for(let B=0;B<4;B++)for(const W of O)if(Fet[B](W)){k.push(B);break}return k}class xde{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new vT,this.indexArray=new yl,this.programConfigurations=new Um(c.layers,{zoom:c.zoom,lut:c.lut},m=>Det.includes(m)),this._segments=new io,this.hiddenByLandmarkVertexArray=new rC,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new io}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(c,m,y,k=!1){const E=c.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 B;P!==this._segments.get().length-1&&(P++,this._segmentToGroundQuads[P]=[],this._segmentToRegionTriCounts[P]=[0,0,0,0,0]);{const W=c[0],J=c[1];B=bje(W.sub(c[E-1])._perp()._unit(),J.sub(W)._perp()._unit())}for(let W=0;Wk.region-E.region);for(let y=0;yB+W,0);let O=0;for(let B=0;B<=4;B++){const W=P[B];if(W!==0){let J=this.regionSegments[B];J||(J=this.regionSegments[B]=new io);const ee={vertexOffset:E.vertexOffset,primitiveOffset:E.primitiveOffset+O,vertexLength:E.vertexLength,primitiveLength:W};J.get().push(ee)}O+=W}for(let B=0;B0?this.hiddenByLandmarkVertexBuffer=c.createVertexBuffer(this.hiddenByLandmarkVertexArray,Aet.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 c=0;c<=4;c++){const m=this.regionSegments[c];m&&m.destroy()}}}}class JD{constructor(c){this.zoom=c.zoom,this.canonical=c.canonical,this.overscaling=c.overscaling,this.layers=c.layers,this.pixelRatio=c.pixelRatio,this.layerIds=this.layers.map(m=>m.fqid),this.index=c.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=c.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new yl,this.footprintVertices=new lx,this.footprintSegments=[],this.layoutVertexArray=new bv,this.centroidVertexArray=new BD,this.wallVertexArray=new vb,this.indexArray=new yl,this.programConfigurations=new Um(c.layers,{zoom:c.zoom,lut:c.lut},m=>Let.includes(m)),this.segments=new io,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new xde(c),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){this.features=[],this.hasPattern=lde("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=Be(y),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:B}of c){const W=this.layers[0]._featureFilter.needGeometry,J=Ht(E,W);if(!this.layers[0]._featureFilter.filter(new Ii(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),J,y))continue;const ee={id:P,sourceLayerIndex:B,index:O,geometry:W?J.geometry:Et(E,y,k),properties:E.properties,type:E.type,patterns:{}},ne=this.layoutVertexArray.length,ie=gde[ee.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:cde("fill-extrusion",this.layers,ee,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const ue of ee.geometry)for(const we of pje(ue,ie))this.addFeature(E.id,ee,[we],O,y,{},m.availableImages,k,m.brightness);else this.addFeature(E.id,ee,ee.geometry,O,y,{},m.availableImages,k,m.brightness);m.featureIndex.insert(E,ee.geometry,O,B,this.index,ne)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(c,m,y,k,E,P){for(const{featureId:O,feature:B}of this.features){const W=gde[B.type]==="Polygon",{geometry:J}=B;if(this.wallMode)for(const ee of J)for(const ne of pje(ee,W))this.addFeature(O,B,[ne],B.index,m,y,k,E,P);else this.addFeature(O,B,J,B.index,m,y,k,E,P)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(c,m,y,k,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,this.worldview),this.groundEffect.update(c,m,E,y,k,P,O,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Pet),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,Tet.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,Eet.members,!0)),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}uploadCentroid(c){this.groundEffect.uploadHiddenByLandmark(c),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=c.createVertexBuffer(this.centroidVertexArray,Met.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(c,m,y,k,E,P,O,B,W){const J=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,ee=[new rs(0,0),new rs(Gs,Gs)],ne=B.projection,ie=ne.name==="globe",ue=this.wallMode||gde[m.type]==="Polygon",we=new _je;we.centroidDataIndex=this.centroidData.length;const Ee=new vje;Ee.buildingId=c,m.properties&&m.properties.hasOwnProperty("building_id")&&(Ee.buildingId=m.properties.building_id);const Te=this.layers[0].paint.get("fill-extrusion-base").evaluate(m,{},E)<=0,Ue=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},E);let Ye;if(Ee.height=Ue,Ee.vertexArrayOffset=this.layoutVertexArray.length,Ee.groundVertexArrayOffset=this.groundEffect.vertexArray.length,ie&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new XS),this.wallMode){if(ie)return void cr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(y.length!==1)return;Ye=function(Wt){const hs=Wt[0].x===Wt[Wt.length-1].x&&Wt[0].y===Wt[Wt.length-1].y;(function(pr){let wr=0;const Wn=pr.length;for(let qs=0;qs=0})(Wt)||(Wt=Wt.reverse());const vs={geometry:[],joinNormals:[],indices:[]},Ds=[],Fs=[],Es=[];let Is=Wt.length;for(;Is>=2&&Wt[Is-1].equals(Wt[Is-2]);)Is--;if(Is<(hs?3:2))return vs;let us,as,Ls,Ks,$s,Pr=0;for(;Pr0;let hn="miter";const ua=2;hn==="miter"&&qs>ua&&(hn="bevel"),hn==="bevel"&&(qs>100&&(hn="flipbevel"),qs{const ms=new rs(Mn.x,Mn.y),Os=new rs(Mn.x,Mn.y);ms.x+=pi.x*wt,ms.y+=pi.y*wt,Os.x-=pi.x*Math.max(gt,1),Os.y-=pi.y*Math.max(gt,1),Es.push(pi),Ds.push(ms),Fs.push(Os)};if(hn==="miter")wr._mult(qs),fa(us,wr,0,0);else if(hn==="flipbevel")wr=$s.mult(-1),fa(us,wr,0,0),fa(us,wr.mult(-1),0,0);else{const Mn=-Math.sqrt(qs*qs-1),pi=jr?Mn:0,gt=jr?0:Mn;as&&fa(us,Ks,pi,gt),Ls&&fa(us,$s,pi,gt)}}vs.geometry=[...Ds,...Fs.reverse(),Ds[0]],vs.joinNormals=[...Es,...Es.reverse(),Es[Es.length-1]];const lr=vs.geometry.length-1;for(let pr=0;prWt<(hs.length-1)/2||Wt===hs.length-1,_t=this.wallMode?[y]:UT(y,500);for(let Wt=_t.length-1;Wt>=0;Wt--){const hs=_t[Wt];(hs.length===0||(ft=hs[0]).every(ys=>ys.x<=0)||ft.every(ys=>ys.x>=Gs)||ft.every(ys=>ys.y<=0)||ft.every(ys=>ys.y>=Gs))&&_t.splice(Wt,1)}var ft;let St;if(ie)St=Mje(_t,ee,E);else{St=[];for(const Wt of _t)St.push({polygon:Wt,bounds:ee})}const Pt=ue?this.edgeRadius:0,Ft=Pt>0&&this.zoom<17,ns=(Wt,hs)=>{if(Wt.length===0)return!1;const ys=Wt[Wt.length-1];return hs.x===ys.x&&hs.y===ys.y};for(const{polygon:Wt,bounds:hs}of St){let ys=0,vs=0;for(const Is of Wt)ue&&!Is[0].equals(Is[Is.length-1])&&Is.push(Is[0]),vs+=ue?Is.length-1:Is.length;const Ds=this.segments.prepareSegment((ue?5:4)*vs,this.layoutVertexArray,this.indexArray);Ee.footprintSegIdx<0&&(Ee.footprintSegIdx=this.footprintSegments.length),Ee.polygonSegIdx<0&&(Ee.polygonSegIdx=this.polygonSegments.length);const Fs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Es=new yje;if(Es.vertexOffset=this.footprintVertices.length,Es.indexOffset=3*this.footprintIndices.length,Es.ringIndices=[],ue){const Is=[],us=[];ys=Ds.vertexLength;for(let Ls=0;Ls4&&Nje(us[us.length-2],us[0],us[1]),Ls=Pt?Bet(us[us.length-2],us[0],us[1],Pt):0;const Ks=[];let $s,Pr,lr;Pr=us[1].sub(us[0])._perp()._unit();let pr=!0;for(let wr=1,Wn=0;wr0?1:0,pi=qs.dist(jr);if(Wn+pi>32768&&(Wn=0),Pt){lr=hn.sub(jr)._perp()._unit();let Os=jje(qs,jr,hn,wje(Pr,lr),Pt);isNaN(Os)&&(Os=0);const nr=jr.sub(qs)._unit();qs=qs.add(nr.mult(Ls))._round(),jr=jr.add(nr.mult(-Os))._round(),Ls=Os,Pr=lr,Te&&this.zoom>=17&&(ns(Ks,qs)||Ks.push(qs),ns(Ks,jr)||Ks.push(jr))}const gt=Ds.vertexLength,wt=us.length>4&&Nje(qs,jr,hn);let ms=Sje(Wn,as,pr);if(HT(this.layoutVertexArray,qs.x,qs.y,fa,Mn,0,0,ms),HT(this.layoutVertexArray,qs.x,qs.y,fa,Mn,0,1,ms),this.wallMode){const Os=st(wr-1,us),nr=Ye.joinNormals[wr-1];WT(this.wallVertexArray,nr,Os),WT(this.wallVertexArray,nr,Os)}if(Wn+=pi,ms=Sje(Wn,wt,!pr),as=wt,HT(this.layoutVertexArray,jr.x,jr.y,fa,Mn,0,0,ms),HT(this.layoutVertexArray,jr.x,jr.y,fa,Mn,0,1,ms),this.wallMode){const Os=st(wr,us),nr=Ye.joinNormals[wr];WT(this.wallVertexArray,nr,Os),WT(this.wallVertexArray,nr,Os)}if(Ds.vertexLength+=4,this.indexArray.emplaceBack(gt+0,gt+1,gt+2),this.indexArray.emplaceBack(gt+1,gt+3,gt+2),Ds.primitiveLength+=2,Pt){const Os=ys+(wr===1?us.length-2:wr-2),nr=wr===1?ys:Os+1;if(this.indexArray.emplaceBack(gt+1,Os,gt+3),this.indexArray.emplaceBack(Os,nr,gt+3),Ds.primitiveLength+=2,$s===void 0&&($s=gt),!yde(hn,us[wr],hs)){const ar=wr===us.length-1?$s:Ds.vertexLength;this.indexArray.emplaceBack(gt+2,gt+3,ar),this.indexArray.emplaceBack(gt+3,ar+1,ar),this.indexArray.emplaceBack(gt+3,nr,ar+1),Ds.primitiveLength+=3}pr=!pr}if(ie){const Os=this.layoutVertexExtArray,nr=ne.projectTilePoint(qs.x,qs.y,E),ar=ne.projectTilePoint(jr.x,jr.y,E),Ir=ne.upVector(E,qs.x,qs.y),zr=ne.upVector(E,jr.x,jr.y);GT(Os,nr,Ir),GT(Os,nr,Ir),GT(Os,ar,zr),GT(Os,ar,zr)}}ue&&(ys+=us.length-1),Te&&Pt&&this.zoom>=17&&(Ks.length!==0&&ns(Ks,Ks[0])&&Ks.pop(),this.groundEffect.addData(Ks,hs,J,Pt>0))}this.footprintSegments.push(Es),Fs.triangleCount=this.indexArray.length-Fs.triangleArrayOffset,this.polygonSegments.push(Fs),++Ee.footprintSegLen,++Ee.polygonSegLen}if(Ee.vertexCount=this.layoutVertexArray.length-Ee.vertexArrayOffset,Ee.groundVertexCount=this.groundEffect.vertexArray.length-Ee.groundVertexArrayOffset,Ee.vertexCount!==0){if(Ee.centroidXY=we.borders?fje:this.encodeCentroid(we,Ee),this.centroidData.push(Ee),we.borders){this.featuresOnBorder.push(we);const Wt=this.featuresOnBorder.length-1;for(let hs=0;hsthis.featuresOnBorder[m].borders[c][0]-this.featuresOnBorder[y].borders[c][0])}splitToSubtiles(){const c=[];for(let O=0;OGs),J=2*W+(+(B.min.x+B.max.x>Gs)^W);for(let ee=0;eeO.triangleSegmentIdx===B.triangleSegmentIdx?O.subtile-B.subtile:O.triangleSegmentIdx-B.triangleSegmentIdx);let y=0,k=0,E=0;for(const O of c){if(O.triangleSegmentIdx!==y)break;E++}const P=c.length;for(;k!==c.length;){y=c[k].triangleSegmentIdx;let O=0,B=k,W=k;for(let J=B;J0&&this.triangleSubSegments.push({segment:ie,min:ee,max:ne}),B=W;for(let ue=B;ue[we[0]*(1-Te[0])+Ee[0]*Te[0],we[1]*(1-Te[1])+Ee[1]*Te[1]],ie=[],ue=[];for(const we of this.triangleSubSegments){ie[0]=we.min.x/Gs,ie[1]=we.min.y/Gs,ue[0]=we.max.x/Gs,ue[1]=we.max.y/Gs;const Ee=ne(J,ee,ie),Te=ne(J,ee,ue);if(new Tr([Ee[0],Ee[1],E],[Te[0],Te[1],P]).intersectsPrecise(y)===0){W&&(k.segments.push(W),W=void 0);continue}const Ue=we.segment;W&&W.vertexOffset!==Ue.vertexOffset&&(k.segments.push(W),W=void 0),W?(W.vertexLength+=Ue.vertexLength,W.primitiveLength+=Ue.primitiveLength):W={vertexOffset:Ue.vertexOffset,primitiveLength:Ue.primitiveLength,vertexLength:Ue.vertexLength,primitiveOffset:Ue.primitiveOffset,sortKey:void 0,vaos:{}}}return W&&k.segments.push(W),k}encodeCentroid(c,m){const y=c.centroid(),k=m.span(),E=Math.min(7,Math.round(k.x*this.tileToMeter/10)),P=Math.min(7,Math.round(k.y*this.tileToMeter/10));return new rs(Se(y.x,1,Gs-1)<<3|E,Se(y.y,1,Gs-1)<<3|P)}encodeBorderCentroid(c){if(!c.borders)return new rs(0,0);const m=c.borders,y=Number.MAX_VALUE;if(m[0][0]!==y||m[1][0]!==y){const k=m[0][0]!==y?0:1;return new rs(6|(m[0][0]!==y?0:65528),(m[k][0]+m[k][1])/2<<3|6)}{const k=m[2][0]!==y?2:3;return new rs((m[k][0]+m[k][1])/2<<3|6,6|(m[2][0]!==y?0:65528))}}showCentroid(c){const m=this.centroidData[c.centroidDataIndex];m.flags&=2147483647,m.centroidXY.x=0,m.centroidXY.y=0,this.writeCentroidToBuffer(m)}writeCentroidToBuffer(c){this.groundEffect.updateHiddenByLandmark(c);const m=c.vertexArrayOffset,y=c.vertexCount+c.vertexArrayOffset,k=c.flags&Ly?fje:c.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==k.y||E!==k.x){for(let P=m;PB.max.x||B.min.x>P.max.x||P.min.y>B.max.y||B.min.y>P.max.y||P.footprint.buildingIds.has(B.buildingId)&&(B.flags|=Ly);else for(const B of this.centroidData)if(!(B.flags&Ly||P.min.x>B.max.x||B.min.x>P.max.x||P.min.y>B.max.y||B.min.y>P.max.y))for(let W=0;Wm!=ie>m&&c<(this.footprintVertices.int16[2*(J+P.vertexOffset)+0]-ee)*(m-ne)/(ie-ne)+ee&&(k=!k)}O=B}}return k}getHeightAtTileCoord(c,m){let y=Number.NEGATIVE_INFINITY,k=!0;const E=4*(c+Gs)*Gs+(m+Gs);if(this.partLookup.hasOwnProperty(E)){const P=this.partLookup[E];return P?{height:P.height,hidden:!!(P.flags&Ly)}:void 0}for(const P of this.centroidData)c>P.max.x||P.min.x>c||m>P.max.y||P.min.y>m||P.height<=y||this.footprintContainsPoint(c,m,P)&&(y=P.height,this.partLookup[E]=P,k=!!(P.flags&Ly));if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:k};this.partLookup[E]=void 0}}function wje(p,c){const m=p.add(c)._unit();return p.x*m.x+p.y*m.y}function Bet(p,c,m,y){const k=c.sub(p)._perp()._unit(),E=m.sub(c)._perp()._unit();return jje(p,c,m,wje(k,E),y)}function jje(p,c,m,y,k){const E=Math.sqrt(1-y*y);return Math.min(p.dist(c)/3,c.dist(m)/3,k*E/y)}function yde(p,c,m){return p.xm[1].x&&c.x>m[1].x||p.ym[1].y&&c.y>m[1].y}function kje(p,c){return p.xc[1].x||p.yc[1].y}function Nje(p,c,m){if(p.x<0||p.x>=Gs||c.x<0||c.x>=Gs||m.x<0||m.x>=Gs)return!1;const y=m.sub(c),k=y.perp(),E=p.sub(c);return(y.x*E.x+y.y*E.y)/Math.sqrt((y.x*y.x+y.y*y.y)*(E.x*E.x+E.y*E.y))>-.866&&k.x*E.x+k.y*E.y<0}function Sje(p,c,m){const y=c?2|p:-3&p;return m?1|y:-2&y}function Cje(){const p=Math.PI/32,c=Math.tan(p),m=C;return m*Math.sqrt(1+2*c*c)-m}function Mje(p,c,m){const y=1<{for(const Pt of ft)ue.push({polygon:Pt,bounds:St})},Ee=Math.ceil(Math.log2(J)),Te=Math.ceil(Math.log2(ee)),Ue=Ee-Te,Ye=[];for(let ft=0;ft0?0:1);for(let ft=0;ftSt+1?_t.push({polygons:vs,bounds:Fs,depth:St+1}):we(vs,Fs)}if(Ds.length){const Fs=[new rs(Pt===0?ys:Ft.x,Pt===1?ys:Ft.y),ns];Ye.length>St+1?_t.push({polygons:Ds,bounds:Fs,depth:St+1}):we(Ds,Fs)}}return ue}(p,c,Math.ceil((E-k)/11.25),Math.ceil((P-O)/11.25),1,(B,W,J)=>{if(B===0)return .5*(W+J);{const ee=me((m.y+W/Gs)/y);return(X(.5*(me((m.y+J/Gs)/y)+ee))*y-m.y)*Gs}})}function $et(p,c,m,y,k,E){const P=Math.pow(2,y.z-k.z);for(let O=0;O=B[P]&&(O=c,B=p),O[P]k&&Pje(O,B,P,k),O[P]E&&Pje(B,O,P,E)}}function eO(p,c,m,y,k,E){const P=[];for(let O=0;O=y&&ue.x>=y||(ie.x>=y?ie=new rs(y,ie.y+(y-ie.x)/(ue.x-ie.x)*(ue.y-ie.y))._round():ue.x>=y&&(ue=new rs(y,ie.y+(y-ie.x)/(ue.x-ie.x)*(ue.y-ie.y))._round()),ie.y>=k&&ue.y>=k||(ie.y>=k?ie=new rs(ie.x+(k-ie.y)/(ue.y-ie.y)*(ue.x-ie.x),k)._round():ue.y>=k&&(ue=new rs(ie.x+(k-ie.y)/(ue.y-ie.y)*(ue.x-ie.x),k)._round()),W&&ie.equals(W[W.length-1])||(W=[ie],P.push(W),E&&E.push({progress:{min:Ee+Lje(Te,Ue,ie)*we,max:1},parentIndex:O,prevPoint:Te,nextPoint:Ue})),W.push(ue),E&&(E[E.length-1].progress.max=Ee+Lje(Te,Ue,ue)*we,E[E.length-1].nextPoint=Ue)))))}if(E&&ee>0)for(let ne=J;neW.t-J.t);let P=0,O=0,B=[];for(y.push(B);P!==p.length;){if(O===E.length){for(;P!==p.length;)B.length!==0&&B[B.length-1].equals(p[P])||B.push(p[P]),P++;break}E[O].t<=P?(B.length!==0&&B[B.length-1].equals(E[O].point)||B.push(E[O].point),Math.trunc(E[O].t),O++):(B.length!==0&&B[B.length-1].equals(p[P])||B.push(p[P]),P++)}}function Lje(p,c,m){return p.x!==c.x?(m.x-p.x)/(c.x-p.x):p.y!==c.y?(m.y-p.y)/(c.y-p.y):0}function KT(p,c){return p.x*c.x+p.y*c.y}function Dje(p,c){if(p.length===1){let m=0;const y=c[m++];let k;for(;!k||y.equals(k);)if(k=c[m++],!k)return 1/0;for(;m{ys[0]=vs,ys[1]=Ds,ys[2]=Fs,ys[3]=1},hs=Cje();ie>0&&(ie+=hs),ue+=hs;for(const ys of ne){const vs=[],Ds=[];for(const Fs of ys){const Es=Fs.x+we.x,Is=Fs.y+we.y,us=ee.projection.projectTilePoint(Es,Is,_t),as=ee.projection.upVector(_t,Fs.x,Fs.y);let Ls=ie,Ks=ue;if(Te){const $s=Fje(Es,Is,ie,ue,Te,Ue,Ye,st);Ls+=$s.base,Ks+=$s.top}ie!==0?Wt(Ft,us.x+as[0]*Pt*Ls,us.y+as[1]*Pt*Ls,us.z+as[2]*Pt*Ls):Wt(Ft,us.x,us.y,us.z),Wt(ns,us.x+as[0]*Pt*Ks,us.y+as[1]*Pt*Ks,us.z+as[2]*Pt*Ks),Rt(Ft,Ft,Ee),Rt(ns,ns,Ee),vs.push(new Tb(Ft[0],Ft[1],Ft[2])),Ds.push(new Tb(ns[0],ns[1],ns[2]))}ft.push(vs),St.push(Ds)}return[ft,St]}(p,c,m,y,k,E,P,O,B,W,J):P?function(ee,ne,ie,ue,we,Ee,Te,Ue,Ye){const st=[],_t=[],ft=[0,0,0,1];for(const St of ee){const Pt=[],Ft=[];for(const ns of St){const Wt=ns.x+ue.x,hs=ns.y+ue.y,ys=Fje(Wt,hs,ne,ie,Ee,Te,Ue,Ye);ft[0]=Wt,ft[1]=hs,ft[2]=ys.base,ft[3]=1,ht(ft,ft,we),ft[3]=Math.max(ft[3],1e-5);const vs=new Tb(ft[0]/ft[3],ft[1]/ft[3],ft[2]/ft[3]);ft[0]=Wt,ft[1]=hs,ft[2]=ys.top,ft[3]=1,ht(ft,ft,we),ft[3]=Math.max(ft[3],1e-5);const Ds=new Tb(ft[0]/ft[3],ft[1]/ft[3],ft[2]/ft[3]);Pt.push(vs),Ft.push(Ds)}st.push(Pt),_t.push(Ft)}return[st,_t]}(c,m,y,k,E,P,O,B,W):function(ee,ne,ie,ue,we){const Ee=[],Te=[],Ue=we[8]*ne,Ye=we[9]*ne,st=we[10]*ne,_t=we[11]*ne,ft=we[8]*ie,St=we[9]*ie,Pt=we[10]*ie,Ft=we[11]*ie;for(const ns of ee){const Wt=[],hs=[];for(const ys of ns){const vs=ys.x+ue.x,Ds=ys.y+ue.y,Fs=we[0]*vs+we[4]*Ds+we[12],Es=we[1]*vs+we[5]*Ds+we[13],Is=we[2]*vs+we[6]*Ds+we[14],us=we[3]*vs+we[7]*Ds+we[15],as=Fs+Ue,Ls=Es+Ye,Ks=Is+st,$s=Math.max(us+_t,1e-5),Pr=Fs+ft,lr=Es+St,pr=Is+Pt,wr=Math.max(us+Ft,1e-5);Wt.push(new Tb(as/$s,Ls/$s,Ks/$s)),hs.push(new Tb(Pr/wr,lr/wr,pr/wr))}Ee.push(Wt),Te.push(hs)}return[Ee,Te]}(c,m,y,k,E)}function Fje(p,c,m,y,k,E,P,O){const B=P*k.getElevationAt(p,c,!0,!0),W=E[0]!==0,J=W?E[1]===0?P*(E[0]/gje-xje):P*function(ee,ne,ie){const ue=Math.floor(ne[0]/8),we=Math.floor(ne[1]/8),Ee=10*(ne[0]-8*ue),Te=10*(ne[1]-8*we),Ue=ee.getElevationAt(ue,we,!0,!0),Ye=ee.getMeterToDEM(ie),st=Math.floor(.5*(Ee*Ye-1)),_t=Math.floor(.5*(Te*Ye-1)),ft=ee.tileCoordToPixel(ue,we),St=2*st+1,Pt=2*_t+1,Ft=function(Ds,Fs,Es,Is,us){return[Ds.getElevationAtPixel(Fs,Es,!0),Ds.getElevationAtPixel(Fs+us,Es,!0),Ds.getElevationAtPixel(Fs,Es+us,!0),Ds.getElevationAtPixel(Fs+Is,Es+us,!0)]}(ee,ft.x-st,ft.y-_t,St,Pt),ns=Math.abs(Ft[0]-Ft[1]),Wt=Math.abs(Ft[2]-Ft[3]),hs=Math.abs(Ft[0]-Ft[2])+Math.abs(Ft[1]-Ft[3]),ys=Math.min(.25,.5*Ye*(ns+Wt)/St),vs=Math.min(.25,.5*Ye*hs/Pt);return Ue+Math.max(ys*Ee,vs*Te)}(k,E,O):B;return{base:B+(m===0?-1:m),top:W?Math.max(J+y,B+m+2):B+y}}class Uet{constructor(c){this._callback=c,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 Vet{constructor(){this.tasks={},this.taskQueue=[],qt(["process"],this),this.invoker=new Uet(this.process),this.nextId=0}add(c,m){const y=this.nextId++,k=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(k===0){try{c()}finally{}return null}return this.tasks[y]={fn:c,metadata:m,priority:k,id:y},this.taskQueue.push(y),this.invoker.trigger(),{cancel:()=>{delete this.tasks[y]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(y=>!!this.tasks[y]),!this.taskQueue.length)return;const c=this.pick();if(c===null)return;const m=this.tasks[c];if(delete this.tasks[c],this.taskQueue.length&&this.invoker.trigger(),!m)return;m.fn()}finally{}}pick(){let c=null,m=1/0;for(let k=0;k{y&&delete this.callbacks[O],this.target.postMessage({id:O,type:"",targetMapId:k,sourceMapId:this.mapId})}}}receive(c){const m=c.data;if(!m)return;const y=m.id;if(y&&(!m.targetMapId||this.mapId===m.targetMapId))if(m.type===""){const k=this.cancelCallbacks[y];delete this.cancelCallbacks[y],k&&k.cancel()}else if(m.mustQueue||ca(self)){const k=this.callbacks[y],E=this.scheduler.add(()=>this.processTask(y,m),k&&k.metadata||{type:"message"});E&&(this.cancelCallbacks[y]=E)}else this.processTask(y,m)}processTask(c,m){if(delete this.cancelCallbacks[c],m.type===""){const y=this.callbacks[c];delete this.callbacks[c],y&&(m.error?y(ox(m.error)):y(null,ox(m.data)))}else{const y=new Set,k=m.hasCallback?(P,O)=>{this.target.postMessage({id:c,type:"",sourceMapId:this.mapId,error:P?Lf(P):null,data:Lf(O,y)},y)}:()=>{},E=ox(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,E,k);else if(this.parent.getWorkerSource){const P=m.type.split("."),{source:O,scope:B}=E;this.parent.getWorkerSource(m.sourceMapId,P[0],O,B)[P[1]](E,k)}else k(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var ZT={workerUrl:"",workerClass:null,workerParams:void 0};const vde="mapboxgl_preloaded_worker_pool";class Ab{constructor(c){this.active={},this.name=c}acquire(c,m=Ab.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[vde]}numActive(){return Object.keys(this.active).length}}Ab.workerCount=2;class xC{constructor(c,m,y="Worker",k=Ab.workerCount){this.workerPool=c,this.actors=[],this.currentActor=0,this.id=Ot();const E=this.workerPool.acquire(this.id,k);for(let P=0;P{this.ready=!0})}broadcast(c,m,y){Mt(this.actors,(k,E)=>{k.send(c,m,E)},y=y||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(c=>{c.remove()}),this.actors=[],this.workerPool.release(this.id)}}let YT,_de;function tO(){return YT||(YT=new Ab),YT}xC.Actor=zje;const bde=4096;class Het{constructor(c){this.module=c,this.memoryStack=this.module.malloc(bde),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>bde?-1:(new Int32Array(this.module.heap32.buffer,m,c.length).set(c),m)}createFloatArray(c){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>bde?-1:(new Float32Array(this.module.heapF32.buffer,m,c.length).set(c),m)}readStringBuffer(c){let m="";for(;this.module.heapU8[c]!==0;)m+=String.fromCharCode(this.module.heapU8[c]),++c;return m}setStyle(c){const m=c.normalScale;this.module.setStyle(m[0],m[1],m[2],c.tileToMeters)}setAOOptions(c,m){this.module.setAOOptions(c?1:0,m)}setMetricOptions(c,m){this.module.setMetricOptions(c?1:0,m)}setStructuralOptions(c){this.module.setStructuralOptions(c?1:0)}setFacadeOptions(c,m){this.module.setFacadeOptions(c,m?1:0)}setFauxFacadeOptions(c,m,y){this.module.setFauxFacadeOptions(c?1:0,m?1:0,y)}setFacadeClassifierOptions(c){this.module.setFacadeClassifierOptions(c)}generateMesh(c,m){this.memoryStackNextFree=this.memoryStack;for(const O of c){const B=this.createIntArray(O.ringIndices),W=this.createFloatArray(O.coordinates);if(B===-1||W===-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,W,B,O.ringIndices.length-1)}for(const O of m){let B;B=O.entrances?JSON.parse(O.entrances):[];const W=this.createFloatArray(B),J=this.createFloatArray(O.coordinates);if(W===-1||J===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(O.sourceId,O.crossPerc,O.distanceToRoad,W,B.length,J,O.coordinates.length)}if(!this.module.generateMesh()){const O=this.module.getLastError();return this.readStringBuffer(O)}const y=this.module.getMeshCount(),k=new Array(y);for(let O=0;Ok.arrayBuffer()).then(k=>{c.buffers[m]=k})}function Gje(p,c){const m=p.json.bufferViews[c];return new Uint8Array(p.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function Xet(p,c,m,y){if(p.uri){const k=Wje(p.uri,y);return fetch(k).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{c.images[m]=E})}if(p.bufferView!==void 0){const k=Gje(c,p.bufferView),E=new Blob([k],{type:p.mimeType});return createImageBitmap(E).then(P=>{c.images[m]=P})}}function Kje(p,c=0,m){const y={json:null,images:[],buffers:[]};if(new Uint32Array(p,c,1)[0]===Vje){const J=new Uint32Array(p,c);let ee=2;const ne=(J[ee++]>>2)-3,ie=J[ee++]>>2;if(ee++,y.json=JSON.parse(Hje.decode(J.subarray(ee,ee+ie))),ee+=ie,ee{const J=[],ee=O&&O.includes(kde),ne=O&&O.includes(nO);if(ee&&J.push(function(){if(!Wf)return XT??(XT=function(ie){let ue,we=null;function Ee(){ue=new Uint8Array(we.buffer)}function Te(){throw new Error("Unexpected Draco error.")}const Ue={a:{a:Te,d:function(Ye,st,_t){return ue.copyWithin(Ye,st,st+_t)},c:function(Ye){const st=ue.length,_t=Math.max(Ye>>>0,Math.ceil(1.2*st)),ft=Math.ceil((_t-st)/65536);try{return we.grow(ft),Ee(),!0}catch{return!1}},b:Te}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(ie,Ue):ie.then(Ye=>Ye.arrayBuffer()).then(Ye=>WebAssembly.instantiate(Ye,Ue))).then(Ye=>{const{Rb:st,Qb:_t,P:ft,T:St,X:Pt,Ja:Ft,La:ns,Qa:Wt,Va:hs,Wa:ys,eb:vs,jb:Ds,f:Fs,e:Es,yb:Is,zb:us,Ab:as,Bb:Ls,Db:Ks,Gb:$s}=Ye.instance.exports;we=Es;const Pr=(()=>{let lr=0,pr=0,wr=0,Wn=0;return qs=>{wr&&(st(Wn),st(lr),pr+=wr,wr=lr=0),lr||(pr+=128,lr=_t(pr));const jr=qs.length+7&-8;let hn=lr;jr>=pr&&(wr=jr,hn=Wn=_t(jr));for(let ua=0;ua{Wf=ie,XT=void 0}))}()),ne&&J.push(function(){if(jde)return;const ie=function(ue){let we;const Ee=WebAssembly.instantiateStreaming(ue,{}).then(Ye=>{we=Ye.instance,we.exports.__wasm_call_ctors()}),Te={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ue={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Ee,supported:!0,decodeGltfBuffer(Ye,st,_t,ft,St,Pt){(function(Ft,ns,Wt,hs,ys,vs,Ds){const Fs=Ft.exports.sbrk,Es=hs+3&-4,Is=Fs(Es*ys),us=Fs(vs.length),as=new Uint8Array(Ft.exports.memory.buffer);as.set(vs,us);const Ls=ns(Is,hs,ys,us,vs.length);if(Ls===0&&Ds&&Ds(Is,Es,ys),Wt.set(as.subarray(Is,Is+hs*ys)),Fs(Is-Fs(0)),Ls!==0)throw new Error(`Malformed buffer data: ${Ls}`)})(we,we.exports[Ue[St]],Ye,st,_t,ft,we.exports[Te[Pt]])}}}(fetch(qje()));return ie.ready.then(()=>{jde=ie})}()),E)for(let ie=0;ie{if(ee&&P)for(const{primitives:ie}of P)for(const ue of ie)Ket(ue,y);if(ne&&P&&B)for(const ie of B)Zet(ie,y);return y})})}function Zje(p){return fetch(p).then(c=>c.arrayBuffer()).then(c=>Kje(c,0,p))}function Nde(p){switch(p){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 Sde(p){switch(p){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 Cde{constructor(c,m,y,k){this.context=c,this.format=y,this.useMipmap=k&&k.useMipmap,this.texture=c.gl.createTexture(),this.update(m,{premultiply:k&&k.premultiply})}update(c,m){const y=c&&c instanceof HTMLVideoElement&&c.width===0?c.videoWidth:c.width,k=c&&c instanceof HTMLVideoElement&&c.height===0?c.videoHeight:c.height,{context:E}=this,{gl:P}=E,{x:O,y:B}=m&&m.position?m.position:{x:0,y:0},W=O+y,J=B+k;!this.size||this.size[0]===W&&this.size[1]===J||(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 ee=c instanceof HTMLImageElement||c instanceof HTMLCanvasElement||c instanceof HTMLVideoElement||c instanceof ImageData||ImageBitmap&&c instanceof ImageBitmap;if(!this.size&&W>0&&J>0){const ne=this.useMipmap?Math.floor(Math.log2(Math.max(W,J)))+1:1;P.texStorage2D(P.TEXTURE_2D,ne,this.format,W,J),this.size=[W,J]}this.size&&(ee?P.texSubImage2D(P.TEXTURE_2D,0,O,B,Nde(this.format),Sde(this.format),c):"data"in c&&c.data&&P.texSubImage2D(P.TEXTURE_2D,0,O,B,y,k,Nde(this.format),Sde(this.format),c.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(c,m,y=!1){const{context:k}=this,{gl:E}=k;E.bindTexture(E.TEXTURE_2D,this.texture),c!==this.minFilter&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MAG_FILTER,c),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MIN_FILTER,this.useMipmap&&!y?c===E.NEAREST?E.NEAREST_MIPMAP_NEAREST:E.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),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(c,m,y,k,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),c!==this.minFilter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,this.useMipmap?c===O.NEAREST?O.NEAREST_MIPMAP_NEAREST:O.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),y!==this.wrapS&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,y),this.wrapS=y),k!==this.wrapT&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,k),this.wrapT=k),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:c}=this.context;c.deleteTexture(this.texture),this.texture=null}}class JT{constructor(c,m){this.context=c,this.texture=m}bind(c,m){const{context:y}=this,{gl:k}=y;k.bindTexture(k.TEXTURE_2D,this.texture),c!==this.minFilter&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,c),k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,c),this.minFilter=c),m!==this.wrapS&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,m),k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,m),this.wrapS=m)}}const Qet=ra([{name:"a_pos_3f",components:3,type:"Float32"}]),Jet=ra([{name:"a_color_3f",components:3,type:"Float32"}]),ett=ra([{name:"a_color_4f",components:4,type:"Float32"}]),ttt=ra([{name:"a_uv_2f",components:2,type:"Float32"}]),stt=ra([{name:"a_normal_3f",components:3,type:"Float32"}]),rtt=ra([{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"}]),ntt=ra([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Yje(p,c){const m=aO(p.projection,p.zoom,p.width,p.height),y=function(E,P,O,B,W){const J=new x(O.lng-180*Ev,O.lat),ee=new x(O.lng+180*Ev,O.lat),ne=E.project(J.lng,J.lat),ie=E.project(ee.lng,ee.lat),ue=-Math.atan2(ie.y-ne.y,ie.x-ne.x),we=Xe.fromLngLat(O);we.y=Se(we.y,-1+Ev,1-Ev);const Ee=we.toLngLat(),Te=E.project(Ee.lng,Ee.lat),Ue=Xe.fromLngLat(Ee);Ue.x+=Ev;const Ye=Ue.toLngLat(),st=E.project(Ye.lng,Ye.lat),_t=Qje(st.x-Te.x,st.y-Te.y,ue),ft=Xe.fromLngLat(Ee);ft.y+=Ev;const St=ft.toLngLat(),Pt=E.project(St.lng,St.lat),Ft=Qje(Pt.x-Te.x,Pt.y-Te.y,ue),ns=Math.abs(_t.x)/Math.abs(Ft.y),Wt=j([]);$(Wt,Wt,-ue*(1-(W?0:B)));const hs=j([]);return I(hs,hs,[1,1-(1-ns)*B,1]),hs[4]=-Ft.x/Ft.y*B,$(hs,hs,ue),S(hs,Wt,hs),hs}(p.projection,0,p.center,m,c),k=Xje(p);return I(y,y,[k,k,1]),y}function Xje(p){const c=p.projection,m=aO(p.projection,p.zoom,p.width,p.height),y=Mde(c,p.center),k=Mde(c,x.convert(c.center));return Math.pow(2,y*m+(1-m)*k)}function aO(p,c,m,y,k=1/0){const E=p.range;if(!E)return 0;const P=Math.min(k,Math.max(m,y)),O=Math.log2(P/1024);return ze(E[0]+O,E[1]+O,c)}const Ev=1/4e4;function Mde(p,c){const m=Se(c.lat,-pe,pe),y=new x(c.lng-180*Ev,m),k=new x(c.lng+180*Ev,m),E=p.project(y.lng,m),P=p.project(k.lng,m),O=Xe.fromLngLat(y),B=Xe.fromLngLat(k),W=P.x-E.x,J=P.y-E.y,ee=B.x-O.x,ne=B.y-O.y,ie=Math.sqrt((ee*ee+ne*ne)/(W*W+J*J));return Math.log2(ie)}function Qje(p,c,m){const y=Math.cos(m),k=Math.sin(m);return{x:p*y-c*k,y:p*k+c*y}}function Jje(p,c,m){j(p),$(p,p,Jr(c[2])),L(p,p,Jr(c[0])),F(p,p,Jr(c[1])),I(p,p,m),S(p,p,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function iO(p,c,m,y,k,E,P,O){const B=[m[0]-c[0],m[1]-c[1],0],W=[y[0]-c[0],y[1]-c[1],0];if(ce(B)<1e-12||ce(W)<1e-12)return qe(p);const J=dt([],B,W);Ie(J,J),xe(W,y,c),B[2]=(E-k)*O,W[2]=(P-k)*O;const ee=B;return dt(ee,B,W),Ie(ee,ee),fs(p,J,ee)}function oO(p,c,m=!1){const y=Tv(c.zoom),k=function(E,P,O){const B=P.worldSize,W=[E[12],E[13],E[14]],J=me(W[1]/B),ee=ae(W[0]/B),ne=j([]),ie=re(1,J)*B,ue=re(1,0)*B*Ce(J,P.zoom),we=1/rde(B);let Ee=ue*we;if(O){const st=aO(P.projection,P.zoom,P.width,P.height,1024);Ee=we*P.projection.pixelSpaceConversion(P.center.lat,B,st)}const Te=Sv(J,ee);de(Te,Te,ke([],Ie([],Te),ie*Ee*W[2]));const Ue=function(st){const _t=[st[0],st[1],st[2]];let ft=[0,1,0];const St=dt([],ft,_t);return dt(ft,_t,St),Pe(ft)===0&&(ft=[0,1,0],dt(St,_t,ft)),Ie(St,St),Ie(ft,ft),Ie(_t,_t),[St[0],St[1],St[2],0,ft[0],ft[1],ft[2],0,_t[0],_t[1],_t[2],0,st[0],st[1],st[2],1]}(Te);I(ne,ne,[Ee,Ee,Ee*ie]),A(ne,ne,[-W[0],-W[1],-W[2]]);const Ye=S([],P.globeMatrix,Ue);return S(Ye,Ye,ne),S(Ye,Ye,E),Ye}(p,c,m);if(y>0){const E=function(P,O){const B=O.worldSize,W=re(1,0)*B*Ce(O.center.lat,O.zoom)/rde(B),J=re(1,O.center.lat)*B,ee=j([]);F(ee,ee,Jr(O.center.lng)),L(ee,ee,Jr(O.center.lat)),A(ee,ee,[0,0,dd]),I(ee,ee,[W,W,W*J]);const ne=O.point;return A(ee,ee,[-ne.x,-ne.y,0]),S(ee,ee,P),S(ee,O.globeMatrix,ee)}(p,c);return function(P,O,B){const W=(ue,we,Ee)=>{const Te=ce(ue),Ue=ce(we),Ye=Hf(ue,we,Ee);return ke(Ye,Ye,1/ce(Ye)*Ur(Te,Ue,Ee))},J=W([P[0],P[1],P[2]],[O[0],O[1],O[2]],B),ee=W([P[4],P[5],P[6]],[O[4],O[5],O[6]],B),ne=W([P[8],P[9],P[10]],[O[8],O[9],O[10]],B),ie=Hf([P[12],P[13],P[14]],[O[12],O[13],O[14]],B);return[J[0],J[1],J[2],0,ee[0],ee[1],ee[2],0,ne[0],ne[1],ne[2],0,ie[0],ie[1],ie[2],1]}(k,E,y)}return k}function Tde(p,c,m,y){const k=Tr.projectAabbCorners(y,m);let E=Number.MAX_VALUE;for(let O=0;O0||Ee===0&&ue[0]*we[0]+ue[1]*we[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>we[0]*we[0]+we[1]*we[1])&&(J=ie)}ee=J}while(ee!==W);return B.length>0&&B.push(B[0]),B}(k);if(Ea(p,P))return E}const Eb=64,bC={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function lO(p,c,m,y,k,E,P,O,B,W=!1){const J=m.zoom,ee=m.project(y),ne=Ce(y.lat,J),ie=1/ne;j(p),A(p,p,[ee.x+P[0]*ie,ee.y+P[1]*ie,P[2]]);let ue=1,we=1;const Ee=m.worldSize;if(W){if(m.projection.name==="mercator"){let st=0;m.elevation&&(st=m.elevation.getAtPointOrZero(new Xe(ee.x/Ee,ee.y/Ee),0));const _t=ht([],[ee.x,ee.y,st,1],m.projMatrix)[3]/m.cameraToCenterDistance;ue=_t,we=_t*Ce(m.center.lat,J)}else if(m.projection.name==="globe"){const st=oO(p,m),_t=[0,0,0,1];ht(_t,_t,S([],m.projMatrix,st));const ft=_t[3]/m.cameraToCenterDistance,St=Tv(J),Pt=m.projection.pixelsPerMeter(y.lat,Ee)*Ce(y.lat,J),Ft=m.projection.pixelsPerMeter(m.center.lat,Ee)*Ce(m.center.lat,J);ue=ft/Ur(Pt,Me(m.center.lat),St),we=ft*ne/Pt,ue*=Ft,we*=Ft}}else ue=ie;I(p,p,[ue,ue,we]);const Te=[...p],Ue=c.orientation,Ye=[];if(Jje(Ye,[Ue[0]+(k?k[0]:0),Ue[1]+(k?k[1]:0),Ue[2]+(k?k[2]:0)],E),S(p,Te,Ye),O&&m.elevation){let st=0;const _t=[];if(B&&m.elevation){st=function(St,Pt,Ft,ns,Wt){const hs=Pt.elevation;if(!hs)return 0;const ys=Tr.projectAabbCorners(Ft,ns),vs=re(1,Wt.lat)*Pt.worldSize,Ds=function(pr,wr){const Wn=[0,0,1],qs=[{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 jr of qs){const hn=pr[jr.corners[0]],ua=pr[jr.corners[1]],fa=pr[jr.corners[2]],Mn=[ua[0]-hn[0],ua[1]-hn[1],wr*(ua[2]-hn[2])],pi=dt(Mn,Mn,[fa[0]-hn[0],fa[1]-hn[1],wr*(fa[2]-hn[2])]);Ie(pi,pi),jr.dotProductWithUp=Ve(pi,Wn)}return qs.sort((jr,hn)=>jr.dotProductWithUp-hn.dotProductWithUp),qs[0].corners}(ys,vs),Fs=ys[Ds[0]],Es=ys[Ds[1]],Is=ys[Ds[2]],us=ys[Ds[3]],as=hs.getAtPointOrZero(new Xe(Fs[0]/Pt.worldSize,Fs[1]/Pt.worldSize),0),Ls=hs.getAtPointOrZero(new Xe(Es[0]/Pt.worldSize,Es[1]/Pt.worldSize),0),Ks=hs.getAtPointOrZero(new Xe(Is[0]/Pt.worldSize,Is[1]/Pt.worldSize),0),$s=hs.getAtPointOrZero(new Xe(us[0]/Pt.worldSize,us[1]/Pt.worldSize),0),Pr=(as+$s)/2,lr=(Ls+Ks)/2;return Pr>lr?Ls=c.gl.NEAREST_MIPMAP_NEAREST}),p.uploaded=!0,p.image=null)}function att(p,c,m){p.indexBuffer=c.createIndexBuffer(p.indexArray,!1,!0),p.vertexBuffer=c.createVertexBuffer(p.vertexArray,Qet.members,!1,!0),p.normalArray&&(p.normalBuffer=c.createVertexBuffer(p.normalArray,stt.members,!1,!0)),p.texcoordArray&&(p.texcoordBuffer=c.createVertexBuffer(p.texcoordArray,ttt.members,!1,!0)),p.colorArray&&(p.colorBuffer=c.createVertexBuffer(p.colorArray,(p.colorArray.bytesPerElement===12?Jet:ett).members,!1,!0)),p.featureArray&&(p.pbrBuffer=c.createVertexBuffer(p.featureArray,ntt.members,!0)),p.segments=io.simpleSegment(0,0,p.vertexArray.length,p.indexArray.length);const y=p.material;y.pbrMetallicRoughness.baseColorTexture&&eA(y.pbrMetallicRoughness.baseColorTexture,c),y.pbrMetallicRoughness.metallicRoughnessTexture&&eA(y.pbrMetallicRoughness.metallicRoughnessTexture,c),y.normalTexture&&eA(y.normalTexture,c),y.occlusionTexture&&eA(y.occlusionTexture,c,m),y.emissionTexture&&eA(y.emissionTexture,c)}function Ade(p,c,m){if(p.meshes)for(const y of p.meshes)att(y,c,m);if(p.children)for(const y of p.children)Ade(y,c,m)}function cO(p){if(p.meshes)for(const c of p.meshes)c.indexArray.destroy(),c.vertexArray.destroy(),c.colorArray&&c.colorArray.destroy(),c.normalArray&&c.normalArray.destroy(),c.texcoordArray&&c.texcoordArray.destroy(),c.featureArray&&c.featureArray.destroy();if(p.children)for(const c of p.children)cO(c)}function Ede(p){if(p.meshes)for(const m of p.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&&((c=m.material).pbrMetallicRoughness.baseColorTexture&&c.pbrMetallicRoughness.baseColorTexture.gfxTexture&&c.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),c.pbrMetallicRoughness.metallicRoughnessTexture&&c.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&c.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),c.normalTexture&&c.normalTexture.gfxTexture&&c.normalTexture.gfxTexture.destroy(),c.emissionTexture&&c.emissionTexture.gfxTexture&&c.emissionTexture.gfxTexture.destroy(),c.occlusionTexture&&c.occlusionTexture.gfxTexture&&c.occlusionTexture.gfxTexture.destroy()));var c;if(p.children)for(const m of p.children)Ede(m)}function Pb(p,c){const m=p.json.bufferViews[c.bufferView],y=rO[c.componentType];return new y(p.buffers[m.buffer],(c.byteOffset||0)+(m.byteOffset||0),c.count*(m.byteStride&&m.byteStride!==QT[c.type]*y.BYTES_PER_ELEMENT?m.byteStride/y.BYTES_PER_ELEMENT:QT[c.type]))}function Pde(p,c,m,y){const k=rO[c.componentType],E=function(J){switch(J){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(k),P=p.json.bufferViews[c.bufferView],O=P.byteStride?P.byteStride/k.BYTES_PER_ELEMENT:QT[c.type],B=m.float32,W=B.length/m.capacity;for(let J=0,ee=0;J0){for(let Ee=0;Ee0){E.texcoordArray=new Lp;const ne=c.json.accessors[k.TEXCOORD_0];E.texcoordArray.resize(ne.count);const ie=Pb(c,ne);Pde(c,ne,E.texcoordArray,ie)}if(k._FEATURE_ID_RGBA4444!==void 0){const ne=c.json.accessors[k._FEATURE_ID_RGBA4444];c.json.extensionsUsed&&c.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=Pb(c,ne))}k._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(Pb(c,c.json.accessors[k._FEATURE_RGBA4444]).buffer));const ee=p.material;return E.material=function(ne,ie){const{emissiveFactor:ue=[0,0,0],alphaMode:we="OPAQUE",alphaCutoff:Ee=.5,normalTexture:Te,occlusionTexture:Ue,emissiveTexture:Ye,doubleSided:st,name:_t}=ne,{baseColorFactor:ft=[1,1,1,1],metallicFactor:St=1,roughnessFactor:Pt=1,baseColorTexture:Ft,metallicRoughnessTexture:ns}=ne.pbrMetallicRoughness||{},Wt=Ue?ie[Ue.index]:void 0;if(Ue&&Ue.extensions&&Ue.extensions.KHR_texture_transform&&Wt){const hs=Ue.extensions.KHR_texture_transform;Wt.offsetScale=[hs.offset[0],hs.offset[1],hs.scale[0],hs.scale[1]]}return{name:_t,pbrMetallicRoughness:{baseColorFactor:new Fr(...ft),metallicFactor:St,roughnessFactor:Pt,baseColorTexture:Ft?ie[Ft.index]:void 0,metallicRoughnessTexture:ns?ie[ns.index]:void 0},doubleSided:st,emissiveFactor:new Fr(...ue),alphaMode:we,alphaCutoff:Ee,normalTexture:Te?ie[Te.index]:void 0,occlusionTexture:Wt,emissionTexture:Ye?ie[Ye.index]:void 0,defined:ne.defined===void 0}}(ee!==void 0?c.json.materials[ee]:{defined:!1},m),E}function tke(p,c,m){const{matrix:y,rotation:k,translation:E,scale:P,mesh:O,extras:B,children:W,name:J}=p,ee={};if(ee.name=J,ee.localMatrix=y||function(ne,ie,ue,we){var Ee=ie[0],Te=ie[1],Ue=ie[2],Ye=ie[3],st=Ee+Ee,_t=Te+Te,ft=Ue+Ue,St=Ee*st,Pt=Ee*_t,Ft=Ee*ft,ns=Te*_t,Wt=Te*ft,hs=Ue*ft,ys=Ye*st,vs=Ye*_t,Ds=Ye*ft,Fs=we[0],Es=we[1],Is=we[2];return ne[0]=(1-(ns+hs))*Fs,ne[1]=(Pt+Ds)*Fs,ne[2]=(Ft-vs)*Fs,ne[3]=0,ne[4]=(Pt-Ds)*Es,ne[5]=(1-(St+hs))*Es,ne[6]=(Wt+ys)*Es,ne[7]=0,ne[8]=(Ft+vs)*Is,ne[9]=(Wt-ys)*Is,ne[10]=(1-(St+ns))*Is,ne[11]=0,ne[12]=ue[0],ne[13]=ue[1],ne[14]=ue[2],ne[15]=1,ne}([],k||[0,0,0,1],E||[0,0,0],P||[1,1,1]),ee.globalMatrix=w(ee.localMatrix),O!==void 0){ee.meshes=m[O];const ne=ee.anchor=[0,0];for(const ie of ee.meshes){const{min:ue,max:we}=ie.aabb;ne[0]+=ue[0]+we[0],ne[1]+=ue[1]+we[1]}ne[0]=Math.floor(ne[0]/ee.meshes.length/2),ne[1]=Math.floor(ne[1]/ee.meshes.length/2)}if(B&&(B.id&&(ee.id=B.id),B.lights&&(ee.lights=function(ne){if(!ne.length)return[];const ie=function(Ue){const Ye=atob(Ue),st=new Uint8Array(Ye.length);for(let _t=0;_t1&&y[y.length-1].equals(y[0])&&y.pop();let k=0;for(let P=0;P0&&y.reverse();const E=fC(y.flatMap(P=>[P.x,P.y]),[]);return E.length===0?null:{vertices:y,indices:E}}function ctt(p,c){const m=[],y=[];let k=0;const E=[];for(const P of p){k=m.length;const O=P.vertexArray.float32,B=P.indexArray.uint16;for(let W=0;W0&&([y[P+1],y[P+2]]=[y[P+2],y[P+1]])}return{vertices:m,indices:y}}function Ide(p){const c=function(B,W){const J=[],ee=WebGL2RenderingContext;if(B.json.textures)for(const ne of B.json.textures){const ie={magFilter:ee.LINEAR,minFilter:ee.NEAREST,wrapS:ee.REPEAT,wrapT:ee.REPEAT};ne.sampler!==void 0&&Object.assign(ie,B.json.samplers[ne.sampler]),J.push({image:W[ne.source],sampler:ie,uploaded:!1})}return J}(p,p.images),m=function(B,W){const J=[];for(const ee of B.json.meshes){const ne=[];for(const ie of ee.primitives)ne.push(itt(ie,B,W));J.push(ne)}return J}(p,c),{scenes:y,scene:k,nodes:E}=p.json,P=y?y[k||0].nodes:[...E.keys()],O=[];for(const B of P)O.push(tke(E[B],p,m));return function(B,W,J){const ee={},ne=new Set;for(let ie=0;ie0){const ie=Array.from(ne.values()).sort((ue,we)=>ue-we);for(let ue=ie.length-1;ue>=0;ue--)B.splice(ie[ue],1)}}(O,P,p.json.nodes),O}function dtt(p){p.heightmap=new Float32Array(4096),p.heightmap.fill(-1);const c=p.vertexArray.float32,m=p.aabb.min[0]-1,y=p.aabb.min[1]-1,k=Eb/(p.aabb.max[0]-m+2),E=Eb/(p.aabb.max[1]-y+2);for(let P=0;Pp.heightmap[W*Eb+B]&&(p.heightmap[W*Eb+B]=O)}}function ske(p,c,m,y,k){m.reserve(m.length+4*p.length),y.reserve(y.length+10*p.length),k.reserve(k.length+10*p.length);let E=y.length;for(const P of p){const O=Math.min(10,Math.max(4,1.3*P.height))*c,B=[-P.normal[1],P.normal[0],0],W=Math.min(.29,.1*P.width/P.depth),J=P.width-2*P.depth*c*(W+.01),ee=Ge([],P.pos,B,J/2),ne=Ge([],P.pos,B,-J/2),ie=[ee[0],ee[1],ee[2]+P.height],ue=[ne[0],ne[1],ne[2]+P.height],we=Ge([],P.normal,B,W);ke(we,we,O);const Ee=Ge([],P.normal,B,-W);ke(Ee,Ee,O),de(we,ee,we),de(Ee,ne,Ee),ee[2]+=.1,ne[2]+=.1,y.emplaceBack(we[0],we[1],we[2]),y.emplaceBack(Ee[0],Ee[1],Ee[2]),y.emplaceBack(ee[0],ee[1],ee[2]),y.emplaceBack(ne[0],ne[1],ne[2]),y.emplaceBack(ie[0],ie[1],ie[2]),y.emplaceBack(ue[0],ue[1],ue[2]),y.emplaceBack(ee[0],ee[1],ee[2]),y.emplaceBack(ne[0],ne[1],ne[2]),y.emplaceBack(we[0],we[1],we[2]),y.emplaceBack(Ee[0],Ee[1],Ee[2]);const Te=J/O/2;k.emplaceBack(-Te-W,-1,Te,.8),k.emplaceBack(Te+W,-1,Te,.8),k.emplaceBack(-Te,0,Te,1.3),k.emplaceBack(Te,0,Te,1.3),k.emplaceBack(Te+W,-.8,Te,.7),k.emplaceBack(Te+W,-.8,Te,.7),k.emplaceBack(0,0,Te,1.3),k.emplaceBack(0,0,Te,1.3),k.emplaceBack(Te+W,-1.2,Te,.8),k.emplaceBack(Te+W,-1.2,Te,.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 utt(p,c){const m={};m.indexArray=new yl,m.vertexArray=new uh,m.colorArray=new cx,ske(p,c,m.indexArray,m.vertexArray,m.colorArray);const y={defined:!0};y.emissiveFactor=Fr.black;const k={};return k.baseColorFactor=Fr.white,y.pbrMetallicRoughness=k,m.material=y,m.aabb=new Tr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const rke=ra([{name:"a_pos_3f",components:3,type:"Float32"}]),htt=ra([{name:"a_normal_3",components:3,type:"Int16"}]),mtt=ra([{name:"a_centroid_3",components:3,type:"Int16"}]),nke=ra([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),ptt=ra([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),ftt=ra([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),gtt=ra([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),xtt=ra([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),ytt=ra([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),ake=Ut.types,dO=32767;function vtt(p,c){const m=Gs+c;for(const y of p)for(const k of y)if(k.x<-c||k.x>m||k.y<-c||k.y>m)return!1;return!0}function _tt(p){switch(p){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: ${p}`)}}class Lde{constructor(){this.layoutVertexArray=new uh,this.layoutAttenuationArray=new cx,this.layoutColorArray=new hh,this.indexArray=new yl,this.indexArrayForConflation=new yl,this.segmentsBucket=new io}}class Dde{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new io,this.entranceBloom=new Lde;const m=66560;this.layoutVertexArray=new uh,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new _v,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new _v,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new hh,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new dx,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new rC,this.layoutAOArray.reserve(m),this.indexArray=new yl,this.indexArray.reserve(66560),this.indexArrayForConflation=new yl,this.segmentsBucket=new io,this.entranceBloom=new Lde,c&&(this.layoutFacadePaintArray=new hh,this.layoutFacadeDataArray=new Ay,this.layoutFacadeVerticalRangeArray=new hh)}reserve(c,m,y){this.layoutVertexArray.reserveForAdditional(c),this.layoutCentroidArray.reserveForAdditional(c),this.layoutFloodLightDataArray.reserveForAdditional(c),this.layoutNormalArray.reserveForAdditional(c),this.layoutAOArray.reserveForAdditional(c),this.layoutColorArray.reserveForAdditional(c),this.indexArray.reserveForAdditional(m),y&&(this.layoutFacadePaintArray.reserveForAdditional(c),this.layoutFacadeDataArray.reserveForAdditional(c),this.layoutFacadeVerticalRangeArray.reserveForAdditional(c))}}class ike{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Lp,this.footprintsIndices=new dx,this.footprintsMin=new rs(1/0,1/0),this.footprintsMax=new rs(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Dde(!1),this.buildingWithFacade=new Dde(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=c.zoom,this.canonical=c.canonical,this.layers=c.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=c.index,this.hasPattern=!1,this.worldview=c.worldview,this.lut=c.lut,this.programConfigurations=new Um(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=c.projection,this.groundEffect=new xde(c),this.groundEffect.groundRadiusArray=new Ff,this.hasAppearances=null}updateFootprints(c,m){const y=new ZD([],[],1),k={vertices:[],indices:new Uint32Array(0),grid:y,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:k,id:c})}updateAppearances(c,m,y,k){}prepare(){return function(){if(sO!=null||Bje!=null)return null;if(_C!=null)return _C;const c=fetch(ta.BUILDING_GEN_URL);return _C=function(m){let y,k,E,P,O;function B(){y=new Uint8Array(O.buffer),k=new Int16Array(O.buffer),E=new Int32Array(O.buffer),P=new Float32Array(O.buffer)}function W(){throw new Error("Unexpected BuildingGen error.")}const J=()=>{},ee={a:{a:W,f:function(ne){const ie=y.length,ue=Math.max(ne>>>0,Math.ceil(1.2*ie)),we=Math.ceil((ue-ie)/65536);try{return O.grow(we),B(),!0}catch{return!1}},g:W,b:J,c:J,d:J,e:J}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(m,ee):m.then(ne=>ne.arrayBuffer()).then(ne=>WebAssembly.instantiate(ne,ee))).then(ne=>{const ie=ne.instance.exports;return(0,ie.g)(),O=ie.f,B(),new Het({setStyle:ie.h,setAOOptions:ie.i,setMetricOptions:ie.j,setStructuralOptions:ie.k,setFacadeOptions:ie.l,setFauxFacadeOptions:ie.m,setFacadeClassifierOptions:ie.n,addFeature:ie.o,addFacade:ie.p,generateMesh:ie.q,getLastError:ie.r,getOuterRingLength:ie.s,getMeshCount:ie.t,getPositionsPtr:ie.u,getPositionsLength:ie.v,getNormalsPtr:ie.w,getNormalsLength:ie.x,getAOPtr:ie.y,getAOLength:ie.z,getUVPtr:ie.A,getUVLength:ie.B,getFauxFacadePtr:ie.C,getFauxFacadeLength:ie.D,getIndicesPtr:ie.E,getIndicesLength:ie.F,getBuildingPart:ie.G,getRingCount:ie.H,getRingPtr:ie.I,getRingLength:ie.J,malloc:ie.K,free:ie.L,heapU8:y,heap16:k,heap32:E,heapF32:P})})}(c).then(m=>(_C=null,sO=m,sO)).catch(m=>{cr("Could not load building-gen"),_C=null,Bje=m}),_C}()}populate(c,m,y,k){const E=Wet();if(!E)return;const P=Be(y);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,B=new Map;let W=0;for(const{feature:Te}of c){if(ake[Te.type]!=="LineString"){O.set(Te.id,Te.properties.source_id);continue}const Ue=this.layers[0]._featureFilter.needGeometry;if(Ue&&!this.layers[0]._featureFilter.filter(new Ii(this.zoom),Te,y))continue;const Ye=Ht(Te,Ue);if(!Ue&&!this.layers[0]._featureFilter.filter(new Ii(this.zoom),Ye,y))continue;const st=Ue?Ye.geometry:Et(Te,y,k),_t=[];for(const Ft of st)for(const ns of Ft)_t.push(ns.x),_t.push(ns.y);const ft={coordinates:_t,crossPerc:Te.properties.cross_perc,distanceToRoad:Te.properties.distance_to_road,entrances:Te.properties.entrances,sourceId:0},St=Te.properties.source_id;let Pt=B.get(St);Pt||(Pt=[],B.set(St,Pt)),Pt.push(ft),++W}this.maxHeight=0;const J=new Array,ee=new Set,ne=Te=>{Te!=null&&ee.add(Te)},ie=(Te,Ue)=>{Te!=null&&J.push({buildingId:Te,footprintIndex:Ue})},ue=64*(c.length-W),we=ue/2;this.buildingWithFacade.reserve(ue,we,!0),this.buildingWithoutFacade.reserve(2*ue,2*we,!1),this.footprintsIndices.reserve(16*(c.length-W)),this.footprintsVertices.reserve(8*(c.length-W));for(const{feature:Te,id:Ue,index:Ye,sourceLayerIndex:st}of c){if(ake[Te.type]==="LineString")continue;const _t=this.layers[0]._featureFilter.needGeometry;if(_t&&!this.layers[0]._featureFilter.filter(new Ii(this.zoom),Te,y))continue;let ft=null;if(Te.properties&&Te.properties.hasOwnProperty("building_id")&&(ft=Te.properties.building_id,ee.has(ft)))continue;const St=Ht(Te,_t);if(!_t&&!this.layers[0]._featureFilter.filter(new Ii(this.zoom),St,y))continue;const Pt=_t?St.geometry:Et(Te,y,k),Ft=UT(Pt,500);let ns=!1;for(const Xr of Ft)if(Xr.length!==1){ns=!0;break}if(ns){ne(ft);continue}if(!vtt(Pt,163)){ne(ft);continue}const Wt=this.layers[0],hs=_tt(Wt.layout.get("building-roof-shape").evaluate(Te,{},y)),ys=Wt.layout.get("building-base").evaluate(Te,{},y),vs=Wt.layout.get("building-height").evaluate(Te,{},y),Ds=Wt.layout.get("building-flood-light-ground-radius").evaluate(Te,{},y),Fs=Wt.paint.get("building-ambient-occlusion-intensity"),Es=Ds/this.tileToMeter;Te.properties["building-part"]="roof";const Is=Wt.paint.get("building-color").evaluate(Te,{},this.canonical).toPremultipliedRenderColor(this.lut),us=Wt.paint.get("building-emissive-strength").evaluate(Te,{},this.canonical);Te.properties["building-part"]="wall";const as=Wt.paint.get("building-color").evaluate(Te,{},this.canonical).toPremultipliedRenderColor(this.lut),Ls=Wt.paint.get("building-emissive-strength").evaluate(Te,{},this.canonical);Te.properties["building-part"]="window";const Ks=Wt.paint.get("building-color").evaluate(Te,{},this.canonical).toPremultipliedRenderColor(this.lut),$s=Wt.paint.get("building-emissive-strength").evaluate(Te,{},this.canonical);Te.properties["building-part"]="door";const Pr=Wt.paint.get("building-color").evaluate(Te,{},this.canonical).toPremultipliedRenderColor(this.lut),lr=Wt.paint.get("building-emissive-strength").evaluate(Te,{},this.canonical);let pr=Wt.layout.get("building-flood-light-wall-radius").evaluate(Te,{},y);pr=Se(pr,0,2048);const wr=pr/2048*dO,Wn=O.get(Ue),qs=B.get(Wn)||[],jr=qs.length!==0&&Wt.layout.get("building-facade").evaluate(Te,{},y);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(jr,!1,1);let hn=0,ua=0,fa=0,Mn=0,pi=0,gt=0,wt=0,ms=0,Os=0,nr=0,ar=0;if(jr){let Xr=Math.round(Wt.layout.get("building-facade-floors").evaluate(Te,{},y));if(ys===0){Xr=Math.max(1,Xr-(qs.length>0?1:0));let ii=4;if(vs>100){const Hi=[10,13,15];ii=Hi[Te.id?Te.id%Hi.length:0]}else vs<=10&&(ii=3);E.setFacadeOptions(ii,!0),pi=(vs<15?1.3:1.61803)*ii/P}else pi=ys/P;gt=vs/P,pi=Math.min(pi,gt),fa=Wt.layout.get("building-facade-unit-width").evaluate(Te,{},y)/P,Mn=(gt-pi)/Xr,E.setFauxFacadeOptions(!0,!0,fa);const co=Wt.layout.get("building-facade-window").evaluate(Te,{},y);hn=co[0],ua=co[1],wt=Math.floor(65535*Math.min(1,pi/Gs)),ms=Math.floor(65535*Math.min(1,gt/Gs)),Os=Math.floor(255*hn)<<8|Math.floor(255*ua),nr=Math.floor(65535*Math.min(1,fa/Gs)),ar=Math.floor(65535*Math.min(1,Mn/Gs))}const Ir=Array(Ft.length),zr={x:1/0,y:1/0},kn={x:-1/0,y:-1/0},Fn={x:0,y:0};let Vn=0;for(let Xr=0;Xr0){const ii=[],Hi=Array(co.length+1);Hi[0]=0;for(let bl=0;blGs||zr.y<0||kn.y>Gs)&&this.featuresOnBorder.push({featureId:Te.id,footprintIndex:this.footprints.length});{const Xr=fC(yi,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Xr.length),this.footprintsIndices.uint16.set(Xr,Yr),this.buildingIds.add(ft??Te.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Ci.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Ci.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Li.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Li.y);const co={footprintVertexOffset:aa,footprintVertexLength:this.footprintsVertices.length-aa,footprintIndexOffset:Yr,footprintIndexLength:this.footprintsIndices.length-Yr,min:Ci,max:Li,hiddenFlags:0,indicesOffset:Qa,indicesLength:Ji,bloomIndicesOffset:ai,bloomIndicesLength:wi,groundEffectVertexOffset:Oo,groundEffectVertexLength:Mi,hasFauxFacade:jr,height:zn,promoteId:Ue,feature:St,parts:Ra,buildingBloom:Fa},ii=this.footprints.length;Te.id!==void 0&&this.featureFootprintLookup.set(Te.id,ii),ie(ft,ii),this.footprints.push(co)}this.programConfigurations.populatePaintArrays(en.layoutVertexArray.length,Te,Ye,{},m.availableImages,y,m.brightness),this.groundEffect.addPaintPropertiesData(Te,Ye,{},m.availableImages,y,m.brightness),m.featureIndex.insert(Te,Pt,Ye,st,this.index,fi)}J.forEach(({buildingId:Te,footprintIndex:Ue})=>{ee.has(Te)&&(this.footprints[Ue].hiddenFlags|=4)});const Ee=new Set;this.buildingIds.forEach((Te,Ue,Ye)=>{ee.has(Te)||Ee.add(Te)}),this.buildingIds=Ee,this.groundEffect.prepareBorderSegments()}update(c,m,y,k,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O),this.groundEffect.update(c,m,E,y,k,P,O),this.evaluate(this.layers[0],c),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(c){const m=y=>{y.layoutVertexBuffer=c.createVertexBuffer(y.layoutVertexArray,rke.members),y.layoutNormalBuffer=c.createVertexBuffer(y.layoutNormalArray,htt.members),y.layoutCentroidBuffer=c.createVertexBuffer(y.layoutCentroidArray,mtt.members),y.layoutFloodLightDataBuffer=c.createVertexBuffer(y.layoutFloodLightDataArray,ytt.members),y.layoutFacadeDataArray&&y.layoutFacadeDataArray.length&&(y.layoutFacadeDataBuffer=c.createVertexBuffer(y.layoutFacadeDataArray,ftt.members)),y.layoutFacadeVerticalRangeArray&&y.layoutFacadeVerticalRangeArray.length&&(y.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(y.layoutFacadeVerticalRangeArray,gtt.members)),y.entranceBloom.layoutVertexArray.length&&(y.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(y.entranceBloom.layoutVertexArray,rke.members),y.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(y.entranceBloom.layoutAttenuationArray,xtt.members)),this.uploadUpdatedColorBuffer(c),this.uploadUpdatedIndexBuffer(c)};this.uploaded||(m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){const c=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()))};c(this.buildingWithoutFacade),c(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(c,m,y=!0){let k=!1;const E=y?m:0,P=0|(y?-1:~m);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const O of c){const B=this.footprints[O],W=B.hiddenFlags&P|E;B.hiddenFlags!==W&&(B.hiddenFlags=W,k=!0,this.groundEffect.updateHiddenByLandmarkRange(B.groundEffectVertexOffset,B.groundEffectVertexLength,B.hiddenFlags!==0))}return k&&(this.indexArrayForConflationUploaded=!1),k}uploadUpdatedIndexBuffer(c){if(this.groundEffect.uploadHiddenByLandmark(c),this.indexArrayForConflationUploaded)return;const m=k=>{k.indexArray.length!==0&&(k.indexArrayForConflation.resize(k.indexArray.length),k.indexArrayForConflation.uint16.set(k.indexArray.uint16),k.entranceBloom.indexArrayForConflation.resize(k.entranceBloom.indexArray.length),k.entranceBloom.indexArrayForConflation.uint16.set(k.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const k of this.footprints){const E=k.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=k.indicesOffset+k.indicesLength;if(k.hiddenFlags!==0){for(let B=k.indicesOffset;B{k.indexArray.length!==0&&(k.indexBuffer?k.indexBuffer.updateData(k.indexArrayForConflation):k.indexBuffer=c.createIndexBuffer(k.indexArrayForConflation,!0),k.entranceBloom.indexBuffer?k.entranceBloom.indexBuffer.updateData(k.entranceBloom.indexArrayForConflation):k.entranceBloom.indexBuffer=c.createIndexBuffer(k.entranceBloom.indexArrayForConflation,!0))};y(this.buildingWithoutFacade),y(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(c){const m=y=>{y.layoutColorBuffer?y.layoutColorBuffer.updateData(y.layoutColorArray):y.layoutColorBuffer=c.createVertexBuffer(y.layoutColorArray,nke.members,!0),y.layoutFacadePaintArray&&(y.layoutFacadePaintBuffer?y.layoutFacadePaintBuffer.updateData(y.layoutFacadePaintArray):y.layoutFacadePaintBuffer=c.createVertexBuffer(y.layoutFacadePaintArray,ptt.members,!0)),y.entranceBloom.layoutColorBuffer?y.entranceBloom.layoutColorBuffer.updateData(y.entranceBloom.layoutColorArray):y.entranceBloom.layoutColorBuffer=c.createVertexBuffer(y.entranceBloom.layoutColorArray,nke.members,!0)};m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(c,m){const y=c.paint.get("building-ambient-occlusion-intensity");for(const k of this.footprints){if(4&k.hiddenFlags)continue;const E=m[k.promoteId],P=k.feature;P.properties["building-part"]="roof";const O=c.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),B=c.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="wall";const W=c.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),J=c.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="window";const ee=c.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ne=c.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="door";const ie=c.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ue=c.paint.get("building-emissive-strength").evaluate(P,E,this.canonical),we=k.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Te of k.parts){let Ue,Ye=O;Te.part===1?(Ye=O,Ue=B):Te.part===0?(Ye=W,Ue=J):Te.part===2?(Ye=ee,Ue=ne):Te.part===3&&(Ye=ie,Ue=ue),Ue=Se(Ue,0,1);for(let st=0;stP.max.x||B.max.xP.max.y||B.max.yO.max.x||O.min.x>c||m>O.max.y||O.min.y>m||O.height<=y||btt(P,this.footprintsVertices.float32.subarray(2*O.footprintVertexOffset,2*(O.footprintVertexOffset+O.footprintVertexLength)),this.footprintsIndices.uint16.subarray(O.footprintIndexOffset,O.footprintIndexOffset+O.footprintIndexLength))&&(y=O.height,this.footprintLookup[E]=O,k=O.hiddenFlags!==0);if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:k};this.footprintLookup[E]=void 0}}function btt(p,c,m){for(let y=0;y1&&(B=c[++O]);const J=Math.abs(W-B.left),ee=Math.abs(W-B.right),ne=Math.min(J,ee);let ie;const ue=E/y*(k+1);if(B.isDash){const we=k-Math.abs(ue);ie=Math.sqrt(ne*ne+we*we)}else ie=k-Math.sqrt(ne*ne+ue*ue);this.image.data[P+W]=Math.max(0,Math.min(255,ie+128))}}}addRegularDash(c,m){for(let B=c.length-1;B>=0;--B){const W=c[B],J=c[B+1];W.zeroLength?c.splice(B,1):J&&J.isDash===W.isDash&&(J.left=W.left,c.splice(B,1))}const y=c[0],k=c[c.length-1];y.isDash===k.isDash&&(y.left=k.left-this.width,k.right=y.right+this.width);const E=this.width*this.nextRow;let P=0,O=c[P];for(let B=0;B1&&(O=c[++P]);const W=Math.abs(B-O.left),J=Math.abs(B-O.right),ee=Math.min(W,J);this.image.data[E+B]=Math.max(0,Math.min(255,(O.isDash?ee:-ee)+m+128))}}addDash(c,m){const y=this.getKey(c,m);if(this.positions[y])return this.positions[y];const k=m==="round",E=k?7:0,P=2*E+1;if(this.nextRow+P>this.height)return cr("LineAtlas out of space"),null;c.length===0&&c.push(1);let O=0;for(let J=0;Jm.fqid),this.index=c.index,this.projection=c.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(m=>{this.gradients[m.id]={}}),this.layoutVertexArray=new YS,this.layoutVertexArray2=new uh,this.patternVertexArray=new uh,this.indexArray=new yl,this.programConfigurations=new Um(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new io,this.maxLineLength=0,this.zOffsetVertexArray=new uh,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=c.tessellationStep?c.tessellationStep:Gs/64,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){this.hasPattern=lde("line",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Be(y);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="hd-road-markup")this.elevationType="road";else{const ne=this.layers[0].layout.get("line-z-offset"),ie=ne.isConstant()&&!ne.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&ie?"none":"offset",this.elevationType==="offset"&&P==="none"&&cr(`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 B=[];for(const{feature:ne,id:ie,index:ue,sourceLayerIndex:we}of c){const Ee=this.layers[0]._featureFilter.needGeometry,Te=Ht(ne,Ee);if(!this.layers[0]._featureFilter.filter(new Ii(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Te,y))continue;const Ue=E?E.evaluate(Te,{},y):void 0,Ye={id:ie,properties:ne.properties,type:ne.type,sourceLayerIndex:we,index:ue,geometry:Ee?Te.geometry:Et(ne,y,k),patterns:{},sortKey:Ue};B.push(Ye)}E&&B.sort((ne,ie)=>ne.sortKey-ie.sortKey);const{lineAtlas:W,featureIndex:J}=m,ee=this.addConstantDashes(W);for(const ne of B){const{geometry:ie,index:ue,sourceLayerIndex:we}=ne;if(ee&&this.addFeatureDashes(ne,W),this.hasPattern){const Ee=cde("line",this.layers,ne,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Ee)}else this.addFeature(ne,ie,ue,y,W.positions,m.availableImages,m.brightness,m.elevationFeatures);J.insert(c[ue].feature,ie,ue,we,this.index)}}addConstantDashes(c){let m=!1;for(const y of this.layers){const k=y.paint.get("line-dasharray").value,E=y.layout.get("line-cap").value;if(k.kind!=="constant"||E.kind!=="constant")m=!0;else{const P=E.value,O=k.value;if(!O)continue;c.addDash(O,P)}}return m}addFeatureDashes(c,m){const y=this.zoom;for(const k of this.layers){const E=k.paint.get("line-dasharray").value,P=k.layout.get("line-cap").value;if(E.kind==="constant"&&P.kind==="constant")continue;let O,B;if(E.kind==="constant"){if(O=E.value,!O)continue}else O=E.evaluate({zoom:y},c);B=P.kind==="constant"?P.value:P.evaluate({zoom:y},c),m.addDash(O,B),c.patterns[k.id]=[m.getKey(O,B)]}}update(c,m,y,k,E,P,O,B){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,B)}addFeatures(c,m,y,k,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,y,k,P,c.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=c.createVertexBuffer(this.layoutVertexArray2,Ctt)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,Ttt)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,ktt.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Ntt),this.indexBuffer=c.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(c,m){let y,k;if(m&&m>0?(y=`mapbox_clip_start_${m}`,k=`mapbox_clip_end_${m}`):(y="mapbox_clip_start",k="mapbox_clip_end"),c.properties&&c.properties.hasOwnProperty(y)&&c.properties.hasOwnProperty(k))return{start:+c.properties[y],end:+c.properties[k]}}addFeature(c,m,y,k,E,P,O,B){const W=this.layers[0].layout,J=W.get("line-join").evaluate(c,{}),ee=W.get("line-cap").evaluate(c,{}),ne=W.get("line-miter-limit"),ie=W.get("line-round-limit");this.lineClips=this.lineFeatureClips(c),this.lineFeature=c;const ue=!(!c.properties||!c.properties.hasOwnProperty("mapbox_line_metrics"))&&c.properties.mapbox_line_metrics;this.zOffsetValue=W.get("line-z-offset").value;const we=this.layers[0].paint.get("line-width").value;if(we.kind!=="constant"&&we.isLineProgressConstant===!1&&(this.variableWidthValue=we),this.elevationType==="road"){const Ee=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(c,m,k,B,J,ee,ne,ie)){const[Te,Ue]=this.clipRuntimeLinesToTile(m,1);for(let Ye=0;Ye0?_t.parentIndex:null)}this.fillNonElevatedRoadSegment(Ee)}}else for(let Ee=0;Ee0?Ee:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,y,E,P,k,O,void 0,this.worldview)}computeSegNextDir(c,m){return c.nextPoint.sub(m.at(-2)).unit()}computeSegPrevDir(c,m){return m[1].sub(c.prevPoint).unit()}clipLinesToTile(c,m){return eO(c,-m,-m,Gs+m,Gs+m)}clipRuntimeLinesToTile(c,m){const y=[];return[eO(c,-m,-m,Gs+m,Gs+m,y),y]}addElevatedRoadFeature(c,m,y,k,E,P,O,B){const W=[],J=Ya.getElevationFeature(c,k);if(J){const ee=this.clipLinesToTile(m,1),ne=this.prepareElevatedLines(ee,J,y);for(const ie of ne)W.push({geometry:ie,elevation:J,elevationTileID:y,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(W.length===0)return!1;for(const ee of W){const ne=this.layoutVertexArray.length;this.addLine(ee.geometry,c,y,E,P,O,B);const ie=new ui(y,ee.elevationTileID);if(ee.elevation)for(let ue=ne;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),Ee=ie.pointElevation(we,ee.elevation,.05);this.updateHeightRange(Ee),this.zOffsetVertexArray.emplaceBack(Ee,0,0)}else this.fillNonElevatedRoadSegment(ne)}return!0}prepareElevatedLines(c,m,y){if(m.constantHeight!=null)return c;const k=[],E=1/Be(y);for(const P of c)qet(P,new Oa(m,E),0,k);return k}fillNonElevatedRoadSegment(c){for(let m=c;m0,ne=B&&B.progress.max<1;if(this.lineClips){let Ft={min:this.lineClips.start,max:this.lineClips.end},ns=1;if(B){const ys=this.lineClips.end-this.lineClips.start;Ft=function(vs,Ds,Fs){return{min:mi(vs.min,Ds,Fs),max:mi(vs.max,Ds,Fs)}}(B.progress,{min:0,max:1},Ft),ys>0&&(ns=(Ft.max-Ft.min)/ys)}const Wt=+m.properties.mapbox_clip_feature_len,hs=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Wt)||Number.isNaN(hs)){for(let vs=0;vs=2&&c[ue-1].equals(c[ue-2]);)ue--;let we=0;for(;we0,us=this.overscaling<=16?15*Gs/(512*this.overscaling):0;if(ns&&Wt==="round"){if(DsP&&(Wt="bevel"),Wt==="bevel"&&(Ds>2&&(Wt="flipbevel"),Ds2*us){const Ks=Te.sub(Te.sub(Ue)._mult(us/as)._round());this.updateDistance(Ue,Ks),this.addCurrentVertex(Ks,st,0,0,Ee,Pt),Ue=Ks}this.updateDistance(Ue,Te),ys._mult(Ds),this.addCurrentVertex(Te,ys,0,0,Ee,Pt);const Ls=Te.dist(Ye);if(Ls>2*us){const Ks=Te.add(Ye.sub(Te)._mult(us/Ls)._round());this.updateDistance(Te,Ks),this.addCurrentVertex(Ks,_t,0,0,Ee,Pt),Te=Ks}}else ys._mult(Ds),this.addCurrentVertex(Te,ys,0,0,Ee,Pt);else if(Wt==="flipbevel"){if(Ds>100)ys=_t.mult(-1);else{const as=Ds*st.add(_t).mag()/st.sub(_t).mag();ys._perp()._mult(as*(Is?-1:1))}this.addCurrentVertex(Te,ys,0,0,Ee,Pt),this.addCurrentVertex(Te,ys.mult(-1),0,0,Ee,Pt)}else if(Wt==="bevel"||Wt==="fakeround"){Pt!=null&&Ue&&this.addCurrentVertex(Te,St||st,-1,-1,Ee,Pt);const as=Te.dist(Ue)<=2*us&&Wt!=="bevel",Ls=ys.mult(Is?1:-1);Ls._mult(Ds);const Ks=_t.mult(Is?-1:1),$s=st.mult(Is?-1:1),Pr=this.evaluateLineProgressFeatures(this.distance);if(Pt==null&&(this.addHalfVertex(Te,Ls.x,Ls.y,!1,!Is,0,Ee,Pr),as||this.addHalfVertex(Te,Ls.x+2*$s.x,Ls.y+2*$s.y,!1,Is,0,Ee,Pr)),Wt==="fakeround"){const lr=Math.round(180*Fs/Math.PI/20);this.addHalfVertex(Te,$s.x,$s.y,!1,Is,0,Ee,Pr);for(let pr=0;pr1){this.lineSoFar=c.w;const we=(m.x-c.x)/ee,Ee=(m.y-c.y)/ee,Te=(m.z-c.z)/ee,Ue=(m.w-c.w)/ee;for(let Ye=1;Ye=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,J),B.primitiveLength++),P?this.e2=J:this.e1=J,W!=null&&this.zOffsetVertexArray.emplaceBack(W.zOffset,W.variableWidth,W.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(c,m){this.prevDistance=this.distance,this.distance+=c.dist(m),this.updateScaledDistance()}}function Rde(p,c,m){return p.xm||p.ym}let dke,uke;function hke(p,c,m){return c*(Gs/(p.tileSize*Math.pow(2,m-p.tileID.overscaledZ)))}vr(Ode,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const mke=(p,c,m)=>(1-m)*p+m*c;function pke(p,c){return 1/hke(p,1,c.tileZoom)}function fke(p,c,m,y){return p.translatePosMatrix(y||c.tileID.projMatrix,c,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const gke=p=>{const c=[];xke(p)&&c.push("RENDER_LINE_DASH"),p.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT");const m=p.paint.get("line-trim-offset");m[0]===0&&m[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),p.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const y=p.layout.get("line-join").constantOr("miter")==="none",k=!!p.paint.get("line-pattern").constantOr(1);return y&&k&&c.push("LINE_JOIN_NONE"),c};function xke(p){const c=p.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let Fde;const yke=()=>Fde||(Fde={layout:dke||(dke=new _o({"line-cap":new sr(Gt.layout_line["line-cap"]),"line-join":new sr(Gt.layout_line["line-join"]),"line-miter-limit":new Us(Gt.layout_line["line-miter-limit"]),"line-round-limit":new Us(Gt.layout_line["line-round-limit"]),"line-sort-key":new sr(Gt.layout_line["line-sort-key"]),"line-z-offset":new sr(Gt.layout_line["line-z-offset"]),"line-elevation-reference":new Us(Gt.layout_line["line-elevation-reference"]),"line-cross-slope":new Us(Gt.layout_line["line-cross-slope"]),visibility:new Us(Gt.layout_line.visibility),"line-width-unit":new Us(Gt.layout_line["line-width-unit"])})),paint:uke||(uke=new _o({"line-opacity":new sr(Gt.paint_line["line-opacity"]),"line-color":new sr(Gt.paint_line["line-color"]),"line-translate":new Us(Gt.paint_line["line-translate"]),"line-translate-anchor":new Us(Gt.paint_line["line-translate-anchor"]),"line-width":new sr(Gt.paint_line["line-width"]),"line-gap-width":new sr(Gt.paint_line["line-gap-width"]),"line-offset":new sr(Gt.paint_line["line-offset"]),"line-blur":new sr(Gt.paint_line["line-blur"]),"line-dasharray":new sr(Gt.paint_line["line-dasharray"]),"line-pattern":new sr(Gt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Us(Gt.paint_line["line-pattern-cross-fade"]),"line-gradient":new Cy(Gt.paint_line["line-gradient"]),"line-trim-offset":new Us(Gt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Us(Gt.paint_line["line-trim-fade-range"]),"line-trim-color":new Us(Gt.paint_line["line-trim-color"]),"line-emissive-strength":new sr(Gt.paint_line["line-emissive-strength"]),"line-border-width":new sr(Gt.paint_line["line-border-width"]),"line-border-color":new sr(Gt.paint_line["line-border-color"]),"line-occlusion-opacity":new Us(Gt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"})}))},Fde);class Itt extends sr{possiblyEvaluate(c,m){return m=new Ii(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(c,m)}evaluate(c,m,y,k){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(c,m,y,k)}}let tA;function vke(p,c){return c>0?c+2*p:p}const Ltt=ra([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Dtt=ra([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Ott=ra([{name:"a_projected_pos",components:4,type:"Float32"}],4);ra([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Rtt=ra([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Ftt=ra([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),ztt=ra([{name:"a_texb",components:2,type:"Uint16"}]),Btt=ra([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),$tt=ra([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ra([{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 _ke=ra([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),qtt=ra([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ra([{name:"triangle",components:3,type:"Uint16"}]),ra([{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"}]),ra([{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"}]),ra([{type:"Float32",name:"offsetX"}]),ra([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var rc=24;function Utt(p,c,m){return p.sections.forEach(y=>{y.text=function(k,E,P){const O=E.layout.get("text-transform").evaluate(P,{});return O==="uppercase"?k=k.toLocaleUpperCase():O==="lowercase"&&(k=k.toLocaleLowerCase()),Rf.applyArabicShaping&&(k=Rf.applyArabicShaping(k)),k}(y.text,c,m)}),p}const sA={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Vtt(p){return p==="︶"||p==="﹈"||p==="︸"||p==="﹄"||p==="﹂"||p==="︾"||p==="︼"||p==="︺"||p==="︘"||p==="﹀"||p==="︐"||p==="︓"||p==="︔"||p==="`"||p===" ̄"||p==="︑"||p==="︒"}function Htt(p){return p==="︵"||p==="﹇"||p==="︷"||p==="﹃"||p==="﹁"||p==="︽"||p==="︻"||p==="︹"||p==="︗"||p==="︿"}const zde=4294967296,bke=1/zde,wke=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let uO=class{constructor(p=new Uint8Array(16)){this.buf=ArrayBuffer.isView(p)?p:new Uint8Array(p),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(p,c,m=this.length){for(;this.pos>3,E=this.pos;this.type=7&y,p(k,c,this),this.pos===E&&this.skip(y)}return c}readMessage(p,c){return this.readFields(p,c,this.readVarint()+this.pos)}readFixed32(){const p=this.dataView.getUint32(this.pos,!0);return this.pos+=4,p}readSFixed32(){const p=this.dataView.getInt32(this.pos,!0);return this.pos+=4,p}readFixed64(){const p=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*zde;return this.pos+=8,p}readSFixed64(){const p=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*zde;return this.pos+=8,p}readFloat(){const p=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,p}readDouble(){const p=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,p}readVarint(p){const c=this.buf;let m,y;return y=c[this.pos++],m=127&y,y<128?m:(y=c[this.pos++],m|=(127&y)<<7,y<128?m:(y=c[this.pos++],m|=(127&y)<<14,y<128?m:(y=c[this.pos++],m|=(127&y)<<21,y<128?m:(y=c[this.pos],m|=(15&y)<<28,function(k,E,P){const O=P.buf;let B,W;if(W=O[P.pos++],B=(112&W)>>4,W<128||(W=O[P.pos++],B|=(127&W)<<3,W<128)||(W=O[P.pos++],B|=(127&W)<<10,W<128)||(W=O[P.pos++],B|=(127&W)<<17,W<128)||(W=O[P.pos++],B|=(127&W)<<24,W<128)||(W=O[P.pos++],B|=(1&W)<<31,W<128))return wC(k,B,E);throw new Error("Expected varint not more than 10 bytes")}(m,p,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const p=this.readVarint();return p%2==1?(p+1)/-2:p/2}readBoolean(){return!!this.readVarint()}readString(){const p=this.readVarint()+this.pos,c=this.pos;return this.pos=p,p-c>=12&&wke?wke.decode(this.buf.subarray(c,p)):function(m,y,k){let E="",P=y;for(;P239?4:O>223?3:O>191?2:1;if(P+ne>k)break;ne===1?O<128&&(ee=O):ne===2?(B=m[P+1],(192&B)==128&&(ee=(31&O)<<6|63&B,ee<=127&&(ee=null))):ne===3?(B=m[P+1],W=m[P+2],(192&B)==128&&(192&W)==128&&(ee=(15&O)<<12|(63&B)<<6|63&W,(ee<=2047||ee>=55296&&ee<=57343)&&(ee=null))):ne===4&&(B=m[P+1],W=m[P+2],J=m[P+3],(192&B)==128&&(192&W)==128&&(192&J)==128&&(ee=(15&O)<<18|(63&B)<<12|(63&W)<<6|63&J,(ee<=65535||ee>=1114112)&&(ee=null))),ee===null?(ee=65533,ne=1):ee>65535&&(ee-=65536,E+=String.fromCharCode(ee>>>10&1023|55296),ee=56320|1023&ee),E+=String.fromCharCode(ee),P+=ne}return E}(this.buf,c,p)}readBytes(){const p=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,p);return this.pos=p,c}readPackedVarint(p=[],c){const m=this.readPackedEnd();for(;this.pos127;);else if(c===2)this.pos=this.readVarint()+this.pos;else if(c===5)this.pos+=4;else{if(c!==1)throw new Error(`Unimplemented type: ${c}`);this.pos+=8}}writeTag(p,c){this.writeVarint(p<<3|c)}realloc(p){let c=this.length||16;for(;c268435455||p<0?function(c,m){let y,k;if(c>=0?(y=c%4294967296|0,k=c/4294967296|0):(y=~(-c%4294967296),k=~(-c/4294967296),4294967295^y?y=y+1|0:(y=0,k=k+1|0)),c>=18446744073709552e3||c<-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)}(y,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)))))}(k,m)}(p,this):(this.realloc(4),this.buf[this.pos++]=127&p|(p>127?128:0),p<=127||(this.buf[this.pos++]=127&(p>>>=7)|(p>127?128:0),p<=127||(this.buf[this.pos++]=127&(p>>>=7)|(p>127?128:0),p<=127||(this.buf[this.pos++]=p>>>7&127))))}writeSVarint(p){this.writeVarint(p<0?2*-p-1:2*p)}writeBoolean(p){this.writeVarint(+p)}writeString(p){p=String(p),this.realloc(4*p.length),this.pos++;const c=this.pos;this.pos=function(y,k,E){for(let P,O,B=0;B55295&&P<57344){if(!O){P>56319||B+1===k.length?(y[E++]=239,y[E++]=191,y[E++]=189):O=P;continue}if(P<56320){y[E++]=239,y[E++]=191,y[E++]=189,O=P;continue}P=O-55296<<10|P-56320|65536,O=null}else O&&(y[E++]=239,y[E++]=191,y[E++]=189,O=null);P<128?y[E++]=P:(P<2048?y[E++]=P>>6|192:(P<65536?y[E++]=P>>12|224:(y[E++]=P>>18|240,y[E++]=P>>12&63|128),y[E++]=P>>6&63|128),y[E++]=63&P|128)}return E}(this.buf,p,this.pos);const m=this.pos-c;m>=128&&jke(c,m,this),this.pos=c-1,this.writeVarint(m),this.pos+=m}writeFloat(p){this.realloc(4),this.dataView.setFloat32(this.pos,p,!0),this.pos+=4}writeDouble(p){this.realloc(8),this.dataView.setFloat64(this.pos,p,!0),this.pos+=8}writeBytes(p){const c=p.length;this.writeVarint(c),this.realloc(c);for(let m=0;m=128&&jke(m,y,this),this.pos=m-1,this.writeVarint(y),this.pos+=y}writeMessage(p,c,m){this.writeTag(p,2),this.writeRawMessage(c,m)}writePackedVarint(p,c){c.length&&this.writeMessage(p,Wtt,c)}writePackedSVarint(p,c){c.length&&this.writeMessage(p,Gtt,c)}writePackedBoolean(p,c){c.length&&this.writeMessage(p,Ytt,c)}writePackedFloat(p,c){c.length&&this.writeMessage(p,Ktt,c)}writePackedDouble(p,c){c.length&&this.writeMessage(p,Ztt,c)}writePackedFixed32(p,c){c.length&&this.writeMessage(p,Xtt,c)}writePackedSFixed32(p,c){c.length&&this.writeMessage(p,Qtt,c)}writePackedFixed64(p,c){c.length&&this.writeMessage(p,Jtt,c)}writePackedSFixed64(p,c){c.length&&this.writeMessage(p,est,c)}writeBytesField(p,c){this.writeTag(p,2),this.writeBytes(c)}writeFixed32Field(p,c){this.writeTag(p,5),this.writeFixed32(c)}writeSFixed32Field(p,c){this.writeTag(p,5),this.writeSFixed32(c)}writeFixed64Field(p,c){this.writeTag(p,1),this.writeFixed64(c)}writeSFixed64Field(p,c){this.writeTag(p,1),this.writeSFixed64(c)}writeVarintField(p,c){this.writeTag(p,0),this.writeVarint(c)}writeSVarintField(p,c){this.writeTag(p,0),this.writeSVarint(c)}writeStringField(p,c){this.writeTag(p,2),this.writeString(c)}writeFloatField(p,c){this.writeTag(p,5),this.writeFloat(c)}writeDoubleField(p,c){this.writeTag(p,1),this.writeDouble(c)}writeBooleanField(p,c){this.writeVarintField(p,+c)}};function wC(p,c,m){return m?4294967296*c+(p>>>0):4294967296*(c>>>0)+(p>>>0)}function jke(p,c,m){const y=c<=16383?1:c<=2097151?2:c<=268435455?3:Math.floor(Math.log(c)/(7*Math.LN2));m.realloc(y);for(let k=m.pos-1;k>=p;k--)m.buf[k+y]=m.buf[k]}function Wtt(p,c){for(let m=0;m=0&&y>=c&&hO[this.text.charCodeAt(y)];y--)m--;this.text=this.text.substring(c,m),this.sectionIndex=this.sectionIndex.slice(c,m)}substring(c,m){const y=new jC;return y.text=this.text.substring(c,m),y.sectionIndex=this.sectionIndex.slice(c,m),y.sections=this.sections,y}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((c,m)=>Math.max(c,this.sections[m].scale),0)}addTextSection(c,m){this.text+=c.text,this.sections.push(rA.forText(c.scale,c.fontStack||m));const y=this.sections.length-1;for(let k=0;k=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function $de(p,c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we=1){const Ee=jC.fromFeature(p,k,we);ee===fh.vertical&&Ee.verticalizePunctuation(ne);let Te=[];const Ue=function(St,Pt,Ft,ns,Wt,hs){if(!St)return[];const ys=[],vs=function(Is,us,as,Ls,Ks,$s){let Pr=0;for(let lr=0;lr=0;let Fs=0;for(let Is=0;Is0&&Fa>Mn&&(Mn=Fa)}else{const Ca=Ft[Os.fontStack];if(!Ca)continue;Ca[ar]&&(kn=Ca[ar]);const Ra=Pt[Os.fontStack];if(!Ra)continue;const Fa=Ra.glyphs[ar];if(!Fa)continue;if(zr=Fa.metrics,Vn=ar!==8203?rc:0,$s){const ai=Ra.ascender!==void 0?Math.abs(Ra.ascender):0,wi=Ra.descender!==void 0?Math.abs(Ra.descender):0,fi=(ai+wi)*Ir;pi-m/2;){if(P--,P<0)return!1;O-=p[P].dist(E),E=p[P]}O+=p[P].dist(p[P+1]),P++;const B=[];let W=0;for(;Oy;)W-=B.shift().angleDelta;if(W>k)return!1;P++,O+=J.dist(ee)}return!0}function Lke(p){let c=0;for(let m=0;mW){const ue=(W-B)/ie,we=Ur(ee.x,ne.x,ue),Ee=Ur(ee.y,ne.y,ue),Te=new Dy(we,Ee,0,ne.angleTo(ee),J);return!P||Ike(p,Te,O,P,c)?Te:void 0}B+=ie}}function ost(p,c,m,y,k,E,P,O,B){const W=Dke(y,E,P),J=Oke(y,k),ee=J*P,ne=p[0].x===0||p[0].x===B||p[0].y===0||p[0].y===B;return c-ee=0&&st=0&&_t=0&&ne+W<=J){const ft=new Dy(st,_t,0,Ue,ue);y&&!Ike(p,ft,E,y,k)||ie.push(ft)}}ee+=Te}return O||ie.length||P||(ie=Rke(p,ee/2,m,y,k,E,P,!0,B)),ie}function Fke(p){let c=0,m=0;for(const P of p)c+=P.w*P.h,m=Math.max(m,P.w);p.sort((P,O)=>O.h-P.h);const y=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),m),h:1/0}];let k=0,E=0;for(const P of p)for(let O=y.length-1;O>=0;O--){const B=y[O];if(!(P.w>B.w||P.h>B.h)){if(P.x=B.x,P.y=B.y,E=Math.max(E,P.y+P.h),k=Math.max(k,P.x+P.w),P.w===B.w&&P.h===B.h){const W=y.pop();W&&O1?ue-1:ue,md.copy(ee.data,W,{x:0,y:0},{x:we,y:Ee},ee.data,y),md.copy(ee.data,W,{x:0,y:Ue-ue},{x:we,y:Ee-ue},{width:Te,height:ue},y),md.copy(ee.data,W,{x:0,y:0},{x:we,y:Ee+Ue},{width:Te,height:ue},y),md.copy(ee.data,W,{x:Te-ue,y:0},{x:we-ue,y:Ee},{width:ue,height:Ue},y),md.copy(ee.data,W,{x:0,y:0},{x:we+Te,y:Ee},{width:ue,height:Ue},y),md.copy(ee.data,W,{x:Te-ue,y:Ue-ue},{x:we-ue,y:Ee-ue},{width:ue,height:ue},y),md.copy(ee.data,W,{x:0,y:Ue-ue},{x:we+Te,y:Ee-ue},{width:ue,height:ue},y),md.copy(ee.data,W,{x:0,y:0},{x:we+Te,y:Ee+Ue},{width:ue,height:ue},y),md.copy(ee.data,W,{x:Te-ue,y:0},{x:we-ue,y:Ee+Ue},{width:ue,height:ue},y)}this.lut=y,this.image=W,this.iconPositions=k,this.patternPositions=E}addImages(c,m,y,k){for(const[E,P]of c.entries()){const{bin:O,imagePosition:B,imageVariant:W}=Wde(E,P,y);m.set(E,B),k.push(O),P.hasRenderCallback&&this.haveRenderCallbacks.push(W.id)}}patchUpdatedImages(c,m,y){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(k=>c.hasImage(k,y)),c.dispatchRenderCallbacks(this.haveRenderCallbacks,y);for(const k of c.getUpdatedImages(y)){for(const E of this.iconPositions.keys()){const P=Af.parse(E);if(Hs.isEqual(P.id,k)){const O=c.getImage(k,y);this.patchUpdatedImage(this.iconPositions.get(E),O,m,null)}}for(const E of this.patternPositions.keys()){const P=Af.parse(E);if(Hs.isEqual(P.id,k)){const O=c.getImage(k,y);this.patchUpdatedImage(this.patternPositions.get(E),O,m,this.lut)}}}}patchUpdatedImage(c,m,y,k=null){if(!c||!m||c.version===m.version)return;c.version=m.version;const[E,P]=c.tl,O=c.sdf;if(this.lut||O){const B={width:m.data.width,height:m.data.height},W=new md(B);md.copy(m.data,W,{x:0,y:0},{x:0,y:0},B,k,O),y.update(W,{position:{x:E,y:P}})}else y.update(m.data,{position:{x:E,y:P}})}}vr(nA,"ImagePosition"),vr(zke,"ImageAtlas");const aA=1e20;function Bke(p,c,m,y,k,E,P,O,B){for(let W=c;W-1);B++,E[B]=O,P[B]=W,P[B+1]=aA}for(let O=0,B=0;O{let B=this.entries[E];B||(B=this.entries[E]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let W=B.glyphs[P];if(W!==void 0)return void O(null,{stack:E,id:P,glyph:W});if(W=this._tinySDF(B,E,P),W)return B.glyphs[P]=W,void O(null,{stack:E,id:P,glyph:W});const J=Math.floor(P/256);if(256*J>65535)return cr("glyphs > 65535 not supported"),void O(null,{stack:E,id:P,glyph:W});if(B.ranges[J])return void O(null,{stack:E,id:P,glyph:W});let ee=B.requests[J];ee||(ee=B.requests[J]=[],SC.loadGlyphRange(E,J,k,this.requestManager,(ne,ie)=>{if(ie){B.ascender=ie.ascender,B.descender=ie.descender;for(const ue in ie.glyphs)this._doesCharSupportLocalGlyph(+ue)||(B.glyphs[+ue]=ie.glyphs[+ue]);B.ranges[J]=!0}for(const ue of ee)ue(ne,ie);delete B.requests[J]})),ee.push((ne,ie)=>{ne?O(ne):ie&&O(null,{stack:E,id:P,glyph:ie.glyphs[P]||null})})},(E,P)=>{if(E)m(E);else if(P){const O={};for(const{stack:B,id:W,glyph:J}of P)O[B]===void 0&&(O[B]={}),O[B].glyphs===void 0&&(O[B].glyphs={}),O[B].glyphs[W]=J&&{id:J.id,bitmap:J.bitmap.clone(),metrics:J.metrics},O[B].ascender=this.entries[B].ascender,O[B].descender=this.entries[B].descender;m(null,O)}})}_doesCharSupportLocalGlyph(c){return this.localGlyphMode!==Gde.none&&(this.localGlyphMode===Gde.all?!!this.localFontFamily:!!this.localFontFamily&&(Zr["CJK Unified Ideographs"](c)||Zr["Hangul Syllables"](c)||Zr.Hiragana(c)||Zr.Katakana(c)||Zr["CJK Symbols and Punctuation"](c)||Zr["CJK Unified Ideographs Extension A"](c)||Zr["CJK Unified Ideographs Extension B"](c)||Zr.Osage(c)))}_tinySDF(c,m,y){const k=this.localFontFamily;if(!k||!this._doesCharSupportLocalGlyph(y))return;let E=c.tinySDF;if(!E){let we="400";/bold/i.test(m)?we="900":/medium/i.test(m)?we="500":/light/i.test(m)&&(we="200"),E=c.tinySDF=new SC.TinySDF({fontFamily:k,fontWeight:we,fontSize:24*Kf,buffer:3*Kf,radius:8*Kf}),E.fontWeight=we}if(this.localGlyphs[E.fontWeight][y])return this.localGlyphs[E.fontWeight][y];const P=String.fromCodePoint(y),{data:O,width:B,height:W,glyphWidth:J,glyphHeight:ee,glyphLeft:ne,glyphTop:ie,glyphAdvance:ue}=E.draw(P);return this.localGlyphs[E.fontWeight][y]={id:y,bitmap:new Av({width:B,height:W},O),metrics:{width:J/Kf,height:ee/Kf,left:ne/Kf,top:ie/Kf-27,advance:ue/Kf,localGlyph:!0}}}}SC.loadGlyphRange=function(p,c,m,y,k){const E=256*c,P=E+255,O=y.transformRequest(y.normalizeGlyphsURL(m).replace("{fontstack}",p).replace("{range}",`${E}-${P}`),Cf.Glyphs);Ru(O,(B,W)=>{if(B)k(B);else if(W){const J={},ee=function(ne){return new uO(ne).readFields(tst,{})}(W);for(const ne of ee.glyphs)J[ne.id]=ne;k(null,{glyphs:J,ascender:ee.ascender,descender:ee.descender})}})},SC.TinySDF=class{constructor({fontSize:p=24,buffer:c=3,radius:m=8,cutoff:y=.25,fontFamily:k="sans-serif",fontWeight:E="normal",fontStyle:P="normal",lang:O=null}={}){this.buffer=c,this.cutoff=y,this.radius=m,this.lang=O;const B=this.size=p+4*c,W=this._createCanvas(B),J=this.ctx=W.getContext("2d",{willReadFrequently:!0});J.font=`${P} ${E} ${p}px ${k}`,J.textBaseline="alphabetic",J.textAlign="left",J.fillStyle="black",this.gridOuter=new Float64Array(B*B),this.gridInner=new Float64Array(B*B),this.f=new Float64Array(B),this.z=new Float64Array(B+1),this.v=new Uint16Array(B)}_createCanvas(p){const c=document.createElement("canvas");return c.width=c.height=p,c}draw(p){const{width:c,actualBoundingBoxAscent:m,actualBoundingBoxDescent:y,actualBoundingBoxLeft:k,actualBoundingBoxRight:E}=this.ctx.measureText(p),P=Math.ceil(m),O=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-k))),B=Math.min(this.size-this.buffer,P+Math.ceil(y)),W=O+2*this.buffer,J=B+2*this.buffer,ee=Math.max(W*J,0),ne=new Uint8ClampedArray(ee),ie={data:ne,width:W,height:J,glyphWidth:O,glyphHeight:B,glyphTop:P,glyphLeft:0,glyphAdvance:c};if(O===0||B===0)return ie;const{ctx:ue,buffer:we,gridInner:Ee,gridOuter:Te}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(we,we,O,B),ue.fillText(p,we,we+P);const Ue=ue.getImageData(we,we,O,B);Te.fill(aA,0,ee),Ee.fill(0,0,ee);for(let Ye=0;Ye0?St*St:0,Ee[ft]=St<0?St*St:0}}Bke(Te,0,0,W,J,W,this.f,this.v,this.z),Bke(Ee,we,we,O,B,W,this.f,this.v,this.z);for(let Ye=0;Ye{const Ds=fO(Wt.stretch-Ue,Ye,J,p.left*k),Fs=gO(Wt.fixed-ft,St,Wt.stretch,ue),Es=fO(hs.stretch-st,_t,ee,p.top*k),Is=gO(hs.fixed-Pt,Ft,hs.stretch,we),us=fO(ys.stretch-Ue,Ye,J,p.left*k),as=gO(ys.fixed-ft,St,ys.stretch,ue),Ls=fO(vs.stretch-st,_t,ee,p.top*k),Ks=gO(vs.fixed-Pt,Ft,vs.stretch,we),$s=new rs(Ds,Es),Pr=new rs(us,Es),lr=new rs(us,Ls),pr=new rs(Ds,Ls),wr=new rs(Fs/O,Is/O),Wn=new rs(as/O,Ks/O),qs=c*Math.PI/180;if(qs){const pi=Math.sin(qs),gt=Math.cos(qs),wt=[gt,-pi,pi,gt];$s._matMult(wt),Pr._matMult(wt),pr._matMult(wt),lr._matMult(wt)}const jr=Wt.stretch+Wt.fixed,hn=ys.stretch+ys.fixed,ua=hs.stretch+hs.fixed,fa=vs.stretch+vs.fixed,Mn=p.imageSecondary;return{tl:$s,tr:Pr,bl:pr,br:lr,texPrimary:{x:P.paddedRect.x+px+jr,y:P.paddedRect.y+px+ua,w:hn-jr,h:fa-ua},texSecondary:Mn?{x:Mn.paddedRect.x+px+jr,y:Mn.paddedRect.y+px+ua,w:hn-jr,h:fa-ua}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:wr,pixelOffsetBR:Wn,minFontScaleX:St/O/J,minFontScaleY:Ft/O/ee,isSDF:m}};if(y&&(P.stretchX||P.stretchY)){const Wt=Uke(ne,Ee,ue),hs=Uke(ie,Te,we);for(let ys=0;ysE)&&(E=ue.x),(!ie||ue.y>P)&&(P=ue.y)}const B=Math.min(E-y,P-k);let W=B/2;const J=new gS([],ust);if(B===0)return new rs(y,k);for(let ie=y;ieee.d||!ee.d)&&(ee=ie,m&&console.log("found best %d after %d probes",Math.round(1e4*ie.d)/1e4,ne)),ie.max-ee.d<=c||(W=ie.h/2,J.push(new CC(ie.p.x-W,ie.p.y-W,W,p)),J.push(new CC(ie.p.x+W,ie.p.y-W,W,p)),J.push(new CC(ie.p.x-W,ie.p.y+W,W,p)),J.push(new CC(ie.p.x+W,ie.p.y+W,W,p)),ne+=4)}return m&&(console.log(`num probes: ${ne}`),console.log(`best distance: ${ee.d}`)),ee.p}function ust(p,c){return c.max-p.max}class CC{constructor(c,m,y,k){this.p=new rs(c,m),this.h=y,this.d=function(E,P){let O=!1,B=1/0;for(let W=0;WE.y!=we.y>E.y&&E.x<(we.x-ue.x)*(E.y-ue.y)/(we.y-ue.y)+ue.x&&(O=!O),B=Math.min(B,Mo(E,ue,we))}}return(O?1:-1)*Math.sqrt(B)}(this.p,k),this.max=this.d+this.h*Math.SQRT2}}const hst=Object.keys,Zde=Number.POSITIVE_INFINITY,mst=Math.sqrt(2);function Pv(p,c,m,y,k){const E=Ude(p)&&p.collisionPadding?p.collisionPadding:[0,0,0,0],P={top:p.top-E[1],bottom:p.bottom+E[3],left:p.left-E[0],right:p.right+E[2],scaled:!1};return y!==void 0&&function(O,B){O.top*=B,O.bottom*=B,O.left*=B,O.right*=B,O.scaled=!0}(P,y),m&&function(O,B){if(!B)return;const W=Jr(B),J=new rs(O.left,O.top),ee=new rs(O.right,O.top),ne=new rs(O.left,O.bottom),ie=new rs(O.right,O.bottom),ue=new rs(0,0);J._rotateAround(W,ue),ee._rotateAround(W,ue),ne._rotateAround(W,ue),ie._rotateAround(W,ue),O.left=Math.min(J.x,ee.x,ne.x,ie.x),O.right=Math.max(J.x,ee.x,ne.x,ie.x),O.top=Math.min(J.y,ee.y,ne.y,ie.y),O.bottom=Math.max(J.y,ee.y,ne.y,ie.y)}(P,m),k&&(P.left+=k[0],P.right+=k[0],P.top+=k[1],P.bottom+=k[1]),c?{top:Math.min(c.top,P.top),bottom:Math.max(c.bottom,P.bottom),left:Math.min(c.left,P.left),right:Math.max(c.right,P.right),scaled:c.scaled||P.scaled}:P}function Hke(p,[c,m]){let y=0,k=0;if(m===Zde){c<0&&(c=0);const E=c/mst;switch(p){case"top-right":case"top-left":k=E-7;break;case"bottom-right":case"bottom-left":k=7-E;break;case"bottom":k=7-c;break;case"top":k=c-7}switch(p){case"top-right":case"bottom-right":y=-E;break;case"top-left":case"bottom-left":y=E;break;case"left":y=c;break;case"right":y=-c}}else{switch(c=Math.abs(c),m=Math.abs(m),p){case"top-right":case"top-left":case"top":k=m-7;break;case"bottom-right":case"bottom-left":case"bottom":k=7-m}switch(p){case"top-right":case"bottom-right":case"right":y=-c;break;case"top-left":case"bottom-left":case"left":y=c}}return[y,k]}function pst(p,c,m,y,k,E,P,O,B,W,J,ee,ne,ie){const ue=p.layers[0],we=ue.appearances;if(we.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Ee={iconBBox:null,iconVerticalBBox:null},Te={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ue,baseTextRotate:Ye,iconScaleFactor:st}=function(ft,St,Pt){const Ft=ft.get("icon-rotate").evaluate(St,{},Pt),ns=ft.get("text-rotate").evaluate(St,{},Pt),[Wt,hs]=ft.get("icon-size-scale-range");return{baseIconRotate:Ft,baseTextRotate:ns,iconScaleFactor:Se(1,Wt,hs)}}(y,k,E);c&&(Ee.iconBBox=Pv(c,Ee.iconBBox,Ue,P),m)&&(Ee.iconVerticalBBox=Pv(m,Ee.iconVerticalBBox,Ue+90,P));const _t=yO(ee.horizontal);_t&&(Te.textBBox=Pv(_t,Te.textBBox,Ye,1,ie)),ee.vertical&&(Te.textVerticalBBox=Pv(ee.vertical,Te.textVerticalBBox,Ye+90,1,ie));for(const ft of we)ft.hasIconProperties()&&fst(Ee,p,ue,ft,k,E,O,Ue,P,B,c,W,st,J),ft.hasTextProperties()&&gst(Te,ue,ft,k,E,ie,Ye,ne,_t,ee.vertical);return{iconBBox:Ee.iconBBox,iconVerticalBBox:Ee.iconVerticalBBox,textBBox:Te.textBBox,textVerticalBBox:Te.textVerticalBBox}}function fst(p,c,m,y,k,E,P,O,B,W,J,ee,ne,ie){const{appearanceIconOffset:ue,appearanceIconRotate:we,appearanceIconSize:Ee}=function(st,_t,ft,St,Pt,Ft,ns,Wt){const hs=st.hasProperty("icon-offset")?_t.getAppearanceValueAndResolveTokens(st,"icon-offset",ft,St,[]):null,ys=hs&&Array.isArray(hs)?hs:Pt,vs=st.hasProperty("icon-rotate")?_t.getAppearanceValueAndResolveTokens(st,"icon-rotate",ft,St,[]):null,Ds=typeof vs=="number"?vs:Ft,Fs=st.hasProperty("icon-size")?_t.getAppearanceValueAndResolveTokens(st,"icon-size",ft,St,[]):null;return{appearanceIconOffset:ys,appearanceIconRotate:Ds,appearanceIconSize:typeof Fs=="number"?Fs*Wt.iconScaleFactor:ns}}(y,m,k,E,P,O,B,W);let Te=null,Ue=null,Ye=null;y.hasProperty("icon-image")?Ye=function(st,_t,ft,St,Pt,Ft,ns){let Wt=null;const hs=_t.getAppearanceValueAndResolveTokens(ft,"icon-image",St,Pt,[]);if(hs){const ys=st.getResolvedImageFromTokens(hs),vs=ft.getUnevaluatedProperty("icon-size"),Ds=iA(ys,kC(st.zoom,vs,st.worldview),vs,Pt,st.zoom,St,st.pixelRatio,ns,st.worldview);Wt=Ft.get(Ds.iconPrimary.toString())}return Wt}(c,m,y,k,E,ee,ne):J&&(Ye=J.imagePrimary),Ye&&(Te=mO(Ye,null,ue,ie),c.allowVerticalPlacement&&(Ue=mO(Ye,null,ue,ie))),Te&&(p.iconBBox=Pv(Te,p.iconBBox,we,Ee)),Ue&&(p.iconVerticalBBox=Pv(Ue,p.iconVerticalBBox,we+90,Ee))}function gst(p,c,m,y,k,E,P,O,B,W){const{appearanceTextOffset:J,appearanceTextRotate:ee,appearanceTextSize:ne}=function(ue,we,Ee,Te,Ue,Ye,st){const _t=ue.hasProperty("text-offset")?we.getAppearanceValueAndResolveTokens(ue,"text-offset",Ee,Te,[]):null,ft=_t&&Array.isArray(_t)?[_t[0]*rc,_t[1]*rc]:Ue,St=ue.hasProperty("text-rotate")?we.getAppearanceValueAndResolveTokens(ue,"text-rotate",Ee,Te,[]):null,Pt=typeof St=="number"?St:Ye,Ft=ue.hasProperty("text-size")?we.getAppearanceValueAndResolveTokens(ue,"text-size",Ee,Te,[]):null;return{appearanceTextOffset:ft,appearanceTextRotate:Pt,appearanceTextSize:typeof Ft=="number"?Ft:st}}(m,c,y,k,E,P,O),ie=ne/O;B&&(p.textBBox=Pv(B,p.textBBox,ee,ie,J)),W&&(p.textVerticalBBox=Pv(W,p.textVerticalBBox,ee+90,ie,J))}function xO(p,c,m,y,k,E,P,O,B){if(!c||!c.usvg)return;const W=Pke(y),J=Pke(k),ee=E!=="both"&&E!=="width"||!Ake(y)?1:J.width/W.width,ne=E!=="both"&&E!=="height"||!Eke(y)?1:J.height/W.height;m.scaleSelf(ee,ne);const ie=m.toString();P.set(ie,m),O.set(ie,c);const{imagePosition:ue}=Wde(ie,c,Ib);B.set(ie,ue)}function Wke(p,c,m,y,k,E,P,O,B){if(!p)return;const W=function(J,ee,ne,ie,ue,we){if(J.kind==="camera")return J.maxSize;if(J.kind==="composite"){const Ee=ee.possiblyEvaluate(new Ii(J.maxZoom,{worldview:we}),ne).evaluate(ue,{},ne),Te=ee.possiblyEvaluate(new Ii(J.minZoom,{worldview:we}),ne).evaluate(ue,{},ne);return Math.max(Ee,Te)}return ee.possiblyEvaluate(new Ii(ie,{worldview:we})).evaluate(ue,{},ne)}(c,m,y,k,E,B);return p.scaleSelf(W*O*P)}function iA(p,c,m,y,k,E,P,O,B){return{iconPrimary:Wke(p.getPrimary(),c,m,y,k,E,P,O,B),iconSecondary:Wke(p.getSecondary(),c,m,y,k,E,P,O,B)}}function xst(p,c,m){if(!c)return;const y=m.get(p.toString()),k=m.get(c.toString());y&&k&&(y.paddedRect.w===k.paddedRect.w&&y.paddedRect.h===k.paddedRect.h||cr(`Mismatch in icon variant sizes: ${p.toString()} and ${c.toString()}`),y.usvg!==k.usvg&&cr(`Mismatch in icon variant image types: ${p.id} and ${c.id}`))}function Gke(p,c,m,y){if(!p)return;const k=c.get(m.toString());if(p.imagePrimary=k,y){const E=c.get(y.toString());p.imageSecondary=E}}function yst(p,c){for(const m in p.horizontal)Kke(p.horizontal[m],c);Kke(p.vertical,c)}function Kke(p,c){if(p){for(const m of p.positionedLines)for(const y of m.positionedGlyphs)if(y.image!==null){const k=y.image.toString();y.rect=c.get(k).paddedRect}}}function Yde(p){switch(p){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function vst(p,c,m,y,k,E,P,O,B){const W=yO(E.horizontal)||E.vertical,J=m.get("icon-text-fit-padding").evaluate(y,{},k);let ee,ne=c;return c&&B!=="none"&&(p.allowVerticalPlacement&&E.vertical&&(ee=Vde(c,E.vertical,B,J,O,P)),W&&(ne=Vde(c,W,B,J,O,P))),{defaultShapedIcon:ne,verticallyShapedIcon:ee}}function _st(p,c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue,Ye,st,_t,ft,St){let Pt=P.textMaxSize.evaluate(c,{},ne);Pt===void 0?Pt=O*P.textScaleFactor:Pt*=P.textScaleFactor;const Ft=p.layers[0].layout,ns=rc,Wt=O*P.textScaleFactor/ns,hs=yO(m.horizontal)||m.vertical;if(Ee!=="none"&&p.appearanceFeatureData&&c.index18&&Ls>2&&(Ls>>=1),Math.max(Gs/(512*Ls),1)*Ft.get("symbol-spacing")),Fs=Ft.get("text-padding")*p.tilePixelRatio,Es=Ft.get("icon-padding")*p.tilePixelRatio,Is=Jr(Ft.get("text-max-angle")),us=Ft.get("icon-rotation-alignment")==="map"&&Ye!=="point",as=Ds/2;var Ls;p.hasAnyIconTextFit===!1&&Ee!=="none"&&(p.hasAnyIconTextFit=!0);const Ks=c.properties?+c.properties[ls]:null,$s=Ks&&p.elevationFeatureIdToIndex?p.elevationFeatureIdToIndex.get(Ks):65535,Pr=(lr,pr,wr)=>{if(pr.x<0||pr.x>=Gs||pr.y<0||pr.y>=Gs)return;let Wn=null;if(ys){const{x:qs,y:jr,z:hn}=ie.projectTilePoint(pr.x,pr.y,wr);Wn={anchor:new Dy(qs,jr,hn,0,void 0),up:ie.upVector(wr,pr.x,pr.y)}}(function(qs,jr,hn,ua,fa,Mn,pi,gt,wt,ms,Os,nr,ar,Ir,zr,kn,Fn,Vn,na,en,cn,Ca,Ra,Fa,ai,wi,fi,Ha,Qa,zn,pa,Ji,Yr){const aa=qs.addToLineVertexArray(jr,ua);let yi,Ci,Li,Oo,Mi,Xr,co,ii=0,Hi=0,bl=0,nc=0,nl=-1,al=-1;const Fl={};let bu=sv("");const Ti=hn?hn.anchor:jr,To=Ha!=="none";let Ro=0,zu=0;if(wt._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Jc=wt.layout.get("text-offset").evaluate(cn,{},ai);Ro=Jc[0]*rc,zu=Jc[1]*rc}else Ro=wt.layout.get("text-radial-offset").evaluate(cn,{},ai)*rc,zu=Zde;if(qs.allowVerticalPlacement&&fa.vertical){const Jc=fa.vertical;if(zr)Xr=Xde(Jc),gt&&(co=Xde(gt));else{const Yd=wt.layout.get("text-rotate").evaluate(cn,{},ai)+90;Li=vO(ms,Ti,jr,Os,nr,ar,Jc,Ir,Yd,kn,Ji),gt&&(Oo=vO(ms,Ti,jr,Os,nr,ar,gt,Vn,Yd,null,pa))}}if(Mn){const Jc=qs.iconSizeData,Yd=wt.layout.get("icon-rotate").evaluate(cn,{},ai),gh=Kde(Mn,Yd,Ra,To,Ca.iconScaleFactor),Dv=gt?Kde(gt,Yd,Ra,To,Ca.iconScaleFactor):void 0;Ci=vO(ms,Ti,jr,Os,nr,ar,Mn,Vn,Yd,null,zn);const LC=function(Qf,kA,mSe,Prt,pSe,fSe,Irt,Lrt){const gSe=Qf.layers[0],xSe=gSe.appearances;let DC=kA.length;if(mSe&&(DC=Math.max(DC,mSe.length)),xSe.length===0)return DC;const[Drt,Ort]=Prt.get("icon-size-scale-range"),Rrt=Se(1,Drt,Ort);for(const ySe of xSe){const vSe=ySe.getUnevaluatedProperties();if(vSe._values["icon-image"].value!==void 0){const _Se=gSe.getAppearanceValueAndResolveTokens(ySe,"icon-image",pSe,fSe,[]);if(_Se){const bSe=Qf.getResolvedImageFromTokens(_Se);if(bSe){const wSe=vSe._values["icon-size"],Frt=iA(bSe,kC(Qf.zoom,wSe,Qf.worldview),wSe,fSe,Qf.zoom,pSe,Qf.pixelRatio,Rrt,Qf.worldview),zrt=Irt.get(Frt.iconPrimary.toString());DC=Math.max(DC,lst(zrt,Lrt))}}}}return DC}(qs,gh,Dv,wt.layout,cn,ai,qs.iconAtlasPositions,To);ii=4*LC;let Xf=null;Jc.kind==="source"?(Xf=[Gf*wt.layout.get("icon-size").evaluate(cn,{},ai)*Ca.iconScaleFactor],Xf[0]>Oy&&cr(`${qs.layerIds[0]}: Value for "icon-size" is >= ${oA}. Reduce your "icon-size".`)):Jc.kind==="composite"&&(Xf=[Gf*Ca.compositeIconSizes[0].evaluate(cn,{},ai)*Ca.iconScaleFactor,Gf*Ca.compositeIconSizes[1].evaluate(cn,{},ai)*Ca.iconScaleFactor],(Xf[0]>Oy||Xf[1]>Oy)&&cr(`${qs.layerIds[0]}: Value for "icon-size" is >= ${oA}. Reduce your "icon-size".`)),qs.addSymbols(qs.icon,gh,Xf,en,na,cn,void 0,hn,jr,aa.lineStartIndex,aa.lineLength,-1,Fa,ai,wi,fi,qs.symbolInstances.length,LC),nl=qs.icon.placedSymbolArray.length-1,Dv&&(Hi=4*LC,qs.addSymbols(qs.icon,Dv,Xf,en,na,cn,fh.vertical,hn,jr,aa.lineStartIndex,aa.lineLength,-1,Fa,ai,wi,fi,qs.symbolInstances.length,LC),al=qs.icon.placedSymbolArray.length-1)}for(const Jc in fa.horizontal){const Yd=Jc,gh=fa.horizontal[Yd];yi||(bu=sv(gh.text),zr?Mi=Xde(gh):yi=vO(ms,Ti,jr,Os,nr,ar,gh,Ir,wt.layout.get("text-rotate").evaluate(cn,{},ai),kn,Ji));const Dv=gh.positionedLines.length===1;if(bl+=Zke(qs,hn,jr,gh,pi,wt,zr,cn,kn,aa,fa.vertical?fh.horizontal:fh.horizontalOnly,Dv?hst(fa.horizontal):[Yd],Fl,nl,Ca,Fa,ai,qs.symbolInstances.length,wi),Dv)break}fa.vertical&&(nc+=Zke(qs,hn,jr,fa.vertical,pi,wt,zr,cn,kn,aa,fh.vertical,["vertical"],Fl,al,Ca,Fa,ai,qs.symbolInstances.length,wi));let wl=-1;const Fp=(Jc,Yd)=>Jc?Math.max(Jc,Yd):Yd;wl=Fp(Mi,wl),wl=Fp(Xr,wl),wl=Fp(co,wl);const fx=wl>-1?1:0;qs.glyphOffsetArray.length>=65535&&cr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),cn.sortKey!==void 0&&qs.addToSortKeyRanges(qs.symbolInstances.length,cn.sortKey),qs.symbolInstances.emplaceBack(jr.x,jr.y,Ti.x,Ti.y,Ti.z,Fl.right>=0?Fl.right:-1,Fl.center>=0?Fl.center:-1,Fl.left>=0?Fl.left:-1,Fl.vertical>=0?Fl.vertical:-1,nl,al,bu,yi!==void 0?yi:qs.collisionBoxArray.length,yi!==void 0?yi+1:qs.collisionBoxArray.length,Li!==void 0?Li:qs.collisionBoxArray.length,Li!==void 0?Li+1:qs.collisionBoxArray.length,Ci!==void 0?Ci:qs.collisionBoxArray.length,Ci!==void 0?Ci+1:qs.collisionBoxArray.length,Oo||qs.collisionBoxArray.length,Oo?Oo+1:qs.collisionBoxArray.length,Os,bl,nc,ii,Hi,fx,0,Ro,zu,wl,0,To?1:0,Qa)})(p,pr,Wn,lr,m,y,E,k,p.layers[0],p.collisionBoxArray,c.index,c.sourceLayerIndex,p.index,Fs,Ue,W,0,Es,us,Te,c,P,J,ee,ne,ue,we,Ee,$s,st,_t,ft)};if(Ye==="line")for(const lr of eO(c.geometry,0,0,Gs,Gs)){const pr=ost(lr,Ds,Is,m.vertical||hs,y,ns,vs,p.overscaling,Gs);for(const wr of pr)hs&&bst(p,hs.text,as,wr)||Pr(lr,wr,ne)}else if(Ye==="line-center"){for(const lr of c.geometry)if(lr.length>1){const pr=ist(lr,Is,m.vertical||hs,y,ns,vs);pr&&Pr(lr,pr,ne)}}else if(c.type==="Polygon")for(const lr of UT(c.geometry,0)){const pr=dst(lr,16);Pr(lr[0],new Dy(pr.x,pr.y,0,0,void 0),ne)}else if(c.type==="LineString")for(const lr of c.geometry)Pr(lr,new Dy(lr[0].x,lr[0].y,0,0,void 0),ne);else if(c.type==="Point")for(const lr of c.geometry)for(const pr of lr)Pr([pr],new Dy(pr.x,pr.y,0,0,void 0),ne)}const oA=255,Oy=oA*Gf;function Zke(p,c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue){const Ye=function(ft,St,Pt,Ft,ns,Wt,hs,ys){const vs=[];if(St.positionedLines.length===0)return vs;const Ds=Ft.layout.get("text-rotate").evaluate(Wt,{})*Math.PI/180,Fs=function(Ls){const Ks=Ls[0],$s=Ls[1],Pr=Ks*$s;return Pr>0?[Ks,-$s]:Pr<0?[-Ks,$s]:Ks===0?[$s,Ks]:[$s,-Ks]}(Pt);let Es=Math.abs(St.top-St.bottom);for(const Ls of St.positionedLines)Es-=Ls.lineOffset;const Is=St.positionedLines.length,us=Es/Is;let as=St.top-Pt[1];for(let Ls=0;LsOy&&cr(`${p.layerIds[0]}: Value for "text-size" is >= ${oA}. Reduce your "text-size".`)):st.kind==="composite"&&(_t=[Gf*ue.compositeTextSizes[0].evaluate(O,{},Ee)*ue.textScaleFactor,Gf*ue.compositeTextSizes[1].evaluate(O,{},Ee)*ue.textScaleFactor],(_t[0]>Oy||_t[1]>Oy)&&cr(`${p.layerIds[0]}: Value for "text-size" is >= ${oA}. Reduce your "text-size".`)),p.addSymbols(p.text,Ye,_t,B,P,O,J,c,m,W.lineStartIndex,W.lineLength,ie,we,Ee,Ue,!1,Te,Ye.length);for(const ft of ee)ne[ft]=p.text.placedSymbolArray.length-1;return 4*Ye.length}function yO(p){for(const c in p)return p[c];return null}function vO(p,c,m,y,k,E,P,O,B,W,J){let ee,ne,ie,ue;if(ee=J?J.top:P.top,ne=J?J.bottom:P.bottom,ie=J?J.left:P.left,ue=J?J.right:P.right,Ude(P)&&P.collisionPadding){const we=P.collisionPadding;ie-=we[0],ee-=we[1],ue+=we[2],ne+=we[3]}if(B){const we=new rs(ie,ee),Ee=new rs(ue,ee),Te=new rs(ie,ne),Ue=new rs(ue,ne),Ye=Jr(B);let st=new rs(0,0);W&&(st=new rs(W[0],W[1])),we._rotateAround(Ye,st),Ee._rotateAround(Ye,st),Te._rotateAround(Ye,st),Ue._rotateAround(Ye,st),ie=Math.min(we.x,Ee.x,Te.x,Ue.x),ue=Math.max(we.x,Ee.x,Te.x,Ue.x),ee=Math.min(we.y,Ee.y,Te.y,Ue.y),ne=Math.max(we.y,Ee.y,Te.y,Ue.y)}return p.emplaceBack(c.x,c.y,c.z,m.x,m.y,ie,ee,ue,ne,O,y,k,E),p.length-1}function Xde(p){Ude(p)&&p.collisionPadding&&(p.top-=p.collisionPadding[1],p.bottom+=p.collisionPadding[3]);const c=p.bottom-p.top;return c>0?Math.max(10,c):null}function bst(p,c,m,y){const k=p.compareText;if(c in k){const E=k[c];for(let P=E.length-1;P>=0;P--)if(y.dist(E[P])Ye&&(st(ft,vs,Pt,Ft,hs,ys),st(vs,St,hs,ys,ns,Wt))}st(ee,ne,y,E,k,E),st(ne,ie,k,E,k,P),st(ie,ue,k,P,y,P),st(ue,ee,y,P,y,E),we-=Ye,Ee-=Ye,Te+=Ye,Ue+=Ye;const _t=1/Math.max(Te-we,Ue-Ee);return{scale:_t,x:we*_t,y:Ee*_t,x2:Te*_t,y2:Ue*_t,projection:c}}function Xke(p,{x:c,y:m},y=0){return new rs(((c-y)*p.scale-p.x)*Gs,(m*p.scale-p.y)*Gs)}const wst=j(new Float32Array(16));class Iv{constructor(c){this.spec=c,this.name=c.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(c,m){return{x:0,y:0,z:0}}unproject(c,m){return new x(0,0)}projectTilePoint(c,m,y){return{x:c,y:m,z:0}}locationPoint(c,m,y,k=!0){return c._coordinatePoint(c.locationCoordinate(m,y),k)}pixelsPerMeter(c,m){return re(1,c)*m}pixelSpaceConversion(c,m,y){return 1}farthestPixelDistance(c){return Yke(c,c.pixelsPerMeter)}pointCoordinate(c,m,y,k){const E=c.horizonLineFromTop(!1),P=new rs(m,Math.max(E,y));return c.rayIntersectionCoordinate(c.pointRayIntersection(P,k))}pointCoordinate3D(c,m,y){const k=new rs(m,y);if(c.elevation)return c.elevation.pointCoordinate(k);{const E=this.pointCoordinate(c,k.x,k.y,0);return[E.x,E.y,E.z]}}isPointAboveHorizon(c,m){if(c.elevation&&c.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(c,m.x,m.y);const y=c.horizonLineFromTop();return m.y0?m<-MC+y&&(m=-MC+y):m>MC-y&&(m=MC-y);const P=E/Math.pow(bO(m),k);let O=P*Math.sin(k*c),B=E-P*Math.cos(k*c);return O=.5*(O/Math.PI+.5),B=.5*(B/Math.PI+.5),{x:O,y:this.southernCenter?B:1-B,z:0}}unproject(c,m){c=(2*c-.5)*Math.PI,this.southernCenter&&(m=1-m),m=(2*(1-m)-.5)*Math.PI;const{n:y,f:k}=this,E=k-m,P=Math.sign(E),O=Math.sign(y)*Math.sqrt(c*c+E*E);let B=Math.atan2(c,Math.abs(E))*P;E*y<0&&(B-=Math.PI*Math.sign(c)*P);const W=Se(Ka(B/y)+this.center[0],-180,180),J=Se(Ka(2*Math.atan(Math.pow(k/O,1/y))-MC),-pe,pe);return new x(W,this.southernCenter?-J:J)}}class Qke extends Iv{constructor(c){super(c),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(c,m){return{x:V(c),y:X(m),z:0}}unproject(c,m){const y=ae(c),k=me(m);return new x(y,k)}}const Jke=Jr(pe);class Cst extends Iv{project(c,m){const y=(m=Jr(m))*m,k=y*y;return{x:.5*((c=Jr(c))*(.8707-.131979*y+k*(k*(.003971*y-.001529*k)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+y*(.015085+k*(.028874*y-.044475-.005916*k)))/Math.PI+1),z:0}}unproject(c,m){c=(2*c-.5)*Math.PI;let y=m=(2*(1-m)-1)*Math.PI,k=25,E=0,P=y*y;do{P=y*y;const W=P*P;E=(y*(1.007226+P*(.015085+W*(.028874*P-.044475-.005916*W)))-m)/(1.007226+P*(.045255+W*(.259866*P-.311325-.005916*11*W))),y=Se(y-E,-Jke,Jke)}while(Math.abs(E)>1e-6&&--k>0);P=y*y;const O=Se(Ka(c/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),B=Ka(y);return new x(O,B)}}const eNe=Jr(pe);class Mst extends Iv{project(c,m){m=Jr(m),c=Jr(c);const y=Math.cos(m),k=2/Math.PI,E=Math.acos(y*Math.cos(c/2)),P=Math.sin(E)/E,O=.5*(c*k+2*y*Math.sin(c/2)/P)||0,B=.5*(m+Math.sin(m)/P)||0;return{x:.5*(O/Math.PI+.5),y:1-.5*(B/Math.PI+1),z:0}}unproject(c,m){let y=c=(2*c-.5)*Math.PI,k=m=(2*(1-m)-1)*Math.PI,E=25;const P=1e-6;let O=0,B=0;do{const W=Math.cos(k),J=Math.sin(k),ee=2*J*W,ne=J*J,ie=W*W,ue=Math.cos(y/2),we=Math.sin(y/2),Ee=2*ue*we,Te=we*we,Ue=1-ie*ue*ue,Ye=Ue?1/Ue:0,st=Ue?Math.acos(W*ue)*Math.sqrt(1/Ue):0,_t=.5*(2*st*W*we+2*y/Math.PI)-c,ft=.5*(st*J+k)-m,St=.5*Ye*(ie*Te+st*W*ue*ne)+1/Math.PI,Pt=Ye*(Ee*ee/4-st*J*we),Ft=.125*Ye*(ee*we-st*J*ie*Ee),ns=.5*Ye*(ne*ue+st*Te*W)+.5,Wt=Pt*Ft-ns*St;O=(ft*Pt-_t*ns)/Wt,B=(_t*Ft-ft*St)/Wt,y=Se(y-O,-Math.PI,Math.PI),k=Se(k-B,-eNe,eNe)}while((Math.abs(O)>P||Math.abs(B)>P)&&--E>0);return new x(Ka(y),Ka(k))}}class tNe extends Iv{constructor(c){super(c),this.center=c.center||[0,0],this.parallels=c.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(c,m){const{scale:y,cosPhi:k}=this;return{x:Jr(c)*k*y+.5,y:-Math.sin(Jr(m))/k*y+.5,z:0}}unproject(c,m){const{scale:y,cosPhi:k}=this,E=-(m-.5)/y,P=Se(Ka((c-.5)/y)/k,-180,180),O=Math.asin(Se(E*k,-1,1)),B=Se(Ka(O),-pe,pe);return new x(P,B)}}class Tst extends Qke{constructor(c){super(c),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(c,m,y){const k=RT(c,m,y);return Rt(k,k,HD(Hm(y))),{x:k[0],y:k[1],z:k[2]}}locationPoint(c,m,y){const k=Sv(m.lat,m.lng),E=Ie([],k),P=y?c._centerAltitude+y:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(m),c._centerAltitude):c._centerAltitude;Ge(k,k,E,re(1,0)*Gs*P);const O=j(new Float64Array(16));return S(O,c.pixelMatrix,c.globeMatrix),Rt(k,k,O),new rs(k[0],k[1])}pixelsPerMeter(c,m){return re(1,0)*m}pixelSpaceConversion(c,m,y){const k=re(1,c)*m,E=Ur(re(1,45)*m,k,y);return this.pixelsPerMeter(c,m)/E}createTileMatrix(c,m,y){const k=sde(Hm(y.canonical));return S(new Float64Array(16),c.globeMatrix,k)}createInversionMatrix(c,m){const{center:y}=c,k=HD(Hm(m));return F(k,k,Jr(y.lng)),L(k,k,Jr(y.lat)),I(k,k,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(k)}pointCoordinate(c,m,y,k){return Mv(c,m,y,!0)||new Xe(0,0)}pointCoordinate3D(c,m,y){const k=this.pointCoordinate(c,m,y,0);return[k.x,k.y,k.z]}isPointAboveHorizon(c,m){return!Mv(c,m.x,m.y,!1)}farthestPixelDistance(c){const m=function(k,E){const P=k.cameraToCenterDistance,O=k._centerAltitude*E,B=k._camera,W=k._camera.forward(),J=de([],ke([],W,-P),[0,0,O]),ee=k.worldSize/(2*Math.PI),ne=[0,0,-ee],ie=k.width/k.height,ue=Math.tan(k.fovAboveCenter),we=ke([],B.up(),ue),Ee=ke([],B.right(),ue*ie),Te=Ie([],de([],de([],W,we),Ee)),Ue=[];let Ye;if(new br(J,Te).closestPointOnSphere(ne,ee,Ue)){const st=de([],Ue,ne),_t=je([],st,J);Ye=Math.cos(k.fovAboveCenter)*ce(_t)}else{const st=je([],J,ne),_t=je([],ne,J);Ie(_t,_t);const ft=ce(st)-ee;Ye=Math.sqrt(ft*(ft+2*ee));const St=Math.acos(Ye/(ee+ft))-Math.acos(Ve(W,_t));Ye*=Math.cos(St)}return 1.01*Ye}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),y=Tv(c.zoom);if(y>0){const k=Yke(c,re(1,c.center.lat)*c.worldSize),E=c.worldSize/(2*Math.PI),P=Math.max(c.width,c.height)/c.worldSize*Math.PI;return Ur(m,k+E*(1-Math.cos(P)),Math.pow(y,10))}return m}upVector(c,m,y){return RT(m,y,c,1)}upVectorScale(c){return{metersToTile:Op(VD(Hm(c)))}}}function sNe(p){const c=p.parallels,m=!!c&&Math.abs(c[0]+c[1])<.01;switch(p.name){case"mercator":return new Qke(p);case"equirectangular":return new Nst(p);case"naturalEarth":return new Cst(p);case"equalEarth":return new kst(p);case"winkelTripel":return new Mst(p);case"albers":return m?new tNe(p):new jst(p);case"lambertConformalConic":return m?new tNe(p):new Sst(p);case"globe":return new Tst(p)}throw new Error(`Invalid projection name: ${p.name}`)}const Ast=Ut.types,Est=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function mA(p,c,m,y,k,E,P,O,B,W,J,ee,ne){const ie=O?Math.min(Oy,Math.round(O[0])):0,ue=O?Math.min(Oy,Math.round(O[1])):0;p.emplaceBack(c,m,Math.round(32*y),Math.round(32*k),E,P,(ie<<1)+(B?1:0),0+(ue<<1),16*W,16*J,256*ee,256*ne)}function pA(p,c,m){p.emplaceBack(c,m)}function fA(p,c,m,y,k,E,P){p.emplaceBack(c,m,y,k,E,P)}const wO=(p,c,m,y)=>{for(let k=0;k0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,ztt.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,Dtt.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Rtt.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,Ftt.members,!0)),this.opacityVertexBuffer.itemSize=1),(y||k)&&this.programConfigurations.upload(c))}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())}}vr(Qde,"SymbolBuffers");class Jde{constructor(c,m,y){this.layoutVertexArray=new c,this.layoutAttributes=m,this.indexArray=new y,this.segments=new io,this.collisionVertexArray=new wT,this.collisionVertexArrayExt=new cx}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,Btt.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,$tt.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}vr(Jde,"CollisionBuffers");class jO{constructor(c){this.collisionBoxArray=c.collisionBoxArray,this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(P=>P.fqid),this.index=c.index,this.pixelRatio=c.pixelRatio,this.sourceLayerIndex=c.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=j([]),this.placementViewportMatrix=j([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=c.worldview,this.localizable=c.localizable,this.textSizeData=kC(this.zoom,m["text-size"],this.worldview),this.iconSizeData=kC(this.zoom,m["icon-size"],this.worldview);const y=this.layers[0].layout,k=y.get("symbol-sort-key"),E=y.get("symbol-z-order");this.lut=c.lut,this.canOverlap=y.get("text-allow-overlap")||y.get("icon-allow-overlap")||y.get("text-ignore-placement")||y.get("icon-ignore-placement"),this.sortFeaturesByKey=E!=="viewport-y"&&k.constantOr(1)!==void 0,this.sortFeaturesByY=(E==="viewport-y"||E==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=y.get("text-writing-mode").map(P=>fh[P]),this.stateDependentLayerIds=this.layers.filter(P=>P.isStateDependent()).map(P=>P.id),this.sourceID=c.sourceID,this.projection=c.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(c){const m=this.layers[0].getAppearances();return!(!m||m.length===0)&&m.some(y=>y.getProperty(c)!=null)}createArrays(){this.text=new Qde(new Um(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new Qde(new Um(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.glyphOffsetArray=new iC,this.lineVertexArray=new zD,this.symbolInstances=new TT}calculateGlyphDependencies(c,m,y,k,E){for(const P of c){const O=P.codePointAt(0);if(O===void 0)break;if(m[O]=!0,k&&E&&O<=65535){const B=sA[P];B&&(m[B.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(c,m,y,k,E,P){let O=1;const B=c.getUnevaluatedProperties()._values["icon-size"],W=kC(this.zoom,B,this.worldview),J=NC(W,m);if(W.kind!=="constant"&&W.kind!=="camera"||(O=J.uSize),W.kind==="composite"){const{minZoom:ee,maxZoom:ne}=W,ie=B.possiblyEvaluate(new Ii(ee,{worldview:this.worldview}),k),ue=B.possiblyEvaluate(new Ii(ne,{worldview:this.worldview}),k),we=ie.evaluate(y,{},k,E);O=we+(ue.evaluate(y,{},k,E)-we)*J.uSizeT}return W.kind==="source"&&(O=B.possiblyEvaluate(new Ii(this.zoom,{worldview:this.worldview}),k).evaluate(y,{},k,E)),O*P}updateFootprints(c,m){}updateReplacement(c,m){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const y=m.getReplacementRegionsForTile(c.toUnwrapped(),!0);return!XD(this.activeReplacements,y)&&(this.activeReplacements=y,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Hd.build(c):c}populate(c,m,y,k){const E=this.layers[0],P=E.layout,O=this.projection.name==="globe",B=P.get("text-font"),W=P.get("text-field"),J=P.get("icon-image"),[ee,ne]=P.get("icon-size-scale-range"),ie=Se(m.scaleFactor||1,ee,ne),ue=(W.value.kind!=="constant"||W.value.value instanceof Vd&&!W.value.value.isEmpty()||W.value.value.toString().length>0)&&(B.value.kind!=="constant"||B.value.value.length>0),we=J.value.kind!=="constant"||!!J.value.value||Object.keys(J.parameters).length>0,Ee=this.hasAnyAppearanceProperty("icon-image"),Te=P.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!ue&&!we&&!Ee)return;const Ue=m.iconDependencies,Ye=m.glyphDependencies,st=m.availableImages,_t=new Ii(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ft=St=>{const Pt=St.id.toString();Ue.has(Pt)?Ue.get(Pt).push(St):Ue.set(Pt,[St])};for(const St of c){const{feature:Pt,id:Ft,index:ns,sourceLayerIndex:Wt}=St,hs=E._featureFilter.needGeometry,ys=Ht(Pt,hs);if(!E._featureFilter.filter(_t,ys,y))continue;if(hs||(ys.geometry=Et(Pt,y,k)),O&&Pt.type!==1&&y.z<=5){const Ls=ys.geometry,Ks=.98078528056,$s=(Pr,lr)=>Ve(RT(Pr.x,Pr.y,y,1),RT(lr.x,lr.y,y,1)){if(!Ls.getProperty("icon-image"))return;const Ks=this.getCombinedIconPrimary(Ls,Fs,ys,y,st,us,ie);Ks&&ft(Ks)}),vs){const Ls=B.evaluate(ys,{},y).join(","),Ks=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(fh.vertical)>=0;for(const $s of vs.sections)if($s.image){const Pr=$s.image.getPrimary().scaleSelf(this.pixelRatio),lr=Pr.id.toString(),pr=Ue.get(lr)||[];pr.push(Pr),Ue.set(lr,pr)}else{const Pr=pb(vs.toString()),lr=$s.fontStack||Ls,pr=Ye[lr]=Ye[lr]||{};this.calculateGlyphDependencies($s.text,pr,Ks,this.allowVerticalPlacement,Pr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(St){const Pt={},Ft={},ns=[];let Wt=0;function hs(Fs){ns.push(St[Fs]),Wt++}function ys(Fs,Es,Is){const us=Ft[Fs];return delete Ft[Fs],Ft[Es]=us,ns[us].geometry[0].pop(),ns[us].geometry[0]=ns[us].geometry[0].concat(Is[0]),us}function vs(Fs,Es,Is){const us=Pt[Es];return delete Pt[Es],Pt[Fs]=us,ns[us].geometry[0].shift(),ns[us].geometry[0]=Is[0].concat(ns[us].geometry[0]),us}function Ds(Fs,Es,Is){const us=Is?Es[0][Es[0].length-1]:Es[0][0];return`${Fs}:${us.x}:${us.y}`}for(let Fs=0;FsFs.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 St of m.elevationFeatures)this.elevationFeatureIdToIndex.set(St.id,this.elevationFeatures.length),this.elevationFeatures.push(St)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((St,Pt)=>St.sortKey-Pt.sortKey)}getCombinedIconPrimary(c,m,y,k,E,P,O){let B,W;const J=c.getUnevaluatedProperties();if(J._values["icon-image"].value!==void 0){const ee=m.getAppearanceValueAndResolveTokens(c,"icon-image",y,k,E);B=this.getResolvedImageFromTokens(ee)}else{const ee=m.getValueAndResolveTokens("icon-image",y,k,E);B=this.getResolvedImageFromTokens(ee)}if(B){const ee=J._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];W=iA(B,kC(this.zoom,ee,this.worldview),ee,k,this.zoom,P,this.pixelRatio,O,this.worldview).iconPrimary}return W}updateAppearanceBasedIconTextures(c,m,y,k){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const E=this.layers[0];let P=!1,O=0;const B=E.layout,[W,J]=B.get("icon-size-scale-range"),ee=Se(1,W,J);for(let ne=0;ne=0){const Ee=we.id,Te=m&&Ee!==void 0?m[String(Ee)]:void 0,Ue={type:"Point",id:we.id,properties:we.properties,geometry:[]},Ye=this.layers[0].appearances&&this.layers[0].appearances.find(st=>st.isActive({globals:k,feature:Ue,canonical:c,featureState:Te}));if(we.activeAppearance===Ye){O+=ie.numIconVertices;continue}if(Ye){we.activeAppearance=Ye;const st=this.getCombinedIconPrimary(Ye,E,Ue,c,y,{sortKey:void 0,text:void 0,icon:null,index:ie.featureIndex,sourceLayerIndex:ie.featureIndex,geometry:[],properties:we.properties,type:"Point",id:we.id},ee);if(!st)continue;const _t=st.toString(),ft=this.iconAtlasPositions&&this.iconAtlasPositions.get(_t);if(ft){const St=E.getAppearanceValueAndResolveTokens(Ye,"icon-offset",Ue,c,y),Pt=St&&Array.isArray(St)?St:[0,0];let Ft=mO(ft,void 0,Pt,E.layout.get("icon-anchor").evaluate(Ue,{},c));const ns=E.getAppearanceValueAndResolveTokens(Ye,"icon-rotate",Ue,c,y),Wt=typeof ns=="number"?ns:0,hs=ft.sdf,ys=E.layout.get("icon-text-fit").constantOr("none");ys!=="none"&&we.textShaping&&we.iconTextFitPadding&&we.fontScale&&(Ft=Vde(Ft,we.textShaping,ys,we.iconTextFitPadding,Pt,we.fontScale));const vs=this.calculateEffectiveAppearanceIconSize(Ye,k.zoom,Ue,c,y,ee),Ds=0,Fs=1+(Math.min(Oy,Math.round(vs*Gf))<<1),Es=Kde(Ft,Wt,hs,ys!=="none",ee);we.isUsingAppearanceVertexData||(we.isUsingAppearanceVertexData=!0,we.layoutBasedVertexData=this.icon.getIconVertexData(O,ie.numIconVertices));for(let us=0;us0&&(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+=ie.numIconVertices,we.activeAppearance=null;else if(we.isUsingAppearanceVertexData){const _t=we.layoutBasedVertexData.length/12;for(let ft=0;ft<_t;++ft){const St=ft*12;this.icon.updateIconVertexData(O+ft,we.layoutBasedVertexData[St+0],we.layoutBasedVertexData[St+1],we.layoutBasedVertexData[St+2],we.layoutBasedVertexData[St+3],we.layoutBasedVertexData[St+4],we.layoutBasedVertexData[St+5],we.layoutBasedVertexData[St+6],we.layoutBasedVertexData[St+7],we.layoutBasedVertexData[St+8],we.layoutBasedVertexData[St+9],we.layoutBasedVertexData[St+10],we.layoutBasedVertexData[St+11])}O+=_t,we.isUsingAppearanceVertexData=!1,we.activeAppearance=null,P=!0}else O+=ie.numIconVertices,we.activeAppearance=null}}return P}update(c,m,y,k,E,P,O){this.text.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,this.worldview),this.icon.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,this.worldview)}updateRoadElevation(c){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let m=!1;const y=Be(c),k=1/y;let E=!1,P=!1;for(let O=0;O0||ne>0,Ee=ie>0,Te=this.elevationFeatures[B.elevationFeatureIndex];if(Te){const Ue=new rs(B.tileAnchorX,B.tileAnchorY),Ye=.075+Te.pointElevation(Ue);B.zOffset!==Ye&&(m=!0,B.zOffset=Ye),Ye!==0&&(this.hasAnyZOffset=!0);const st=Te.computeSlopeNormal(Ue,k),_t=fs(Ke(),oe(0,0,1),st);Qe(W,W,_t),Qe(J,J,_t),W[2]*=y,J[2]*=y,W[0]===1&&W[1]===0&&W[2]===0&&J[0]===0&&J[1]===1&&J[2]===0||(E=E||we,P=P||Ee)}if(we&&(wO(this.text.orientationVertexArray,ee,W,J),wO(this.text.orientationVertexArray,ne,W,J)),Ee){const{placedIconSymbolIndex:Ue,verticalPlacedIconSymbolIndex:Ye}=B;Ue>=0&&wO(this.icon.orientationVertexArray,ie,W,J),Ye>=0&&wO(this.icon.orientationVertexArray,ue,W,J)}}E||(this.text.orientationVertexArray=void 0),P||(this.icon.orientationVertexArray=void 0),m&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const c=(E,P,O)=>{y+=P,y>E.length&&E.resize(y);for(let B=-P;B<0;B++)E.emplace(B+y,O)},m=(E,P,O)=>{k+=P,k>E.length&&E.resize(k);for(let B=-P;B<0;B++)E.emplace(B+k,O)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let y=0,k=0;for(let E=0;E0;if((O>0||B>0)&&(c(this.text.zOffsetVertexArray,O,J),c(this.text.zOffsetVertexArray,B,J)),ee){const{placedIconSymbolIndex:ne,verticalPlacedIconSymbolIndex:ie}=P;ne>=0&&m(this.icon.zOffsetVertexArray,W,J),ie>=0&&m(this.icon.zOffsetVertexArray,P.numVerticalIconVertices,J)}}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(c,m,y,k,E){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(c),this.iconCollisionBox.upload(c)),this.text.upload(c,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(c,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(c,m,y,k){return!!(c&&m&&y)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(c,m,y,k)&&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=sNe(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(c,m){const y=this.lineVertexArray.length;if(c.segment!==void 0)for(const{x:k,y:E}of m)this.lineVertexArray.emplaceBack(k,E);return{lineStartIndex:y,lineLength:this.lineVertexArray.length-y}}addSymbols(c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we,Ee,Te,Ue){const Ye=c.indexArray,st=c.layoutVertexArray,_t=c.globeExtVertexArray,ft=c.segments.prepareSegment(4*Ue,st,Ye,this.canOverlap?P.sortKey:void 0),St=this.glyphOffsetArray.length,Pt=ft.vertexLength,Ft=this.allowVerticalPlacement&&O===fh.vertical?Math.PI/2:0,ns=P.text&&P.text.sections;for(let ys=0;ys=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:k),P=Hde(this.textSizeData,c,E)/rc;return this.tilePixelRatio*P}getSymbolInstanceIconSize(c,m,y){const k=this.icon.placedSymbolArray.get(y),E=Hde(this.iconSizeData,c,k);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(c,m,y,k){c.emplaceBack(m,-y,-y,k),c.emplaceBack(m,y,-y,k),c.emplaceBack(m,y,y,k),c.emplaceBack(m,-y,y,k)}_updateTextDebugCollisionBoxes(c,m,y,k,E,P,O){for(let B=k;B0}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(c,m){const y=c.placedSymbolArray.get(m),k=y.vertexStartIndex+4*y.numGlyphs;for(let E=y.vertexStartIndex;Ek[O]-k[B]||E[B]-E[O]),P}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let c=0;cthis.symbolInstances.get(m).zOffset-this.symbolInstances.get(c).zOffset)}addToSortKeyRanges(c,m){const y=this.sortKeyRanges[this.sortKeyRanges.length-1];y&&y.sortKey===m?y.symbolInstanceEnd=c+1:this.sortKeyRanges.push({sortKey:m,symbolInstanceStart:c,symbolInstanceEnd:c+1})}sortFeatures(c){if(this.sortFeaturesByY&&this.sortedAngle!==c&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(c),this.sortedAngle=c,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const m of this.symbolInstanceIndexes){const y=this.symbolInstances.get(m);this.featureSortOrder.push(y.featureIndex);const{rightJustifiedTextSymbolIndex:k,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:O,placedIconSymbolIndex:B,verticalPlacedIconSymbolIndex:W}=y;k>=0&&this.addIndicesForPlacedSymbol(this.text,k),E>=0&&E!==k&&this.addIndicesForPlacedSymbol(this.text,E),P>=0&&P!==E&&P!==k&&this.addIndicesForPlacedSymbol(this.text,P),O>=0&&this.addIndicesForPlacedSymbol(this.text,O),B>=0&&this.addIndicesForPlacedSymbol(this.icon,B),W>=0&&this.addIndicesForPlacedSymbol(this.icon,W)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(c){const m=this.symbolInstances.get(this.text.symbolInstanceIndices[c]).elevationFeatureIndex;let y;return this.elevationFeatures&&my in p?String(p[y]):"")}let nNe,aNe,eue;vr(jO,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),jO.addDynamicAttributes=TC;class iNe{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:Fm,this.defaultValue=c}evaluate(c){if(c.formattedSection){const m=this.defaultValue.property.overrides;if(m&&m.hasOverride(c.formattedSection))return m.getOverride(c.formattedSection)}return c.feature&&c.featureState?this.defaultValue.evaluate(c.feature,c.featureState):this.defaultValue.property.specification.default}eachChild(c){this.defaultValue.isConstant()||c(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}vr(iNe,"FormatSectionOverride",{omit:["defaultValue"]});const tue=()=>eue||(eue={layout:nNe||(nNe=new _o({"symbol-placement":new Us(Gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Us(Gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Us(Gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new sr(Gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Us(Gt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Us(Gt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Us(Gt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Us(Gt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Us(Gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Us(Gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Us(Gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new sr(Gt.layout_symbol["icon-size"]),"icon-size-scale-range":new Us(Gt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new sr(Gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new sr(Gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new sr(Gt.layout_symbol["icon-image"]),"icon-image-use-theme":new Us({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new sr(Gt.layout_symbol["icon-rotate"]),"icon-padding":new Us(Gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Us(Gt.layout_symbol["icon-keep-upright"]),"icon-offset":new sr(Gt.layout_symbol["icon-offset"]),"icon-anchor":new sr(Gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Us(Gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Us(Gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Us(Gt.layout_symbol["text-rotation-alignment"]),"text-field":new sr(Gt.layout_symbol["text-field"]),"text-font":new sr(Gt.layout_symbol["text-font"]),"text-size":new sr(Gt.layout_symbol["text-size"]),"text-size-scale-range":new Us(Gt.layout_symbol["text-size-scale-range"]),"text-max-width":new sr(Gt.layout_symbol["text-max-width"]),"text-line-height":new sr(Gt.layout_symbol["text-line-height"]),"text-letter-spacing":new sr(Gt.layout_symbol["text-letter-spacing"]),"text-justify":new sr(Gt.layout_symbol["text-justify"]),"text-radial-offset":new sr(Gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Us(Gt.layout_symbol["text-variable-anchor"]),"text-anchor":new sr(Gt.layout_symbol["text-anchor"]),"text-max-angle":new Us(Gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Us(Gt.layout_symbol["text-writing-mode"]),"text-rotate":new sr(Gt.layout_symbol["text-rotate"]),"text-padding":new Us(Gt.layout_symbol["text-padding"]),"text-keep-upright":new Us(Gt.layout_symbol["text-keep-upright"]),"text-transform":new sr(Gt.layout_symbol["text-transform"]),"text-offset":new sr(Gt.layout_symbol["text-offset"]),"text-allow-overlap":new Us(Gt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Us(Gt.layout_symbol["text-ignore-placement"]),"text-optional":new Us(Gt.layout_symbol["text-optional"]),visibility:new Us(Gt.layout_symbol.visibility)})),paint:aNe||(aNe=new _o({"icon-opacity":new sr(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new sr(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new sr(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new sr(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new sr(Gt.paint_symbol["icon-color"]),"icon-halo-color":new sr(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new sr(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new sr(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Us(Gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Us(Gt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Us(Gt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new sr(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new sr(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new sr(Gt.paint_symbol["text-color"],{runtimeType:xu,getOverride:p=>p.textColor,hasOverride:p=>!!p.textColor}),"text-halo-color":new sr(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new sr(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new sr(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Us(Gt.paint_symbol["text-translate"]),"text-translate-anchor":new Us(Gt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Us(Gt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Us(Gt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Us(Gt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Us(Gt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new sr(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"})}))},eue);class kO extends Kd{constructor(c,m,y,k){super(c,tue(),m,y,k,c.layout?c.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=j([]),this.hasOcclusionOpacityProperties=c.paint!==void 0&&("icon-occlusion-opacity"in c.paint||"text-occlusion-opacity"in c.paint)}_handleSpecialPaintPropertyUpdate(c){c!=="icon-occlusion-opacity"&&c!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(c,m){super.recalculate(c,m),this.appearances&&this.appearances.forEach(k=>{k.recalculate(c,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 y=this.layout.get("text-writing-mode");if(y){const k=[];for(const E of y)k.indexOf(E)<0&&k.push(E);this.layout._values["text-writing-mode"]=k}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(c,m,y,k){return this._saturation===c&&this._contrast===m&&this._brightnessMin===y&&this._brightnessMax===k||(this._colorAdjustmentMatrix=function(E,P,O,B){E=Zi(E),P=xa(P);const W=b(),J=E/3,ee=1-2*J,ne=[ee,J,J,0,J,ee,J,0,J,J,ee,0,0,0,0,1],ie=.5-.5*P,ue=B-O;return S(W,[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,ie,ie,ie,1]),S(W,W,ne),W}(c,m,y,k),this._saturation=c,this._contrast=m,this._brightnessMin=y,this._brightnessMax=k),this._colorAdjustmentMatrix}getValueAndResolveTokens(c,m,y,k){const E=this.layout.get(c).evaluate(m,{},y,k),P=this._unevaluatedLayout._values[c];return P.isDataDriven()||hb(P.value)||!E?E:rNe(m.properties,E)}getAppearanceValueAndResolveTokens(c,m,y,k,E){const P=c.getProperty(m);if(!P)return;const O=P.evaluate(y,{},k,E),B=c.getUnevaluatedProperties()._values[m];return B.isDataDriven()||hb(B.value)||!O||typeof O!="string"?O:rNe(y.properties,O)}createBucket(c){return new jO(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of tue().paint.overridableProperties){if(!kO.hasPaintOverride(this.layout,c))continue;const m=this.paint.get(c),y=new iNe(m),k=new OS(y,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 xv("source",k):new jy("composite",k,m.value.zoomStops,m.value.interpolationType),this.paint._values[c]=new Ny(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(c,m,y){return!(!this.layout||m.isDataDriven()||y.isDataDriven())&&kO.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,m){const y=c.get("text-field"),k=tue().paint.properties[m];let E=!1;const P=O=>{for(const B of O)if(k.overrides&&k.overrides.hasOverride(B))return void(E=!0)};if(y.value.kind==="constant"&&y.value.value instanceof Vd)P(y.value.value.sections);else if(y.value.kind==="source"){const O=W=>{E||(W instanceof Ef&&sc(W.value)===X_?P(W.value.sections):W instanceof Mp?P(W.sections):W.eachChild(O))},B=y.value;B._styleExpression&&O(B._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(c,m,y){return{config:new ux(this,{zoom:m,lut:y}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let oNe,lNe,cNe,dNe;var sue=ra([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function NO(p,c,m,y,k,E,P,O){const B=[p,c,1,m,y,1,k,E,1],W=[P,O,1],J=v([],B),[ee,ne,ie]=fe(W,W,J);return _(B,B,[ee,0,0,0,ne,0,0,0,ie])}function uNe(p,c,m,y,k,E,P,O){const B=function(W,J,ee,ne,ie,ue,we,Ee){const Te=NO(0,0,1,0,1,1,0,1),Ue=NO(W,J,ee,ne,ie,ue,we,Ee);return _(Ue,Ue,v([],Te))}(p,c,m,y,k,E,P,O);return[B[2]/B[8]/Gs,B[5]/B[8]/Gs]}function SO(p){return[p[0],Math.min(Math.max(p[1],-pe),pe)]}class hNe extends Ns{constructor(c,m,y,k){super(),this.id=c,this.dispatcher=y,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(k),this.options=m,this._dirty=!1}load(c,m){if(this._loaded=m||!1,this.fire(new Qh("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=Zg(this.map._requestManager.transformRequest(this.url,Cf.Image),(y,k)=>{this._imageRequest=null,this._loaded=!0,y?this.fire(new Yg(y)):k&&(this.image=k instanceof HTMLImageElement?xl.getImageData(k):k,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,c&&(this.coordinates=c),this._finishLoading())})}loaded(){return this._loaded}updateImage(c){return c.url?(this._imageRequest&&c.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=c.url,this.load(c.coordinates,this._loaded),this):this}setTexture(c){if(!(c.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new JT(this.map.painter.context,c.handle),this.width=c.dimensions[0],this.height=c.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Qh("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(c){this.map=c,this.load()}onRemove(c){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof JT||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(c){if(this.coordinates=c,this._boundsArray=void 0,this._unsupportedCoords=!1,!c.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let m=c[0][1],y=c[0][1];for(const E of c)E[1]>y&&(y=E[1]),E[1]pe?this.onNorthPole=!0:k<-pe&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=c.map(Xe.fromLngLat);this.tileID=function(P){let O=1/0,B=1/0,W=-1/0,J=-1/0;for(const we of P)O=Math.min(O,we.x),B=Math.min(B,we.y),W=Math.max(W,we.x),J=Math.max(J,we.y);const ee=Math.max(W-O,J-B),ne=Math.max(0,Math.floor(-Math.log2(ee))),ie=Math.pow(2,ne);let ue=Math.floor((O+W)/2*ie);return ue>1&&(ue-=1),new bi(ne,ue,Math.floor((B+J)/2*ie))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Qh("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof JT||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(c){for(const Te in this.tiles){const Ue=this.tiles[Te];Ue.state!=="loaded"&&(Ue.state="loaded",Ue.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=lA(new bi(0,0,0),this.map.transform.projection),y=[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(Te){const Ue=Te[1].x-Te[0].x,Ye=Te[1].y-Te[0].y,st=Te[2].x-Te[1].x,_t=Te[2].y-Te[1].y,ft=Te[3].x-Te[2].x,St=Te[3].y-Te[2].y,Pt=Te[0].x-Te[3].x,Ft=Te[0].y-Te[3].y,ns=Ue*_t-st*Ye,Wt=st*St-ft*_t,hs=ft*Ft-Pt*St,ys=Pt*Ye-Ue*Ft;return ns>0&&Wt>0&&hs>0&&ys>0||ns<0&&Wt<0&&hs<0&&ys<0}(y))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const k=lA(this.tileID,this.map.transform.projection),[E,P,O,B]=this.coordinates.map(Te=>{const Ue=k.projection.project(Te[0],Te[1]);return Xke(k,Ue)._round()});this.perspectiveTransform=uNe(E.x,E.y,P.x,P.y,O.x,O.y,B.x,B.y);const W=this._boundsArray=new bv;W.emplaceBack(E.x,E.y,0,0),W.emplaceBack(P.x,P.y,Gs,0),W.emplaceBack(B.x,B.y,0,Gs),W.emplaceBack(O.x,O.y,Gs,Gs),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=c.createVertexBuffer(W,sue.members),this.boundsSegments=io.simpleSegment(0,0,4,2);const J=[],ee=[SO((ne=this.coordinates)[0]),SO(ne[1]),SO(ne[2]),SO(ne[3])];var ne;const[ie,ue,we,Ee]=function(Te){let Ue=Te[0][0],Ye=Ue,st=Te[0][1],_t=st;for(let ft=1;ftYe&&(Ye=Te[ft][0]),Te[ft][1]_t&&(_t=Te[ft][1]);return[Ue,st,Ye-Ue,_t-st]}(ee);{const Te=new bv,[Ue,Ye,st,_t]=function(Es){let Is=Es[0].x,us=Is,as=Es[0].y,Ls=as;for(let Ks=1;Ksus&&(us=Es[Ks].x),Es[Ks].yLs&&(Ls=Es[Ks].y);return[Is,as,us-Is,Ls-as]}(y),ft=Es=>[(Es.x-Ue)/st,(Es.y-Ye)/_t],[St,Pt,Ft,ns]=y.map(ft),Wt=function(Es,Is,us,as,Ls,Ks,$s,Pr){const lr=NO(0,0,1,0,1,1,0,1);return _(lr,lr,v([],NO(Es,Is,us,as,Ls,Ks,$s,Pr)))}(St[0],St[1],Pt[0],Pt[1],Ft[0],Ft[1],ns[0],ns[1]);this.elevatedGlobePerspectiveTransform=uNe(St[0],St[1],Pt[0],Pt[1],Ft[0],Ft[1],ns[0],ns[1]);const hs=(Es,Is)=>{J.push(Es.lng);const us=Math.round((Es.lng-ie)/we*Gs),as=Math.round((Es.lat-ue)/Ee*Gs),Ls=ft(Is),Ks=fe([],[Ls[0],Ls[1],1],Wt),$s=Math.round(Ks[0]/Ks[2]*Gs),Pr=Math.round(Ks[1]/Ks[2]*Gs);Te.emplaceBack(us,as,$s,Pr)},ys=y[3].x-y[0].x,vs=y[3].y-y[0].y,Ds=y[2].x-y[1].x,Fs=y[2].y-y[1].y;for(let Es=0;Es<65;Es++){const Is=Es/64,us=[y[0].x+Is*ys,y[0].y+Is*vs],as=[y[1].x+Is*Ds,y[1].y+Is*Fs],Ls=as[0]-us[0],Ks=as[1]-us[1];for(let $s=0;$s<65;$s++){const Pr=$s/64,lr={x:us[0]+Ls*Pr,y:us[1]+Ks*Pr};hs(m.projection.unproject(lr.x,lr.y),lr)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(Te,sue.members)}{this.maxLongitudeTriangleSize=0;let Te=[],Ue=new yl;const Ye=(st,_t,ft)=>{Ue.emplaceBack(st,_t,ft);const St=J[st],Pt=J[_t],Ft=J[ft],ns=Math.min(Math.min(St,Pt),Ft),Wt=Math.max(Math.max(St,Pt),Ft)-ns;Wt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Wt),Te.push(ns+Wt/2)};for(let st=0;st<64;st++)for(let _t=0;_t<64;_t++){const ft=65*st+_t,St=ft+1,Pt=ft+65,Ft=Pt+1;Ye(ft,Pt,St),Ye(St,Pt,Ft)}[Te,Ue]=function(st,_t){const ft=Array.from({length:st.length},(Ft,ns)=>ns);ft.sort((Ft,ns)=>st[Ft]-st[ns]);const St=[],Pt=new yl;for(let Ft=0;Ft{P.segments.push({vertexOffset:0,primitiveOffset:ee,vertexLength:m.segments[0].vertexLength,primitiveLength:ne,sortKey:void 0,vaos:{}})},B=.51*this.maxLongitudeTriangleSize;if(Math.abs(y[0]-k)<=B){const ee=Ki(y,0,y.length,k+B);return ee===y.length||O(ee,Vo(y,ee+1,y.length,k+360-B)-ee),P}kGs?k-Gs:k,new rs(Math.trunc(k),Math.trunc(y[m+1]))}translationForInstance(c){const m=16*c,y=this.instancedDataArray.float32;return[y[m+4],y[m+5],y[m+6]]}rotationScaleForInstance(c){const m=16*c,y=this.instancedDataArray.float32;return[y[m+7],y[m+8],y[m+9],y[m+10],y[m+11],y[m+12],y[m+13],y[m+14],y[m+15]]}transformForInstance(c){const m=16*c,y=this.instancedDataArray.float32;return[y[m+7],y[m+8],y[m+9],y[m+4],y[m+10],y[m+11],y[m+12],y[m+5],y[m+13],y[m+14],y[m+15],y[m+6],0,0,0,1]}}class aue{constructor(c){this.zoom=c.zoom,this.canonical=c.canonical,this.overscaledZ=this.canonical.z+Math.log2(c.overscaling),this.layers=c.layers,this.layerIds=this.layers.map(m=>m.fqid),this.projection=c.projection,this.index=c.index,this.worldview=c.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=c.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){this.tileToMeter=Be(y);const E=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:P,id:O,index:B,sourceLayerIndex:W}of c){const J=O??(P.properties&&P.properties.hasOwnProperty("id")?P.properties.id:void 0),ee=Ht(P,E);if(!this.layers[0]._featureFilter.filter(new Ii(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ee,y))continue;const ne={id:J,sourceLayerIndex:W,index:B,geometry:E?ee.geometry:Et(P,y,k),properties:P.properties,type:P.type,patterns:{}},ie=this.addFeature(ne,ne.geometry,ee);ie&&m.featureIndex.insert(P,ne.geometry,B,W,this.index,this.instancesPerModel[ie].instancedDataArray.length,Gs/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const c=this.layers[0].modelManager,m=this.layers[0].scope;let y=0;for(const k of this.modelUris){const E=c.getModel(k,m);if(!E)continue;const P=this.instancesPerModel[k];if(P){const O=.5*Ne(E.aabb.max,E.aabb.min)*P.maxScale+P.maxXYTranslationDistance,B=Math.min(Gs,Math.max(O/this.tileToMeter,Gs/32));y=Math.max(B,y)}}return y}update(c,m,y,k){for(const E in this.instancesPerModel){const P=this.instancesPerModel[E];for(const O in c)P.idToFeaturesIndex.hasOwnProperty(O)&&(this.evaluate(P.features[P.idToFeaturesIndex[O]],c[O],P,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let c=!1;for(const m in this.instancesPerModel){const y=this.instancesPerModel[m];for(const k of y.features){const E=this.layers[0],P=k.feature,O=this.canonical,B=E.paint.get("model-rotation").evaluate(P,{},O),W=E.paint.get("model-scale").evaluate(P,{},O),J=E.paint.get("model-translation").evaluate(P,{},O);rt(k.rotation,B)&&rt(k.scale,W)&&rt(k.translation,J)||(this.evaluate(k,k.featureStates,y,!0),c=!0)}}return c}updateReplacement(c,m,y,k){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const E=m.getReplacementRegionsForTile(c.toUnwrapped(),!0);if(XD(this.activeReplacements,E))return!1;this.activeReplacements=E;let P=!1;for(const O in this.instancesPerModel){const B=this.instancesPerModel[O],W=B.instancedDataArray;for(const J of B.features){const ee=J.instancedDataOffset,ne=J.instancedDataCount;for(let ie=0;ieGs;we=Ee?we-Gs:we;const Te=Math.floor(we),Ue=Math.floor(W.float32[ue+1]);let Ye=!1;for(const st of this.activeReplacements)if(!lje(st,y,_Ne.Model,k)&&!(st.min.x>Te||Te>st.max.x||st.min.y>Ue||Ue>st.max.y)&&(Ye=mje(hje(Te,Ue,c.canonical,st.footprintTileId.canonical),st.footprint),Ye))break;W.float32[ue]=Ye?we+Gs:we,P=P||Ye!==Ee}}}return P}isEmpty(){for(const c in this.instancesPerModel)if(this.instancesPerModel[c].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(c){if(!this.uploaded)for(const m in this.instancesPerModel){const y=this.instancesPerModel[m];y.instancedDataArray.length<0||y.instancedDataArray.length===0||(y.instancedDataBuffer?y.instancedDataBuffer.updateData(y.instancedDataArray):y.instancedDataBuffer=c.createVertexBuffer(y.instancedDataArray,rtt.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(c){for(const y in this.instancesPerModel){const k=this.instancesPerModel[y];k.instancedDataArray.length!==0&&k.instancedDataBuffer&&k.instancedDataBuffer.destroy()}const m=this.layers[0].modelManager;if(c&&m&&this.modelUris&&this.modelsRequested)for(const y of this.modelUris)m.removeModel(y,"",!0)}addFeature(c,m,y){const k=this.layers[0],E=k.layout.get("model-id").evaluate(y,{},this.canonical);if(!E)return cr(`modelId is not evaluated for layer ${k.id} and it is not going to get rendered.`),E;(nue(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new wNe);const P=this.instancesPerModel[E],O=P.instancedDataArray,B=new bNe(y,O.length);for(const W of m)for(const J of W){if(J.x<0||J.x>=Gs||J.y<0||J.y>=Gs)continue;if(this.lookupDim!==0){const ne=(this.lookupDim-1)/Gs,ie=this.lookupDim*(J.y*ne|0)+J.x*ne|0;if(this.lookup){if(this.lookup[ie]!==0)continue;this.lookup[ie]=1}}this.instanceCount++;const ee=O.length;O.resize(ee+1),P.instancesEvaluatedElevation.push(0),O.float32[16*ee]=J.x,O.float32[16*ee+1]=J.y}return B.instancedDataCount=P.instancedDataArray.length-B.instancedDataOffset,B.instancedDataCount>0&&(c.id&&(P.idToFeaturesIndex[c.id]=P.features.length),P.features.push(B),this.evaluate(B,{},P,!1)),E}getModelUris(){return this.modelUris}evaluate(c,m,y,k){const E=this.layers[0],P=c.feature,O=this.canonical,B=c.rotation=E.paint.get("model-rotation").evaluate(P,m,O),W=c.scale=E.paint.get("model-scale").evaluate(P,m,O),J=c.translation=E.paint.get("model-translation").evaluate(P,m,O),ee=Object.assign({},E.paint.get("model-color").evaluate(P,m,O));ee.a=E.paint.get("model-color-mix-intensity").evaluate(P,m,O);const ne=[];this.maxVerticalOffset0?Math.sqrt(ie):0;y.maxScale=Math.max(Math.max(y.maxScale,W[0]),Math.max(W[1],W[2])),y.maxXYTranslationDistance=Math.max(y.maxXYTranslationDistance,ue),this.maxScale=Math.max(Math.max(this.maxScale,W[0]),Math.max(W[1],W[2])),Jje(ne,B,W);const we=Math.round(100*ee.a)+ee.b/1.05;for(let Ee=0;Ee10?this.tileToMeter:Be(O,_t)),Ye[Ue+4]=J[0],Ye[Ue+5]=J[1],Ye[Ue+6]=J[2]+st,Ye[Ue+7]=ne[0],Ye[Ue+8]=ne[1],Ye[Ue+9]=ne[2],Ye[Ue+10]=ne[4],Ye[Ue+11]=ne[5],Ye[Ue+12]=ne[6],Ye[Ue+13]=ne[8],Ye[Ue+14]=ne[9],Ye[Ue+15]=ne[10],y.instancesEvaluatedElevation[Te]=J[2]}}}let jNe,kNe;vr(aue,"ModelBucket",{omit:["layers"]}),vr(wNe,"PerModelAttributes"),vr(bNe,"ModelFeature");class AC{constructor(c,m,y){this._demTile=c,this._dem=this._demTile.dem,this._scale=m,this._offset=y}static create(c,m,y){const k=y||c.findDEMTileFor(m);if(!k||!k.dem)return;const E=k.dem,P=k.tileID,O=1<W.fqid),this.stateDependentLayerIds=this.layers.filter(W=>W.isStateDependent()).map(W=>W.id),this.modelTraits|=bC.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,k&&(this.modelTraits|=bC.HasMapboxMeshFeatures),E&&(this.modelTraits|=bC.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=P,this.worldview=B,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const W of m)this.nodesInfo.push(new MNe(W)),SNe(W,O.featureIndexArray.length,O.grid),O.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,O.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(c,m){for(const y of this.getNodesInfo()){const k=y.node;k.footprint&&m.push({footprint:k.footprint,id:c})}}updateAppearances(c,m,y,k){}update(c){const m=Object.keys(c).length!==0;if(m&&!this.stateDependentLayers.length)return;const y=m?this.stateDependentLayers:this.layers;if(!An(c,this.states))for(const k of y)this.evaluate(k,c);this.states=structuredClone(c)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(c){if(!this.needsUpload)return;const m=this.getNodesInfo();for(const y of m){const k=y.node;this.uploaded?this.updatePbrBuffer(k):Ade(k,c,!0)}for(const y of m)cO(y.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(c){let m=!1;if(!c.meshes)return m;for(const y of c.meshes)y.pbrBuffer&&(y.pbrBuffer.updateData(y.featureArray),m=!0);return m}needsReEvaluation(c,m,y){const k=c.transform.projectionOptions,E=c.style.getBrightness(),P=this.brightness!==E;if(!this.uploaded||this.dirty||k.name!==this.projection.name||gA(y.paint.get("model-color").value,P)||gA(y.paint.get("model-color-mix-intensity").value,P)||gA(y.paint.get("model-roughness").value,P)||gA(y.paint.get("model-emissive-strength").value,P)||gA(y.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=k,this.brightness=E;const O=this.getNodesInfo();for(const B of O)B.state=null;return!0}return!1}evaluateTransform(c,m){if(c.transform.zoom===this.zoom)return;this.zoom=c.transform.zoom;const y=this.getNodesInfo(),k=this.id.canonical;for(const E of y){const P=E.feature;E.evaluatedTranslation=m.paint.get("model-translation").evaluate(P,{},k),E.evaluatedScale=m.paint.get("model-scale").evaluate(P,{},k)}}evaluate(c,m){const y=this.getNodesInfo();for(const k of y){if(!k.node.meshes)continue;const E=k.feature,P=m&&m[E.id];if(An(P,k.state))continue;k.state=structuredClone(P);const O=k.node.meshes&&k.node.meshes[0].featureData,B=k.evaluatedColor[2],W=k.evaluatedRMEA[2],J=this.id.canonical;if(k.hasTranslucentParts=!1,O){for(let ee=0;ee=ft)continue;const Es=iue[Fs],Is=Math.abs(Es);Is>Wt&&(ns=Es,Wt=Is,hs=Ds,ys=vs)}if(Wt>.1){const vs=1-(ft+.5*Math.abs(hs*ys))/ue;let Ds=m._dem.get(Pt,St)+ns*vs;const Fs=m._dem.get(Pt+hs,St+ys),Es=m._dem.get(Pt-hs,St-ys,!0);(Ds-Fs)*(Ds-Es)>0&&(Ds=(Fs+Es)/2),iue[Ft]=m._dem.set(Pt,St,Ds),Lb[Ft]=ft}}}}}O&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=xl.now())}setFilter(c){this.filter=c?HS(c):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(c=>this.filter.filter(new Ii(this.id.overscaledZ,{worldview:this.worldview}),c.feature,this.id.canonical)):this.nodesInfo}destroy(){const c=this.getNodesInfo();for(const m of c)cO(m.node),Ede(m.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(c,m){if(m.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=m.updateTime;const y=m.getReplacementRegionsForTile(c.toUnwrapped());for(const k of this.getNodesInfo()){const E=k.node.footprint;k.hiddenByReplacement=!!E&&!y.find(P=>P.footprint===E)}}getHeightAtTileCoord(c,m){const y=[],k=[0,0,0],E=j([]);for(const P of this.getNodesInfo()){const O=P.node.meshes[0],B=O.transformedAabb;if(cB.max[0]||m>B.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),k[0]=c,k[1]=m,Rt(k,k,E);const W=(k[0]-O.aabb.min[0])/(O.aabb.max[0]-O.aabb.min[0])*Eb|0,J=Math.min(63,(k[1]-O.aabb.min[1])/(O.aabb.max[1]-O.aabb.min[1])*Eb|0)*Eb+Math.min(63,W),ee=O.heightmap[J];if(!(ee<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:ee,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new rs(c,m),new rs(c,m),y),y.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function gA(p,c){return p instanceof xv&&!p.isLightConstant&&c}function Dst(p,c,m,y,k,E,P,O){let B=(61440&c|(61440&c)>>4)>>8,W=(3840&c|(3840&c)>>4)>>4,J=240&c|(240&c)>>4;m[3]>0&&(B=Ur(B,255*m[0],m[3]),W=Ur(W,255*m[1],m[3]),J=Ur(J,255*m[2],m[3]));const ee=B<<8|W,ne=J<<8|Math.floor(255*y[3]),ie=function(ft){const St=Se(ft,0,2);return Math.min(Math.round(.5*St*255),255)}(y[2])<<8|15*y[0]<<4|15*y[1],ue=Se(k[0],0,1),we=Se(k[1],0,1),Ee=Se(k[2],0,1),Te=Se(k[3],0,1);let Ue,Ye,st,_t;if(ue!==we&&P!==E&&we!==ue){const ft=P-E;Ye=1/(ft*(we-ue)),st=-(E+ft*ue)/(ft*(we-ue));const St=Se(k[4],-1,1);_t=Math.pow(10,St),Ue=255*Ee<<8|255*Te}else Ue=65535,Ye=0,st=1,_t=1;if(p.emplaceBack(ee,ne,ie,Ue,Ye,st,_t),O){const ft=O.length;O.clear();for(let St=0;St>16&65535,J=E?B>>16&65535:65535&B,ee=(15&J)<8?15&J:0,ne=p.evaluatedRMEA[ee],ie=p.evaluatedColor[ee],ue=p.emissionHeightBasedParams[ee];let we;if(O&&ee===2&&y.lights&&(we=new sC,we.resize(10*y.lights.length)),Dst(P.featureArray,W,ie,ne,ue,P.aabb.min[2],P.aabb.max[2],we),we&&O){O=!1;const Ee=y.meshes[y.lightMeshIndex];Ee.featureArray=we,Ee.featureArray._trim()}}P.featureArray._trim(),k++}}vr(MO,"Tiled3dModelBucket",{omit:["layers"]}),vr(MNe,"Tiled3dModelFeature");const Rst=["id","tile","layer","source","sourceLayer","state"];class Db{constructor(c,m,y,k,E){this.type="Feature",this._vectorTileFeature=c,this._z=m,this._x=y,this._y=k,this.properties=c?c.properties:{},this.id=E}clone(){const c=new Db(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(c.state=Object.assign({},this.state)),this.layer&&(c.layer=Object.assign({},this.layer)),this.source&&(c.source=this.source),this.sourceLayer&&(c.sourceLayer=this.sourceLayer),c}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(c){this._geometry=c}toJSON(){const c={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const m of Rst)this[m]!==void 0&&(c[m]=this[m]);return c}}class Ob extends Ns{constructor(c,m,y,k){super(),this.id=c,this.type="model",this.models=[],this._loaded=!1,this._options=m,this._modelsInfo=new Map}load(){const c=[];for(const m in this._options.models){const y=this._options.models[m],k=this._modelsInfo.get(m);if(k){const E=k.model;E.position=y.position!=null?new x(y.position[0],y.position[1]):new x(0,0),E.orientation=y.orientation!=null?y.orientation:[0,0,0],k.modelSpec=y,Ob.applyModelSpecification(E,y),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=Zje(this.map._requestManager.transformRequest(y.uri,Cf.Model).url).then(P=>{if(!P)return;const O=Ide(P),B=new eke(m,y.uri,y.position,y.orientation,O);Ob.applyModelSpecification(B,y),B.computeBoundsAndApplyParent(),this.models.push(B),this._modelsInfo.set(m,{modelSpec:y,model:B})}).catch(P=>{this.fire(new Yg(new Error(`Could not load model ${m} from ${y.uri}: ${P.message}`)))});c.push(E)}}Promise.allSettled(c).then(()=>{this._loaded=!0,this.fire(new Qh("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new Yg(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(c,m){m.nodeOverrides&&Ob.convertNodeOverrides(c,m.nodeOverrides),m.materialOverrides&&Ob.convertMaterialOverrides(c,m.materialOverrides),m.nodeOverrideNames&&(c.nodeOverrideNames=[...m.nodeOverrideNames]),m.materialOverrideNames&&(c.materialOverrideNames=[...m.materialOverrideNames]),m.featureProperties&&(c.featureProperties=m.featureProperties)}static convertNodeOverrides(c,m){if(Array.isArray(m)&&m.every(y=>typeof y=="string")){c.nodeOverrideNames=[];for(const y of m)c.nodeOverrideNames.push(y)}else Object.entries(m).forEach(([y,k])=>{const E={orientation:[0,0,0]};if(k.hasOwnProperty("orientation")){const P=k.orientation;P&&(E.orientation=P)}c.nodeOverrides.set(y,E)})}static convertMaterialOverrides(c,m){if(Array.isArray(m)&&m.every(y=>typeof y=="string")){c.materialOverrideNames=[];for(const y of m)c.materialOverrideNames.push(y)}else Object.entries(m).forEach(([y,k])=>{const E={color:new Fr(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=k["model-color"];P!==void 0&&(E.color.r=P[0],E.color.g=P[1],E.color.b=P[2]);const O=k["model-color-mix-intensity"];O!==void 0&&(E.colorMix=O);const B=k["model-emissive-strength"];B!==void 0&&(E.emissionStrength=B);const W=k["model-opacity"];W!==void 0&&(E.opacity=W),c.materialOverrides.set(y,E)})}onAdd(c){this.map=c,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(c,m){}serialize(){return this._options}setProperty(c,m){return!1}reload(){const c=qm(this.id,this.scope);this.map.style.clearSource(c),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(c){this.models=[];const m=new Map;for(const y in c){const k=c[y];if(this._modelsInfo.has(y)){const E=this._modelsInfo.get(y);E&&E.modelSpec.uri===k.uri&&m.set(y,E)}}this._modelsInfo=m,this._options.models=c,this._loaded=!1,this.load()}}function oue(p,c,m,y){const k=1<st.polygon).flat());const Ee=ie?O:null,[Te,Ue]=Rje(E,y,ee,J,W,P,Ee,ne,ue,E.center.lat,p.tileID.canonical),Ye=p.queryGeometry;return Oje(Te,Ue,Ye.isPointQuery()?Ye.screenBounds:Ye.screenGeometry)}},building:class extends Kd{constructor(p,c,m,y){super(p,{layout:oke||(oke=new _o({visibility:new Us(Gt.layout_building.visibility),"building-facade":new sr(Gt.layout_building["building-facade"]),"building-facade-floors":new sr(Gt.layout_building["building-facade-floors"]),"building-facade-unit-width":new sr(Gt.layout_building["building-facade-unit-width"]),"building-facade-window":new sr(Gt.layout_building["building-facade-window"]),"building-roof-shape":new sr(Gt.layout_building["building-roof-shape"]),"building-height":new sr(Gt.layout_building["building-height"]),"building-base":new sr(Gt.layout_building["building-base"]),"building-flood-light-wall-radius":new sr(Gt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new sr(Gt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new sr(Gt.layout_building["building-flip-roof-orientation"])})),paint:lke||(lke=new _o({"building-opacity":new Us(Gt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Us(Gt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Us(Gt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Us(Gt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Us(Gt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Us(Gt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Us(Gt.paint_building["building-cast-shadows"]),"building-color":new sr(Gt.paint_building["building-color"]),"building-emissive-strength":new sr(Gt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Us(Gt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Us(Gt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Us(Gt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Us(Gt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Us(Gt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new sr({type:"string",default:"default","property-type":"data-driven"})}))},c,m,y),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(p){return new ike(p)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(p){return!0}queryRadius(p){return 0}queryIntersectsFeature(p,c,m,y,k,E,P,O,B){let W=this.layout.get("building-height").evaluate(c,m);const J=this.layout.get("building-base").evaluate(c,m),ee=p.tile.getBucket(this).getFootprint(c);if(ee){if(ee.hiddenFlags!==0)return!1;W=ee.height}const[ne,ie]=Rje(E,y,J,W,new rs(0,0),P,null,[0,0],1,E.center.lat,p.tileID.canonical),ue=p.queryGeometry;return Oje(ne,ie,ue.isPointQuery()?ue.screenBounds:ue.screenGeometry)}},line:class extends Kd{constructor(p,c,m,y){const k=yke();super(p,k,c,m,y),k.layout&&(this.layout=new Sy(k.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(p){if(p==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof ib,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(p,c){super.recalculate(p,c),this.paint._values["line-floorwidth"]=(()=>{if(tA)return tA;const m=yke();return tA=new Itt(m.paint.properties["line-width"].specification),tA.useIntegerZoom=!0,tA})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,p)}createBucket(p){return new Ode(p)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(p,c,m){const y=gke(this);return{config:new ux(this,{zoom:c,lut:m}),defines:y,overrideFog:!1}}queryRadius(p){const c=p,m=vke(hd("line-width",this,c),hd("line-gap-width",this,c)),y=hd("line-offset",this,c);return m/2+Math.abs(y)+Mc(this.paint.get("line-translate"))}queryIntersectsFeature(p,c,m,y,k,E){if(p.queryGeometry.isAboveHorizon)return!1;const P=mh(p.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,p.pixelToTileUnitsFactor),O=p.pixelToTileUnitsFactor/2*vke(this.paint.get("line-width").evaluate(c,m),this.paint.get("line-gap-width").evaluate(c,m)),B=this.paint.get("line-offset").evaluate(c,m);return B&&(y=function(W,J){const ee=[],ne=new rs(0,0);for(let ie=0;ie=3){for(let ue=0;ue>16&255)/255,(p>>8&255)/255,(255&p)/255,1)}function Qst(p,c,m){p===1?(c.rgb_color=PO(m.readVarint()),c.paint="rgb_color"):p===2?(c.linear_gradient_idx=m.readVarint(),c.paint="linear_gradient_idx"):p===3?(c.radial_gradient_idx=m.readVarint(),c.paint="radial_gradient_idx"):p===5?m.readPackedFloat(c.dasharray):p===6?c.dashoffset=m.readFloat():p===7?c.miterlimit=m.readFloat():p===8?c.opacity=m.readVarint():p===9?c.width=m.readFloat():p===10?c.linecap=m.readVarint():p===11&&(c.linejoin=m.readVarint())}function Jst(p,c,m){p===1?c.transform=EO(m,m.readVarint()+m.pos):p===2?c.spread_method=m.readVarint():p===3?c.stops.push(PNe(m,m.readVarint()+m.pos)):p===4?c.x1=m.readFloat():p===5?c.y1=m.readFloat():p===6?c.x2=m.readFloat():p===7&&(c.y2=m.readFloat())}function PNe(p,c){return p.readFields(ert,{offset:0,opacity:255,rgb_color:lue},c)}function ert(p,c,m){p===1?c.offset=m.readFloat():p===2?c.opacity=m.readVarint():p===3&&(c.rgb_color=PO(m.readVarint()))}function trt(p,c,m){p===1?c.transform=EO(m,m.readVarint()+m.pos):p===2?c.spread_method=m.readVarint():p===3?c.stops.push(PNe(m,m.readVarint()+m.pos)):p===4?c.cx=m.readFloat():p===5?c.cy=m.readFloat():p===6?c.r=m.readFloat():p===7?c.fx=m.readFloat():p===8?c.fy=m.readFloat():p===9&&(c.fr=m.readFloat())}function srt(p,c,m){p===1?c.transform=EO(m,m.readVarint()+m.pos):p===2?c.clip_path_idx=m.readVarint():p===3&&c.children.push(AO(m,m.readVarint()+m.pos))}function rrt(p,c,m){p===1?c.left=c.top=m.readFloat():p===2?c.width=c.height=m.readFloat():p===3?c.top=m.readFloat():p===4?c.height=m.readFloat():p===5?c.mask_type=m.readVarint():p===6?c.mask_idx=m.readVarint():p===7&&c.children.push(AO(m,m.readVarint()+m.pos))}class nrt{static calculate(c={},m=[]){const y=new Map,k=new Map;if(Object.keys(c).length===0)return y;m.forEach(E=>{k.set(E.name,E.rgb_color||new Fr(0,0,0))});for(const[E,P]of Object.entries(c))k.has(E)?y.set(k.get(E).toString(),P):console.warn(`Ignoring unknown image variable "${E}"`);return y}}function EC(p,c=255,m){const y=c/255,k=p.toString(),E=m.has(k)?m.get(k).clone():p.clone();return E.a*=y,E.toString()}function yA(p,c){if(!Zh()){const m=document.createElement("canvas");return m.width=p,m.height=c,m}return new OffscreenCanvas(p,c)}let uue,vA=null;function hue(p,c,m,y,k){for(const E of y.children)INe(p,c,m,E,k)}function INe(p,c,m,y,k){y.group?(p.save(),function(E,P,O,B,W){const J=B.mask_idx!=null?O.masks[B.mask_idx]:null,ee=B.clip_path_idx!=null?O.clip_paths[B.clip_path_idx]:null;if(B.transform&&(P=PC(B.transform).preMultiplySelf(P)),!function(ue,we,Ee){return ue.opacity!==255||we||Ee}(B,ee!=null,J!=null))return void hue(E,P,O,B,W);const ne=yA(E.canvas.width,E.canvas.height),ie=ne.getContext("2d");hue(ie,P,O,B,W),ee&&BNe(ie,P,O,ee),J&&$Ne(ie,P,O,J,W),E.globalAlpha=B.opacity/255,E.drawImage(ne,0,0)}(p,c,m,y.group,k),p.restore()):y.path&&(p.save(),function(E,P,O,B,W){E.setTransform(P),B.paint_order===Bst.PAINT_ORDER_FILL_AND_STROKE?(LNe(E,O,B,W),ONe(E,O,B,W)):(ONe(E,O,B,W),LNe(E,O,B,W))}(p,c,m,y.path,k),p.restore())}function LNe(p,c,m,y){const k=m.fill;if(!k)return;const E=k.opacity/255;switch(p.save(),p.beginPath(),qNe(m,p),k.paint){case"rgb_color":p.fillStyle=EC(k.rgb_color,k.opacity,y);break;case"linear_gradient_idx":{const P=c.linear_gradients[k.linear_gradient_idx];P.transform&&p.setTransform(PC(P.transform).preMultiplySelf(p.getTransform())),p.fillStyle=RNe(p,P,E,y);break}case"radial_gradient_idx":{const P=c.radial_gradients[k.radial_gradient_idx];P.transform&&p.setTransform(PC(P.transform).preMultiplySelf(p.getTransform())),p.fillStyle=FNe(p,P,E,y)}}p.fill(DNe(m)),p.restore()}function DNe(p){return p.rule===cue.PATH_RULE_NON_ZERO?"nonzero":p.rule===cue.PATH_RULE_EVEN_ODD?"evenodd":void 0}function ONe(p,c,m,y){const k=m.stroke;if(!k)return;const E=UNe(m);p.lineWidth=k.width,p.miterLimit=k.miterlimit,p.setLineDash(k.dasharray),p.lineDashOffset=k.dashoffset;const P=k.opacity/255;switch(k.paint){case"rgb_color":p.strokeStyle=EC(k.rgb_color,k.opacity,y);break;case"linear_gradient_idx":p.strokeStyle=RNe(p,c.linear_gradients[k.linear_gradient_idx],P,y,!0);break;case"radial_gradient_idx":p.strokeStyle=FNe(p,c.radial_gradients[k.radial_gradient_idx],P,y,!0)}switch(k.linejoin){case TO.LINE_JOIN_MITER_CLIP:case TO.LINE_JOIN_MITER:p.lineJoin="miter";break;case TO.LINE_JOIN_ROUND:p.lineJoin="round";break;case TO.LINE_JOIN_BEVEL:p.lineJoin="bevel"}switch(k.linecap){case due.LINE_CAP_BUTT:p.lineCap="butt";break;case due.LINE_CAP_ROUND:p.lineCap="round";break;case due.LINE_CAP_SQUARE:p.lineCap="square"}p.stroke(E)}function RNe(p,c,m,y,k=!1){if(c.stops.length===1){const ne=c.stops[0];return EC(ne.rgb_color,ne.opacity*m,y)}const{x1:E,y1:P,x2:O,y2:B}=c;let W=new DOMPoint(E,P),J=new DOMPoint(O,B);if(k){const ne=PC(c.transform);W=ne.transformPoint(W),J=ne.transformPoint(J)}const ee=p.createLinearGradient(W.x,W.y,J.x,J.y);for(const ne of c.stops)ee.addColorStop(ne.offset,EC(ne.rgb_color,ne.opacity*m,y));return ee}function FNe(p,c,m,y,k=!1){if(c.stops.length===1){const Te=c.stops[0];return EC(Te.rgb_color,Te.opacity*m,y)}const E=PC(c.transform),{fx:P,fy:O,fr:B,cx:W,cy:J,r:ee}=c;let ne=new DOMPoint(P,O),ie=new DOMPoint(W,J),ue=B,we=ee;if(k){ne=E.transformPoint(ne),ie=E.transformPoint(ie);const Te=(E.a+E.d)/2;ue=B*Te,we=c.r*Te}const Ee=p.createRadialGradient(ne.x,ne.y,ue,ie.x,ie.y,we);for(const Te of c.stops)Ee.addColorStop(Te.offset,EC(Te.rgb_color,Te.opacity*m,y));return Ee}function zNe(p,c,m,y){const k=y.transform?PC(y.transform).preMultiplySelf(c):c,E=yA(p.canvas.width,p.canvas.height),P=E.getContext("2d");for(const B of y.children)if(B.group)zNe(P,k,m,B.group);else if(B.path){const W=B.path,J=new Path2D;J.addPath(UNe(W),k),P.fill(J,DNe(W))}const O=y.clip_path_idx!=null?m.clip_paths[y.clip_path_idx]:null;O&&BNe(P,k,m,O),p.globalCompositeOperation="source-over",p.drawImage(E,0,0)}function BNe(p,c,m,y){const k=yA(p.canvas.width,p.canvas.height);zNe(k.getContext("2d"),c,m,y),p.globalCompositeOperation="destination-in",p.drawImage(k,0,0)}function $Ne(p,c,m,y,k){if(y.children.length===0)return;const E=y.mask_idx!=null?m.masks[y.mask_idx]:null;E&&$Ne(p,c,m,E,k);const P=p.canvas.width,O=p.canvas.height,B=yA(P,O),W=B.getContext("2d"),J=y.width,ee=y.height,ne=y.left,ie=y.top,ue=new Path2D,we=new Path2D;we.rect(ne,ie,J,ee),ue.addPath(we,c),W.clip(ue);for(const Ue of y.children)INe(W,c,m,Ue,k);const Ee=W.getImageData(0,0,P,O),Te=Ee.data;if(y.mask_type===TNe.MASK_TYPE_LUMINANCE)for(let Ue=0;Uec[P])return null}else{const O=1/y[P];let B=(p[P]-m[P])*O,W=(c[P]-m[P])*O;if(B>W){const J=B;B=W,W=J}if(B>k&&(k=B),WE)return null}return k}function WNe(p,c,m,y,k,E,P,O,B,W,J){const ee=y-p,ne=k-c,ie=E-m,ue=P-p,we=O-c,Ee=B-m,Te=J[1]*Ee-J[2]*we,Ue=J[2]*ue-J[0]*Ee,Ye=J[0]*we-J[1]*ue,st=ee*Te+ne*Ue+ie*Ye;if(Math.abs(st)<1e-15)return null;const _t=1/st,ft=W[0]-p,St=W[1]-c,Pt=W[2]-m,Ft=(ft*Te+St*Ue+Pt*Ye)*_t;if(Ft<0||Ft>1)return null;const ns=St*ie-Pt*ne,Wt=Pt*ee-ft*ie,hs=ft*ne-St*ee,ys=(J[0]*ns+J[1]*Wt+J[2]*hs)*_t;return ys<0||Ft+ys>1?null:(ue*ns+we*Wt+Ee*hs)*_t}function GNe(p,c,m){return(p-c)/(m-c)}function KNe(p,c,m,y,k,E,P,O,B){const W=1<{const Ue=Ee?1:0,Ye=(ie+1)*we-Ue,st=ue*we,_t=(ue+1)*we-Ue;Te[0]=ie*we,Te[1]=st,Te[2]=Ye,Te[3]=_t};let ee=new VNe(B);const ne=[];for(let ie=0;ie=1;B/=2){const ie=O[O.length-1];ee=new VNe(B);for(let ue=0;ue0;){const{idx:ue,t:we,nodex:Ee,nodey:Te,depth:Ue}=ie.pop();if(this.leaves[ue]){KNe(Ee,Te,Ue,c,m,y,k,ee,ne);const st=1<=Fs[2])return we}continue}let Ye=0;for(let st=0;st=W[J[Pt]]&&(J.splice(Pt,0,st),St=!0);St||(J[Ye]=st),Ye++}}for(let st=0;st=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+(c+1)}static pack(c,m){const y=[0,0,0,0],k=LO.getUnpackVector(m);let E=Math.floor((c+k[3])/k[2]);return y[2]=E%256,E=Math.floor(E/256),y[1]=E%256,E=Math.floor(E/256),y[0]=E,y}getPixels(){return new V2e({width:this.stride,height:this.stride},this.pixels)}backfillBorder(c,m,y){if(this.dim!==c.dim)throw new Error("dem dimension mismatch");let k=m*this.dim,E=m*this.dim+this.dim,P=y*this.dim,O=y*this.dim+this.dim;switch(m){case-1:k=E-1;break;case 1:E=k+1}switch(y){case-1:P=O-1;break;case 1:O=P+1}const B=-m*this.dim,W=-y*this.dim;for(let J=P;J=1;y--){const k=y===1?1:0,E=y===2?1:0;for(let P=0;P>>1^-(1&p[c]);return p}function yrt(p,c){switch(c){case"uint32":return p;case"uint16":for(let m=0;m>4|(61440&y)>>8|(240&k)<<4|61440&k,p[m+1]=15&y|(3840&y)>>4|(15&k)<<8|(3840&k)<<4}return p;case"uint8":for(let m=0;m>6|(192&k)>>4|(192&E)>>2|192&P,p[m+1]=(48&y)>>4|(48&k)>>2|48&E|(48&P)<<2,p[m+2]=(12&y)>>2|12&k|(12&E)<<2|(12&P)<<4,p[m+3]=3&y|(3&k)<<2|(3&E)<<4|(3&P)<<6}return p;default:throw new Error(`Invalid pixel format, "${c}"`)}}vr(LO,"DEMData"),vr(ZNe,"DemMinMaxQuadTree",{omit:["dem"]});var Wm=Uint8Array,_A=Uint16Array,vrt=Int32Array,XNe=new Wm([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]),QNe=new Wm([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]),_rt=new Wm([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),JNe=function(p,c){for(var m=new _A(31),y=0;y<31;++y)m[y]=c+=1<>1|(21845&Rl)<<1;sSe[Rl]=((65280&(IC=(61680&(IC=(52428&IC)>>2|(13107&IC)<<2))>>4|(3855&IC)<<4))>>8|(255&IC)<<8)>>1}var bA=function(p,c,m){for(var y=p.length,k=0,E=new _A(c);k>B]=W;return P},wA=new Wm(288);for(Rl=0;Rl<144;++Rl)wA[Rl]=8;for(Rl=144;Rl<256;++Rl)wA[Rl]=9;for(Rl=256;Rl<280;++Rl)wA[Rl]=7;for(Rl=280;Rl<288;++Rl)wA[Rl]=8;var rSe=new Wm(32);for(Rl=0;Rl<32;++Rl)rSe[Rl]=5;var jrt=bA(wA,9),krt=bA(rSe,5),pue=function(p){for(var c=p[0],m=1;mc&&(c=p[m]);return c},Zf=function(p,c,m){var y=c/8|0;return(p[y]|p[y+1]<<8)>>(7&c)&m},fue=function(p,c){var m=c/8|0;return(p[m]|p[m+1]<<8|p[m+2]<<16)>>(7&c)},Nrt=["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"],Yf=function(p,c,m){var y=new Error(c||Nrt[p]);if(y.code=p,Error.captureStackTrace&&Error.captureStackTrace(y,Yf),!m)throw y;return y},Srt=new Wm(0),Crt=typeof TextDecoder<"u"&&new TextDecoder;try{Crt.decode(Srt,{stream:!0})}catch{}const Mrt={gzip_data:"gzip"};class Rp extends Error{constructor(c){super(c),this.name="MRTError"}}const Trt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},nSe={uint32:1,uint16:2,uint8:4},Art={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let gue;class DO{constructor(c=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=c}getLayer(c){const m=this.layers[c];if(!m)throw new Rp(`Layer '${c}' not found`);return m}getHeaderLength(c){const m=new Uint8Array(c),y=new DataView(c);if(m[0]!==13)throw new Rp("File is not a valid MRT.");return y.getUint32(1,!0)}parseHeader(c){const m=new Uint8Array(c),y=this.getHeaderLength(c);if(m.length= ${y} but got buffer of length ${m.length}`);const k=new gue(m.subarray(0,y)).readFields(lrt,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==k.x||this.y!==k.y||this.z!==k.z))throw new Rp(`Invalid attempt to parse header ${k.z}/${k.x}/${k.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=k.x,this.y=k.y,this.z=k.z;for(const E of k.layers)this.layers[E.name]=new aSe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(c){const m=[],y=this.getLayer(c.layerName);for(let k of c.blockIndices){const E=y.dataIndex[k],P=E.firstByte-c.firstByte,O=E.lastByte-c.firstByte;if(y._blocksInProgress.has(k))continue;const B={layerName:y.name,firstByte:P,lastByte:O,pixelFormat:y.pixelFormat,blockIndex:k,blockShape:[E.bands.length].concat(y.bandShape),buffer:y.buffer,codec:E.codec.codec,filters:E.filters.map(W=>W.filter)};y._blocksInProgress.add(k),m.push(B)}return new iSe(m,()=>{m.forEach(k=>y._blocksInProgress.delete(k.blockIndex))},(k,E)=>{if(m.forEach(P=>y._blocksInProgress.delete(P.blockIndex)),k)throw k;E.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class aSe{constructor({version:c,name:m,units:y,tileSize:k,pixelFormat:E,buffer:P,dataIndex:O},B){if(this.version=c,this.version!==1)throw new Rp(`Cannot parse raster layer encoded with MRT version ${c}`);this.name=m,this.units=y,this.tileSize=k,this.buffer=P,this.pixelFormat=Trt[E],this.dataIndex=O,this.bandShape=[k+2*P,k+2*P,nSe[this.pixelFormat]],this._decodedBlocks=new IO(B?B.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return nSe[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:c})=>c).flat()}processDecodedData(c){const m=c.blockIndex.toString();this._decodedBlocks.get(m)||this._decodedBlocks.put(m,c.data)}getBlockForBand(c){let m=0;switch(typeof c){case"string":for(const[y,k]of this.dataIndex.entries()){for(const[E,P]of k.bands.entries())if(P===c)return{bandIndex:m+E,blockIndex:y,blockBandIndex:E};m+=k.bands.length}break;case"number":for(const[y,k]of this.dataIndex.entries()){if(c>=m&&cthis.cacheSize)throw new Rp(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:y,blockIndices:k}}hasBand(c){const{blockIndex:m}=this.getBlockForBand(c);return m>=0}hasDataForBand(c){const{blockIndex:m}=this.getBlockForBand(c);return m>=0&&!!this._decodedBlocks.get(m.toString())}getBandView(c){const{blockIndex:m,blockBandIndex:y}=this.getBlockForBand(c);if(m<0)throw new Rp(`Band not found: ${JSON.stringify(c)}`);const k=this._decodedBlocks.get(m.toString());if(!k)throw new Rp(`Data for band ${JSON.stringify(c)} of layer "${this.name}" not decoded.`);const E=this.dataIndex[m],P=this.bandShape.reduce((W,J)=>W*J,1),O=y*P,B=k.subarray(O,O+P);return{data:B,bytes:new Uint8Array(B.buffer).subarray(B.byteOffset,B.byteOffset+B.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:E.offset,scale:E.scale}}}DO.setPbf=function(p){gue=p};class iSe{constructor(c,m,y){this.tasks=c,this._onCancel=m,this._onComplete=y,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(c,m){this._finalized||(this._onComplete(c,m),this._finalized=!0)}}DO.performDecoding=function(p,c){const m=new Uint8Array(p);return Promise.all(c.tasks.map(y=>{const{layerName:k,firstByte:E,lastByte:P,pixelFormat:O,blockShape:B,blockIndex:W,filters:J,codec:ee}=y,ne=m.subarray(E,P+1),ie=new Uint32Array(B[0]*B[1]*B[2]);let ue;if(ee!=="gzip_data")throw new Rp(`Unhandled codec: ${ee}`);return ue=function(we,Ee){if(!globalThis.DecompressionStream&&Ee==="gzip_data")return Promise.resolve(((st=function(St){St[0]==31&&St[1]==139&&St[2]==8||Yf(6,"invalid gzip data");var Pt=St[3],Ft=10;4&Pt&&(Ft+=2+(St[10]|St[11]<<8));for(var ns=(Pt>>3&1)+(Pt>>4&1);ns>0;ns-=!St[Ft++]);return Ft+(2&Pt)}(Ye=we))+8>Ye.length&&Yf(6,"invalid gzip data"),function(St,Pt,Ft,ns){var Wt=St.length;if(!Wt||Pt.f&&!Pt.l)return Ft||new Wm(0);var hs=!Ft,ys=hs||Pt.i!=2,vs=Pt.i;hs&&(Ft=new Wm(3*Wt));var Ds,Fs,Es=function(fi){var Ha=Ft.length;if(fi>Ha){var Qa=new Wm(Math.max(2*Ha,fi));Qa.set(Ft),Ft=Qa}},Is=Pt.f||0,us=Pt.p||0,as=Pt.b||0,Ls=Pt.l,Ks=Pt.d,$s=Pt.m,Pr=Pt.n,lr=8*Wt;do{if(!Ls){Is=Zf(St,us,1);var pr=Zf(St,us+1,3);if(us+=3,!pr){var wr=St[(ms=4+((us+7)/8|0))-4]|St[ms-3]<<8,Wn=ms+wr;if(Wn>Wt){vs&&Yf(0);break}ys&&Es(as+wr),Ft.set(St.subarray(ms,Wn),as),Pt.b=as+=wr,Pt.p=us=8*Wn,Pt.f=Is;continue}if(pr==1)Ls=jrt,Ks=krt,$s=9,Pr=5;else if(pr==2){var qs=Zf(St,us,31)+257,jr=Zf(St,us+10,15)+4,hn=qs+Zf(St,us+5,31)+1;us+=14;for(var ua=new Wm(hn),fa=new Wm(19),Mn=0;Mn>4)<16)ua[Mn++]=ms;else{var nr=0,ar=0;for(ms==16?(ar=3+Zf(St,us,3),us+=2,nr=ua[Mn-1]):ms==17?(ar=3+Zf(St,us,7),us+=3):ms==18&&(ar=11+Zf(St,us,127),us+=7);ar--;)ua[Mn++]=nr}}var Ir=ua.subarray(0,qs),zr=ua.subarray(qs);$s=pue(Ir),Pr=pue(zr),Ls=bA(Ir,$s),Ks=bA(zr,Pr)}else Yf(1);if(us>lr){vs&&Yf(0);break}}ys&&Es(as+131072);for(var kn=(1<<$s)-1,Fn=(1<>4;if((us+=15&nr)>lr){vs&&Yf(0);break}if(nr||Yf(2),na<256)Ft[as++]=na;else{if(na==256){Vn=us,Ls=null;break}var en=na-254;na>264&&(en=Zf(St,us,(1<<(Ra=XNe[Mn=na-257]))-1)+tSe[Mn],us+=Ra);var cn=Ks[fue(St,us)&Fn],Ca=cn>>4;if(cn||Yf(3),us+=15&cn,zr=wrt[Ca],Ca>3){var Ra=QNe[Ca];zr+=fue(St,us)&(1<lr){vs&&Yf(0);break}ys&&Es(as+131072);var Fa=as+en;if(asDs.length)&&(Fs=Ds.length),new Wm(Ds.subarray(0,Fs))):Ft.subarray(0,as)}(Ye.subarray(st,-8),{i:2},new Wm(((Te=Ye)[(Ue=Te.length)-4]|Te[Ue-3]<<8|Te[Ue-2]<<16|Te[Ue-1]<<24)>>>0))));var Te,Ue,Ye,st;const _t=Mrt[Ee];if(!_t)throw new Error(`Unhandled codec: ${Ee}`);const ft=new globalThis.DecompressionStream(_t);return new Response(new Blob([we]).stream().pipeThrough(ft)).arrayBuffer().then(St=>new Uint8Array(St))}(ne,ee).then(we=>(function(Ee,Te){Ee.readFields(prt,Te)}(new gue(we),ie),new Art[O](ie.buffer))),ue.then(we=>{for(let Ee=J.length-1;Ee>=0;Ee--)switch(J[Ee]){case"delta_filter":grt(we,B);break;case"zigzag_filter":xrt(we);break;case"bitshuffle_filter":yrt(we,O);break;default:throw new Rp(`Unhandled filter "${J[Ee]}"`)}return{layerName:k,blockIndex:W,data:we}}).catch(we=>{throw we})}))},vr(iSe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),vr(DO,"MapboxRasterTile"),vr(aSe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class oSe{constructor(c){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&ne[3]>=0&&W.insert(B,ne[0],ne[1],ne[2],ne[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Xt(new uO(this.rawTileData)).layers,this.sourceLayerCoder=new oSe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const c in this.vtLayers)this.vtFeatures[c]=[]}return this.vtLayers}query(c,m){const{tilespaceGeometry:y,transform:k,tileTransform:E,pixelPosMatrix:P,availableImages:O,worldview:B}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const W=m.queryRadius?m.queryRadius:0,J=y.bufferedTilespaceBounds,ee=this.grid.query(J.min.x,J.min.y,J.max.x,J.max.y,(we,Ee,Te,Ue)=>Zd(y.bufferedTilespaceGeometry,we-W,Ee-W,Te+W,Ue+W));ee.sort(Ert);let ne=null;k.elevation&&ee.length>0&&(ne=AC.create(k.elevation,this.tileID));const ie={};let ue;for(let we=0;we(Ue||(Ue=Et(Ye,this.tileID.canonical,E)),st.queryIntersectsFeature(y,Ye,_t,Ue,this.z,k,P,ne,ft)))}return ie}loadMatchingFeature(c,m,y,k,E,P){const{featureIndex:O,bucketIndex:B,sourceLayerIndex:W,layoutVertexArrayOffset:J}=m,ee=this.bucketLayerIDs[B],ne=y.layers,ie=Object.keys(ne);if(ie.length&&!hr(ie,ee))return;const ue=y.sourceCache,we=this.sourceLayerCoder.decode(W),Ee=this.vtLayers[we].feature(O),Te=this.getId(Ee,we);for(let Ue=0;Ue`${O.key}: ${O.message}`).join(", ");return void cr(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=E.value}y=this.promoteIdExpression.evaluate({zoom:0},c)}else y=c.properties[k];typeof y=="boolean"&&(y=Number(y))}return y}}function cSe(p,c,m,y,k){return Jt(p,(E,P)=>{const O=c instanceof Sy?c.get(P):null;return O&&O.evaluate?O.evaluate(m,y,void 0,k):O})}function Ert(p,c){return c-p}vr(lSe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const dSe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class xue{static from(c){if(!(c instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[m,y]=new Uint8Array(c,0,2);if(m!==219)throw new Error("Data does not appear to be in a KDBush format.");const k=y>>4;if(k!==1)throw new Error(`Got v${k} data when expected v1.`);const E=dSe[15&y];if(!E)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(c,2,1),[O]=new Uint32Array(c,4,1);return new xue(O,P,E,c)}constructor(c,m=64,y=Float64Array,k){if(isNaN(c)||c<0)throw new Error(`Unpexpected numItems value: ${c}.`);this.numItems=+c,this.nodeSize=Math.min(Math.max(+m,2),65535),this.ArrayType=y,this.IndexArrayType=c<65536?Uint16Array:Uint32Array;const E=dSe.indexOf(this.ArrayType),P=2*c*this.ArrayType.BYTES_PER_ELEMENT,O=c*this.IndexArrayType.BYTES_PER_ELEMENT,B=(8-O%8)%8;if(E<0)throw new Error(`Unexpected typed array class: ${y}.`);k&&k instanceof ArrayBuffer?(this.data=k,this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+O+B,2*c),this._pos=2*c,this._finished=!0):(this.data=new ArrayBuffer(8+P+O+B),this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+O+B,2*c),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]=c)}add(c,m){const y=this._pos>>1;return this.ids[y]=y,this.coords[this._pos++]=c,this.coords[this._pos++]=m,y}finish(){const c=this._pos>>1;if(c!==this.numItems)throw new Error(`Added ${c} items when expected ${this.numItems}.`);return yue(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(c,m,y,k){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:E,coords:P,nodeSize:O}=this,B=[0,E.length-1,0],W=[];for(;B.length;){const J=B.pop()||0,ee=B.pop()||0,ne=B.pop()||0;if(ee-ne<=O){for(let Ee=ne;Ee<=ee;Ee++){const Te=P[2*Ee],Ue=P[2*Ee+1];Te>=c&&Te<=y&&Ue>=m&&Ue<=k&&W.push(E[Ee])}continue}const ie=ne+ee>>1,ue=P[2*ie],we=P[2*ie+1];ue>=c&&ue<=y&&we>=m&&we<=k&&W.push(E[ie]),(J===0?c<=ue:m<=we)&&(B.push(ne),B.push(ie-1),B.push(1-J)),(J===0?y>=ue:k>=we)&&(B.push(ie+1),B.push(ee),B.push(1-J))}return W}within(c,m,y){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:k,coords:E,nodeSize:P}=this,O=[0,k.length-1,0],B=[],W=y*y;for(;O.length;){const J=O.pop()||0,ee=O.pop()||0,ne=O.pop()||0;if(ee-ne<=P){for(let Ee=ne;Ee<=ee;Ee++)hSe(E[2*Ee],E[2*Ee+1],c,m)<=W&&B.push(k[Ee]);continue}const ie=ne+ee>>1,ue=E[2*ie],we=E[2*ie+1];hSe(ue,we,c,m)<=W&&B.push(k[ie]),(J===0?c-y<=ue:m-y<=we)&&(O.push(ne),O.push(ie-1),O.push(1-J)),(J===0?c+y>=ue:m+y>=we)&&(O.push(ie+1),O.push(ee),O.push(1-J))}return B}}function yue(p,c,m,y,k,E){if(k-y<=m)return;const P=y+k>>1;uSe(p,c,P,y,k,E),yue(p,c,m,y,P-1,1-E),yue(p,c,m,P+1,k,1-E)}function uSe(p,c,m,y,k,E){for(;k>y;){if(k-y>600){const W=k-y+1,J=m-y+1,ee=Math.log(W),ne=.5*Math.exp(2*ee/3),ie=.5*Math.sqrt(ee*ne*(W-ne)/W)*(J-W/2<0?-1:1);uSe(p,c,m,Math.max(y,Math.floor(m-J*ne/W+ie)),Math.min(k,Math.floor(m+(W-J)*ne/W+ie)),E)}const P=c[2*m+E];let O=y,B=k;for(jA(p,c,y,m),c[2*k+E]>P&&jA(p,c,y,k);OP;)B--}c[2*y+E]===P?jA(p,c,y,B):(B++,jA(p,c,B,k)),B<=m&&(y=B+1),m<=B&&(k=B-1)}}function jA(p,c,m,y){vue(p,m,y),vue(c,2*m,2*y),vue(c,2*m+1,2*y+1)}function vue(p,c,m){const y=p[c];p[c]=p[m],p[m]=y}function hSe(p,c,m,y){const k=p-m,E=c-y;return k*k+E*E}i.$=dS,i.A=Af,i.B=qm,i.C=2,i.D=xC,i.E=Ns,i.F=nA,i.G=Fke,i.H=cS,i.I=Hs,i.J=CD,i.K=Er,i.L=av,i.M=LS,i.N=ub,i.O=pD,i.P=rs,i.Q=hb,i.R=Cf,i.S=VS,i.T=Cde,i.U=ix,i.V=CO,i.W=uT,i.X=dv,i.Y=cv,i.Z=ab,i._=Wd,i.a=function(p){return ta.API_CDN_URL_REGEX.test(p)},i.a$=me,i.a0=ln,i.a1=Jn,i.a2=Pp,i.a3=class extends CO{},i.a4=DS,i.a5=mD,i.a6=Gt,i.a7=function(p){const c=p.value;return c?ln(c)?nue(c,!0)?[]:[new CO(p.key,c,`invalid url "${c}"`)]:[new CO(p.key,c,`string expected, "${Er(c)}" found`)]:[]},i.a8=jD,i.a9=_o,i.aA=Se,i.aB=S,i.aC=ht,i.aD=dd,i.aE=_i,i.aF=V,i.aG=et,i.aH=function(p,c){const m={};for(let y=0;y{y(E,P)},c):y(E,P),()=>{}}return k.callbacks.push(y),k.cancel||(k.cancel=m((E,P)=>{k.result=[E,P];for(const O of k.callbacks)this.scheduler?this.scheduler.add(()=>{O(E,P)},c):O(E,P);setTimeout(()=>delete this.entries[p],3e3)})),()=>{k.result||(k.callbacks=k.callbacks.filter(E=>E!==y),k.callbacks.length||(k.cancel(),delete this.entries[p]))}}},i.aL=function(p,c,m){const y=JSON.stringify(p.request);return p.data&&(this.deduped.entries[y]={result:[null,p.data]}),this.deduped.request(y,{type:"parseTile",isSymbolTile:p.isSymbolTile,zoom:p.tileZoom},k=>{const E=Ru(p.request,(P,O,B)=>{P?k(P):O&&k(null,{rawData:O,vectorTile:m?void 0:new Xt(new uO(O)),responseHeaders:new Map(B.entries())})});return()=>{E.cancel(),k()}},c)},i.aM=function(p){return p?{cacheControl:p.get("Cache-Control"),expires:p.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=ul,i.aO=function(p){Yc++,Yc>ev&&(p.getActor().send("enforceCacheSizeLimit",J0),Yc=0)},i.aP=function(p){return p<=1?1:Math.pow(2,Math.floor(Math.log2(p)))},i.aQ=fo,i.aR=mNe,i.aS=vNe,i.aT=x,i.aU=hNe,i.aV=function(p,c){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){c(null,m)};for(let y=0;y{}}},i.aW=JT,i.aX=Ob,i.aY=qt,i.aZ=lA,i.a_=ae,i.aa=Us,i.ab=class{constructor(p){this.specification=p}possiblyEvaluate(p,c){return wn(p.expression.evaluate(c))}interpolate(p,c,m){return{x:Ur(p.x,c.x,m),y:Ur(p.y,c.y,m),z:Ur(p.z,c.z,m),azimuthal:Ur(p.azimuthal,c.azimuthal,m),polar:Ur(p.polar,c.polar,m)}}},i.ac=Ii,i.ad=jy,i.ae=Xe,i.af=Rt,i.ag=ce,i.ah=ze,i.ai=Sy,i.aj=Tv,i.ak=Ur,i.al=Gs,i.am=gy,i.an=Jr,i.ao=Fr,i.ap=class{constructor(p){this.specification=p}possiblyEvaluate(p,c){return function([m,y]){const k=wn([1,m,y]);return{x:k.x,y:k.y,z:k.z}}(p.expression.evaluate(c))}interpolate(p,c,m){return{x:Ur(p.x,c.x,m),y:Ur(p.y,c.y,m),z:Ur(p.z,c.z,m)}}},i.aq=function(p,c,m=0,y=!0){const k=new rs(m,m),E=p.sub(k),P=c.add(k),O=[E,new rs(P.x,E.y),P,new rs(E.x,P.y)];return y&&O.push(E.clone()),O},i.ar=function(p,c){const m=[];for(let y=0;y1)return!1;const m=c.getSource().maxzoom,y=1<1)return c;const k=y.getSource().maxzoom,E=1<{const O=this.getAtTileOffset(p,k,E,P),B=y.upVector(p.canonical,k.x,k.y);return ke(B,B,O*y.upVectorScale(p.canonical,c,m).metersToTile),B}}getForTilePoints(p,c,m,y){if(this.isUsingMockSource())return!1;const k=AC.create(this,p,y);return!!k&&(c.forEach(E=>{E[2]=this.exaggeration()*k.getElevationAt(E[0],E[1],m)}),!0)}getMinMaxForTile(p){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(p);if(!c||!c.dem)return null;const m=c.dem.tree,y=c.tileID,k=1<0&&(y+=(p[k]-0)*(p[k]-0)),c[k]<0&&(y+=(0-c[k])*(0-c[k]));return y},i.c0=mje,i.c1=qde,i.c2=Hke,i.c3=Yde,i.c4=xue,i.c5=ke,i.c6=He,i.c7=qe,i.c8=function(p,c,m){m*=.5;var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return p[0]=y*B+k*O,p[1]=k*B-y*O,p[2]=E*B+P*O,p[3]=P*B-E*O,p},i.c9=Je,i.cA=te,i.cB=Va,i.cC=Xje,i.cD=bi,i.cE=M2e,i.cF=function(p,c,m,y,k,E,P,O,B){if(B.name==="globe")return M2e(p,c,new bi(m,y,k),!1);const W=lA({z:m,x:y,y:k},B);return new Tr([(E+W.x/W.scale)*c,c*(W.y/W.scale),P],[(E+W.x2/W.scale)*c,c*(W.y2/W.scale),O])},i.cG=function(p,c,m){return p[0]=Math.min(c[0],m[0]),p[1]=Math.min(c[1],m[1]),p[2]=Math.min(c[2],m[2]),p[3]=Math.min(c[3],m[3]),p},i.cH=function(p,c,m){return p[0]=Math.max(c[0],m[0]),p[1]=Math.max(c[1],m[1]),p[2]=Math.max(c[2],m[2]),p[3]=Math.max(c[3],m[3]),p},i.cI=function(p){const c=Math.round((p+45+360)%360/90)%4;return Dl[c]},i.cJ=pe,i.cK=We,i.cL=pC,i.cM=function(p){const c=j(new Float64Array(16));S(c,p.pixelMatrix,p.globeMatrix);const m=[0,nm,0],y=[0,am,0];return Rt(m,m,c),Rt(y,y,c),[m[0]>0&&m[0]<=p.width&&m[1]>0&&m[1]<=p.height&&!nde(p,new x(p.center.lat,90)),y[0]>0&&y[0]<=p.width&&y[1]>0&&y[1]<=p.height&&!nde(p,new x(p.center.lat,-90))]},i.cN=function(p,c){const{scale:m}=p.tileTransform,y=m*Gs/(p.tileSize*Math.pow(2,c.zoom-p.tileID.overscaledZ+p.tileID.canonical.z));return function(k,E,P){var O=E[1],B=E[2],W=E[3],J=P[0],ee=P[1];return k[0]=E[0]*J,k[1]=O*J,k[2]=B*ee,k[3]=W*ee,k}(new Float32Array(4),c.inverseAdjustmentMatrix,[y,y])},i.cO=aO,i.cP=se,i.cQ=Yje,i.cR=function(p){const c=Yje(p,!0);return f([],[c[0],c[1],c[4],c[5]])},i.cS=I,i.cT=or,i.cU=L,i.cV=function(p){const{x:c,y:m}=p.point,{lng:y,lat:k}=p._center;return E2e(c,m,p.worldSize,y,k)},i.cW=be,i.cX=Ka,i.cY=lo,i.cZ=Qc,i.c_=rm,i.ca=Ua,i.cb=function(p,c){return p[0]=-c[0],p[1]=-c[1],p[2]=-c[2],p[3]=c[3],p},i.cc=Q,i.cd=function(p,c,m,y,k){var E=1/Math.tan(c/2);if(p[0]=E/m,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=E,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[11]=-1,p[12]=0,p[13]=0,p[15]=0,k!=null&&k!==1/0){var P=1/(y-k);p[10]=(k+y)*P,p[14]=2*k*y*P}else p[10]=-1,p[14]=-2*y;return p},i.ce=function(p,c,m,y,k,E,P){var O=1/(c-m),B=1/(y-k),W=1/(E-P);return p[0]=-2*O,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=-2*B,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=2*W,p[11]=0,p[12]=(c+m)*O,p[13]=(k+y)*B,p[14]=(P+E)*W,p[15]=1,p},i.cf=re,i.cg=function(p,c,m){p[4*c+0]=m[0],p[4*c+1]=m[1],p[4*c+2]=m[2],p[4*c+3]=m[3]},i.ch=dC,i.ci=bb,i.cj=vl,i.ck=Dp,i.cl=jb,i.cm=sNe,i.cn=function(){var p=new u(4);return u!=Float32Array&&(p[1]=0,p[2]=0),p[0]=1,p[3]=1,p},i.co=function(p,c,m){var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return p[0]=y*B+E*O,p[1]=k*B+P*O,p[2]=y*-O+E*B,p[3]=k*-O+P*B,p},i.cp=function(p,c){return p[0]===c[0]&&p[1]===c[1]&&p[2]===c[2]&&p[3]===c[3]},i.cq=rt,i.cr=function(p){var c=p[0],m=p[1],y=p[2],k=p[3];return Math.sqrt(c*c+m*m+y*y+k*k)},i.cs=Qt,i.ct=Qe,i.cu=Ho,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=Le,i.d=function(p){return ta.API_TILEJSON_REGEX.test(p)},i.d$=class{constructor(p,c,m,y){this.context=p,this.format=y,this.size=m,this.texture=p.gl.createTexture();const[k,E,P]=this.size,{gl:O}=p;O.bindTexture(O.TEXTURE_3D,this.texture),p.pixelStoreUnpackFlipY.set(!1),p.pixelStoreUnpack.set(1),p.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&O.texImage3D(O.TEXTURE_3D,0,this.format,k,E,P,0,Nde(this.format),Sde(this.format),c.data)}bind(p,c){const{context:m}=this,{gl:y}=m;y.bindTexture(y.TEXTURE_3D,this.texture),p!==this.minFilter&&(y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MAG_FILTER,p),y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MIN_FILTER,p),this.minFilter=p),c!==this.wrapS&&(y.texParameteri(y.TEXTURE_3D,y.TEXTURE_WRAP_S,c),y.texParameteri(y.TEXTURE_3D,y.TEXTURE_WRAP_T,c),this.wrapS=c)}destroy(){const{gl:p}=this.context;p.deleteTexture(this.texture),this.texture=null}},i.d0=function(p){return p*p*p*p*p},i.d1=z,i.d2=45,i.d3=uC,i.d4=function(p,c,m){const y=Math.sqrt(p*p+c*c+m*m),k=y>0?Math.acos(m/y)*qa:0;let E=p!==0||c!==0?Math.atan2(-c,-p)*qa+90:0;return E<0&&(E+=360),[y,E,k]},i.d5=oe,i.d6=wn,i.d7=Be,i.d8=de,i.d9=Tr,i.dA=function(p){return p({pluginStatus:Gd,pluginURL:Of}),qS.on("pluginStateChange",p),p},i.dB=wb,i.dC=class extends zf{constructor(p){super(p),this.current=hC}set(p,c,m){if(this.fetchUniformLocation(p,c)){for(let y=0;y<9;y++)if(m[y]!==this.current[y]){this.current=m,this.gl.uniformMatrix3fv(this.location,!1,m);break}}}},i.dD=Lo,i.dE=function(p,c,m){const y=Tv(m.zoom),k=p.style.map._antialias,E=p.terrain&&p.terrain.exaggeration()>0;return y===0&&!k&&!E},i.dF=function(p){const c=p.pixelsPerMeter,m=c/re(1,p.center.lat),y=j(new Float64Array(16));return A(y,y,[p.point.x,p.point.y,0]),I(y,y,[m,m,c]),Float32Array.from(y)},i.dG=UD,i.dH=function(p){const c=pe-5;p=Se(p,-c,c)/c*90;const m=Math.pow(Math.abs(Math.sin(Jr(p))),3);return Math.round(m*(OT.length-1))},i.dI=function(p,c,m,y){const k=c.getNorth(),E=c.getSouth(),P=c.getWest(),O=c.getEast(),B=1<0){const ue=180/y;_(ie,ie,[ue/W+1,0,0,0,ue/J+1,0,-.5*ue/ee,.5*ue/ne,1])}return ie[2]=B,ie[5]=p.x,ie[8]=p.y,ie},i.dJ=Hm,i.dK=function(p,c,m){const y=j(new Float64Array(16)),k=(c/(1<({u_matrix:new jb(p),u_texsize:new Dp(p),u_pixels_to_tile_units:new mC(p),u_device_pixel_ratio:new vl(p),u_width_scale:new vl(p),u_floor_width_scale:new vl(p),u_image:new dC(p),u_units_to_pixels:new Dp(p),u_tile_units_to_pixels:new vl(p),u_alpha_discard_threshold:new vl(p),u_trim_offset:new Dp(p),u_trim_fade_range:new Dp(p),u_trim_color:new uC(p),u_zbias_factor:new vl(p),u_tile_to_meter:new vl(p),u_ground_shadow_factor:new bb(p),u_pattern_transition:new vl(p)}),i.dX=p=>({u_matrix:new jb(p),u_pixels_to_tile_units:new mC(p),u_device_pixel_ratio:new vl(p),u_width_scale:new vl(p),u_floor_width_scale:new vl(p),u_units_to_pixels:new Dp(p),u_dash_image:new dC(p),u_gradient_image:new dC(p),u_image_height:new vl(p),u_texsize:new Dp(p),u_tile_units_to_pixels:new vl(p),u_alpha_discard_threshold:new vl(p),u_trim_offset:new Dp(p),u_trim_fade_range:new Dp(p),u_trim_color:new uC(p),u_zbias_factor:new vl(p),u_tile_to_meter:new vl(p),u_ground_shadow_factor:new bb(p)}),i.dY=p=>({u_camera_to_center_distance:new vl(p),u_extrude_scale:new mC(p),u_device_pixel_ratio:new vl(p),u_matrix:new jb(p),u_inv_rot_matrix:new jb(p),u_merc_center:new Dp(p),u_tile_id:new bb(p),u_zoom_transition:new vl(p),u_up_dir:new bb(p),u_emissive_strength:new vl(p)}),i.dZ=tC,i.d_=qtt,i.da=xe,i.db=function(p){return[Math.pow(p[0],1/2.2),Math.pow(p[1],1/2.2),Math.pow(p[2],1/2.2)]},i.dc=Zje,i.dd=Ide,i.de=eke,i.df=nue,i.dg=function(p,c){return p.readFields($st,{icons:[]},c)},i.dh=tO,i.di=SC,i.dj=Gde,i.dk=tv,i.dl=fb,i.dm=Kg,i.dn=sv,i.dp=xs,i.dq=function(p){const c=p.indexOf(Ty);return c>=0?p.slice(0,c):p},i.dr=function(p){return p.indexOf(Ty)>=0},i.ds=function(p){const c=p.lastIndexOf(Ty);return c>=0?p.slice(c+1):""},i.dt=function(p){const c=[],m=p.id;return m===void 0&&c.push({message:`layers.${m}: missing required property "id"`}),p.render===void 0&&c.push({message:`layers.${m}: missing required method "render"`}),p.renderingMode&&p.renderingMode!=="2d"&&p.renderingMode!=="3d"&&c.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),c},i.du=function(p,c,m,y){return p.type==="custom"?new Lst(p,c):new zst[p.type](p,c,m,y)},i.dv=Ps,i.dw=function(p){const c=p.indexOf(Ty);return c>=0?p.slice(c+1):""},i.dx=class extends Db{constructor(p,c){super(p._vectorTileFeature,p._z,p._x,p._y,p.id),p.state&&(this.state=Object.assign({},p.state)),this.target=c.target,this.namespace=c.namespace,c.properties&&(this.properties=c.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=p.source,this.sourceLayer=p.sourceLayer,this.layer=p.layer)}toJSON(){const p=super.toJSON();return p.target=this.target,p.namespace=this.namespace,p}},i.dy=qS,i.dz=Mf,i.e=ta,i.e$=le,i.e0=L2e,i.e1=(p,c,m,y,k,E)=>{const P=p.transform,O=P.projection.name==="globe";let B;if(E.paint.get("circle-pitch-alignment")==="map")if(O){const J=A2e(P.zoom,c.canonical)*P._pixelsPerMercatorPixel;B=Float32Array.from([J,0,0,J])}else B=P.calculatePixelsToTileUnitsMatrix(m);else B=new Float32Array([P.pixelsToGLUnits[0],0,0,P.pixelsToGLUnits[1]]);const W={u_camera_to_center_distance:p.transform.getCameraToCenterDistance(P.projection),u_matrix:p.translatePosMatrix(c.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:xl.devicePixelRatio,u_extrude_scale:B,u_inv_rot_matrix:set,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){W.u_inv_rot_matrix=y,W.u_merc_center=k,W.u_tile_id=[c.canonical.x,c.canonical.y,1<{const J=p.transform,ee=J.pitch<15?mke(.07,.7,Se((14-J.zoom)/5,0,1)):.07,ne=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:fke(p,c,m,y),u_texsize:c.imageAtlasTexture?c.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:J.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:k,u_width_scale:E,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:pke(c,J),u_units_to_pixels:[1/J.pixelsToGLUnits[0],1/J.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(ne?null:m.lut).toArray01(),u_zbias_factor:ee,u_tile_to_meter:Be(c.tileID.canonical,0),u_ground_shadow_factor:B,u_pattern_transition:W}},i.e5=(p,c,m,y,k,E,P,O,B,W)=>{const J=p.transform,ee=J.calculatePixelsToTileUnitsMatrix(c),ne=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",ie=J.pitch<15?mke(.07,.7,Se((14-J.zoom)/5,0,1)):.07;return{u_matrix:fke(p,c,m,y),u_pixels_to_tile_units:ee,u_device_pixel_ratio:E,u_width_scale:P,u_floor_width_scale:O,u_units_to_pixels:[1/J.pixelsToGLUnits[0],1/J.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:k,u_texsize:xke(m)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:pke(c,p.transform),u_alpha_discard_threshold:0,u_trim_offset:B,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ne?null:m.lut).toArray01(),u_zbias_factor:ie,u_tile_to_meter:Be(c.tileID.canonical,0),u_ground_shadow_factor:W}},i.e6=Yt,i.e7=FT,i.e8=he,i.e9=om,i.eA=function(p,c){var m=2*Math.acos(c[3]),y=Math.sin(m/2);return y>d?(p[0]=c[0]/y,p[1]=c[1]/y,p[2]=c[2]/y):(p[0]=1,p[1]=0,p[2]=0),m},i.eB=oue,i.eC=lO,i.eD=oO,i.eE=[1,1,1],i.eF=AC,i.eG=ct,i.eH=function(p,c,m,y){var k=c[0],E=c[1],P=c[2],O=c[3];return p[0]=k+y*(m[0]-k),p[1]=E+y*(m[1]-E),p[2]=P+y*(m[2]-P),p[3]=O+y*(m[3]-O),p},i.eI=bC,i.eJ=hh,i.eK=Lp,i.eL=function(p,c,m,y,k,E,P,O,B,W,J,ee,ne,ie,ue,we){var Ee=new u(16);return Ee[0]=p,Ee[1]=c,Ee[2]=m,Ee[3]=y,Ee[4]=k,Ee[5]=E,Ee[6]=P,Ee[7]=O,Ee[8]=B,Ee[9]=W,Ee[10]=J,Ee[11]=ee,Ee[12]=ne,Ee[13]=ie,Ee[14]=ue,Ee[15]=we,Ee},i.eM=C,i.eN=jv,i.eO=ST,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new rs(1/0,1/0),max:new rs(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(p,c=!1){const m=dje(new rs(0,0),new rs(Gs,Gs),p),y=[];if(c&&!mde(m,this._globalClipBounds))return y;for(const k of this._activeRegions){if(k.hiddenByOverlap||!mde(m,k))continue;const E=Iet(k.min,k.max,p);y.push({min:E.min,max:E.max,sourceId:this._sourceIds[k.priority],footprint:k.footprint,footprintTileId:k.tileId,order:k.order,clipMask:k.clipMask,clipScope:k.clipScope})}return y}setSources(p){this._setSources(p.map(c=>({getSourceId:()=>c.cache.id,getFootprints:()=>{const m=[];for(const y of c.cache.getVisibleCoordinates()){const k=c.cache.getTile(y).buckets[c.layer];k&&k.updateFootprints(y.toUnwrapped(),m)}return m},getOrder:()=>c.order,getClipMask:()=>c.clipMask,getClipScope:()=>c.clipScope})))}_addSource(p){const c=p.getFootprints();if(c.length===0)return;const m=p.getOrder(),y=p.getClipMask(),k=p.getClipScope();for(const E of c){if(!E.footprint)continue;const P=dje(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:y,clipScope:k})}this._sourceIds.push(p.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,m)=>c.priority-m.priority||YD(c.min,m.min)||YD(c.max,m.max)||c.order-m.order||c.clipMask-m.clipMask||function(y,k){const E=(P,O)=>P+O;return y.length-k.length||y.reduce(E,"").localeCompare(k.reduce(E,""))}(c.clipScope,m.clipScope));let p=this._activeRegions.length!==this._prevRegions.length;if(!p){let c=0;for(;!p&&c!==this._activeRegions.length;){const m=this._activeRegions[c],y=this._prevRegions[c];p=m.priority!==y.priority||!cje(m,y)||m.order!==y.order||m.clipMask!==y.clipMask||!An(m.clipScope,y.clipScope),this._activeRegions[c].hiddenByOverlap=y.hiddenByOverlap,++c}}if(p){++this._updateTime;for(const m of this._activeRegions)m.order!==VT&&(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 c=m=>{const y=this._activeRegions;if(m>=y.length)return m;const k=y[m].priority;for(;m1){let m=0,y=c(m);for(;m!==y;){let k=m;const E=m;for(;k!==y;){const P=this._activeRegions[k];P.hiddenByOverlap=!1;for(let O=0;O=0;c--)this._addSource(p[c]);this._computeReplacement()}},i.eQ=VT,i.eR=class{constructor(p){this._createGrid(p),this._createPoles(p)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const p of this._poleSegments)p.destroy();for(const p of this._gridSegments)p.withSkirts.destroy(),p.withoutSkirts.destroy()}_fillGridMeshWithLods(p,c){const m=new lx,y=new yl,k=[],E=p+1+2,P=c[0]+1,O=c[0]+1+(1+c.length),B=(W,J,ee)=>{let ne=W===E-1?W-2:W===0?W:W-1;return ne+=ee?24575:0,[ne,J]};for(let W=0;W0?(Ee=2*Math.sqrt(we+1),p[3]=.25*Ee,p[0]=(ee-ie)/Ee,p[1]=(ne-B)/Ee,p[2]=(O-W)/Ee):P>J&&P>ue?(Ee=2*Math.sqrt(1+P-J-ue),p[3]=(ee-ie)/Ee,p[0]=.25*Ee,p[1]=(O+W)/Ee,p[2]=(ne+B)/Ee):J>ue?(Ee=2*Math.sqrt(1+J-P-ue),p[3]=(ne-B)/Ee,p[0]=(O+W)/Ee,p[1]=.25*Ee,p[2]=(ee+ie)/Ee):(Ee=2*Math.sqrt(1+ue-P-J),p[3]=(O-W)/Ee,p[0]=(ne+B)/Ee,p[1]=(ee+ie)/Ee,p[2]=.25*Ee),p},i.f=function(p){return btoa(encodeURIComponent(p).replace(/%([0-9A-F]{2})/g,(c,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([p,c,m]){const y=Math.hypot(p,c,m),k=Math.atan2(p,m),E=.5*Math.PI-Math.acos(-c/y);return new x(Ka(k),Ka(E))},i.f1=Ze,i.f2=Mde,i.f3=function(p){const c=p.navigator?p.navigator.userAgent:null;return!!function(m){if(zo==null){const y=m.navigator?m.navigator.userAgent:null;zo=!!m.safari||!(!y||!(/\b(iPad|iPhone|iPod)\b/.test(y)||y.match("Safari")&&!y.match("Chrome")))}return zo}(p)&&!(!c||!(c.match("Version/15.4")||c.match("Version/15.5")||c.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},i.f4=function(p,c){J0=p,ev=c},i.f5=nde,i.f6=P2e,i.f7=function(p){const c=[0,0,0],m=j(new Float64Array(16));return S(m,p.pixelMatrix,p.globeMatrix),Rt(c,c,m),new rs(c[0],c[1])},i.f8=function(){const p=YT;p&&(p.isPreloaded()&&p.numActive()===1?(p.release(vde),YT=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(){tO().acquire(vde)},i.fA=LO,i.fB=Ut,i.fC=function(p){let c=0;if(new Uint32Array(p,0,1)[0]!==Vje){const m=new Uint32Array(p,0,7),[,,y,k,E,P]=m;c=m.byteLength+k+E+P+E,(y!==p.byteLength||c>=p.byteLength)&&cr("Invalid b3dm header information.")}return Kje(p,c)},i.fD=function(p,c){const m=Ide(p);for(const y of m){for(const k of y.meshes)dtt(k);y.lights&&(y.lightMeshIndex=y.meshes.length,y.meshes.push(utt(y.lights,c)))}return m},i.fE=MO,i.fF=ca,i.fG=zje,i.fH=Rf,i.fI=Fu,i.fJ=function(p){ld(),ih!=null&&ih.then(c=>{c.keys().then(m=>{for(let y=0;ycr(k.message))}).catch(m=>cr(m.message))}).catch(c=>cr(c.message))},i.fa=gb,i.fb=function(p,c,m=!1){if(Gd===Fu.deferred||Gd===Fu.loading||Gd===Fu.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Of=xl.resolveURL(p),Gd=Fu.deferred,fT=c,$S(),m||wD()},i.fc=function(p){yC=xl.resolveURL(p),vC||(vC=new xC(tO(),new Ns)),vC.broadcast("setMeshoptUrl",yC)},i.fd=qje,i.fe=function(p){wde=xl.resolveURL(p),vC||(vC=new xC(tO(),new Ns)),vC.broadcast("setDracoUrl",wde)},i.ff=$je,i.fg=ZT,i.fh=function(p){const c=oh();if(!c)return;const m=c.delete(Q0);p&&m.then(()=>p()).catch(p)},i.fi=Ab,i.fj=vr,i.fk=Av,i.fl=Kf,i.fm=oSe,i.fn=lSe,i.fo=cke,i.fp=ls,i.fq="hd_road_elevation",i.fr=Ya,i.fs=Jt,i.ft=Iy,i.fu=Wde,i.fv=Ib,i.fw=function(p,c,m,y,k,E,P,O=1,B,W,J){p.createArrays(),p.tilePixelRatio=Gs/(512*p.overscaling),p.compareText={},p.iconsNeedLinear=!1;const ee=p.layers[0].layout,ne=p.layers[0]._unevaluatedLayout._values,ie={};ie.scaleFactor=O,ie.textSizeScaleRange=ee.get("text-size-scale-range"),ie.iconSizeScaleRange=ee.get("icon-size-scale-range");const[ue,we]=ie.textSizeScaleRange,[Ee,Te]=ie.iconSizeScaleRange;ie.textScaleFactor=Se(ie.scaleFactor,ue,we),ie.iconScaleFactor=Se(ie.scaleFactor,Ee,Te);const Ue=ne["text-size"],Ye=ne["icon-size"];if(p.textSizeData.kind==="composite"){const{minZoom:Ft,maxZoom:ns}=p.textSizeData;ie.compositeTextSizes=[Ue.possiblyEvaluate(new Ii(Ft,{worldview:J}),E),Ue.possiblyEvaluate(new Ii(ns,{worldview:J}),E)]}if(p.iconSizeData.kind==="composite"){const{minZoom:Ft,maxZoom:ns}=p.iconSizeData;ie.compositeIconSizes=[Ye.possiblyEvaluate(new Ii(Ft,{worldview:J}),E),Ye.possiblyEvaluate(new Ii(ns,{worldview:J}),E)]}ie.layoutTextSize=Ue.possiblyEvaluate(new Ii(P+1,{worldview:J}),E),ie.layoutIconSize=Ye.possiblyEvaluate(new Ii(P+1,{worldview:J}),E),ie.textMaxSize=Ue.possiblyEvaluate(new Ii(18,{worldview:J}),E);const st=ee.get("symbol-placement"),_t=ee.get("text-rotation-alignment")==="map"&&st!=="point",ft=ee.get("text-size");let St=!1;const Pt=[];for(const Ft of p.features){const ns=ee.get("text-font").evaluate(Ft,{},E).join(","),Wt=ft.evaluate(Ft,{},E)*ie.textScaleFactor,hs=ie.layoutTextSize.evaluate(Ft,{},E)*ie.textScaleFactor,ys=ie.layoutIconSize.evaluate(Ft,{},E)*ie.iconScaleFactor,vs={horizontal:{},vertical:void 0},Ds=Ft.text;let Fs,Es=[0,0];if(Ds){const Mn=Ds.toString(),pi=ee.get("text-letter-spacing").evaluate(Ft,{},E)*rc,gt=ee.get("text-line-height").evaluate(Ft,{},E)*rc,wt=mT(Mn)?pi:0,ms=ee.get("text-anchor").evaluate(Ft,{},E),Os=ee.get("text-variable-anchor");if(!Os){const kn=ee.get("text-radial-offset").evaluate(Ft,{},E);if(kn)Es=Hke(ms,[kn*rc,Zde]);else{const Fn=ee.get("text-offset").evaluate(Ft,{},E);Es=[Fn[0]*rc,Fn[1]*rc]}}let nr=_t?"center":ee.get("text-justify").evaluate(Ft,{},E);const ar=st==="point",Ir=ar?ee.get("text-max-width").evaluate(Ft,{},E)*rc:1/0,zr=kn=>{p.allowVerticalPlacement&&pb(Mn)&&(vs.vertical=$de(Ds,c,m,k,ns,Ir,gt,ms,kn,wt,Es,fh.vertical,!0,hs,Wt,B))};if(!_t&&Os){const kn=nr==="auto"?Os.map(Vn=>Yde(Vn)):[nr];let Fn=!1;for(let Vn=0;Vn=0||!pb(Mn)){const kn=$de(Ds,c,m,k,ns,Ir,gt,ms,nr,wt,Es,fh.horizontal,!1,hs,Wt,B);kn&&(vs.horizontal[nr]=kn)}zr(ar?"left":nr)}}let Is,us,as,Ls,Ks,$s,Pr=!1;const lr=ee.get("icon-text-fit").evaluate(Ft,{},E);if(Ft.icon&&Ft.icon.hasPrimary()){const Mn=iA(Ft.icon,p.iconSizeData,ne["icon-size"],E,p.zoom,Ft,B,ie.iconScaleFactor,J);Is=Mn.iconPrimary,as=Mn.iconSecondary;const pi=Is.toString();if(us=y.get(pi),us&&(Ks=ee.get("icon-offset").evaluate(Ft,{},E),$s=ee.get("icon-anchor").evaluate(Ft,{},E),Fs=mO(k.get(pi),as?k.get(as.toString()):void 0,Ks,$s),Pr=us.sdf,p.sdfIcons===void 0?p.sdfIcons=us.sdf:p.sdfIcons!==us.sdf&&cr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(us.pixelRatio!==p.pixelRatio||ee.get("icon-rotate").constantOr(1)!==0)&&(p.iconsNeedLinear=!0)),as){const gt=as.toString();Ls=y.get(gt)}}St=St||!(!Ft.icon||!Ft.icon.hasSecondary());const pr=yO(vs.horizontal)||vs.vertical;p.iconsInText||(p.iconsInText=!!pr&&pr.iconsInText);const wr=hs*ie.textScaleFactor/rc,{defaultShapedIcon:Wn,verticallyShapedIcon:qs}=vst(p,Fs,ee,Ft,E,vs,wr,Ks,lr);lr!=="none"&&Fs&&(Ake(Fs)||Eke(Fs))&&(xO(0,us,Is,Fs,Wn,lr,W,y,k),xO(0,Ls,as,Fs,Wn,lr,W,y,k),qs&&(xO(0,us,Is,Fs,qs,lr,W,y,k),xO(0,Ls,as,Fs,qs,lr,W,y,k))),Fs=Wn;const{iconBBox:jr,iconVerticalBBox:hn,textBBox:ua,textVerticalBBox:fa}=pst(p,Fs,qs,ee,Ft,E,ys,Ks,ie,k,$s,vs,hs,Es);Pt.push({feature:Ft,shapedTextOrientations:vs,shapedText:pr,shapedIcon:Fs,iconPrimary:Is,iconSecondary:as,iconOffset:Ks,iconAnchor:$s,verticallyShapedIcon:qs,layoutTextSize:hs,layoutIconSize:ys,textOffset:Es,isSDFIcon:Pr,iconTextFit:lr,iconCollisionBounds:jr,iconVerticalCollisionBounds:hn,textCollisionBounds:ua,textVerticalCollisionBounds:fa})}return{featureData:Pt,sizes:ie,hasAnySecondaryIcon:St,textAlongLine:_t,symbolPlacement:st}},i.fx=zke,i.fy=function(p,c,m,y,k,E,P,O,B,W){p.iconAtlasPositions=W.iconPositions;const{featureData:J,hasAnySecondaryIcon:ee,sizes:ne,textAlongLine:ie,symbolPlacement:ue}=c;for(const we of J){const{shapedIcon:Ee,verticallyShapedIcon:Te,feature:Ue,shapedTextOrientations:Ye,shapedText:st,layoutTextSize:_t,textOffset:ft,isSDFIcon:St,iconPrimary:Pt,iconSecondary:Ft,iconTextFit:ns,iconOffset:Wt,iconCollisionBounds:hs,iconVerticalCollisionBounds:ys,textCollisionBounds:vs}=we;Gke(Ee,W.iconPositions,Pt,Ft),Gke(Te,W.iconPositions,Pt,Ft),yst(Ye,W.iconPositions),xst(Pt,Ft,W.iconPositions),(st||Ee)&&_st(p,Ue,Ye,Ee,Te,B,ne,_t,0,ft,St,y,k,P,O,ee,ns,Wt,ie,ue,hs,ys,vs)}m&&p.generateCollisionDebugBuffers(E,p.collisionBoxArray,ne.textScaleFactor)},i.fz=Xt,i.g=function(p,c){return Mf(Object.assign(p,{method:"GET"}),c)},i.h=function(p){return p.indexOf("mapbox:")===0},i.i=function(p){return ta.API_STYLE_REGEX.test(p)&&!tc(p)},i.j=Yi,i.k=Nd,i.l=function(p){return decodeURIComponent(atob(p).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(p,c){return Mf(Object.assign(p,{type:"json"}),c)},i.n=Zg,i.o=xl,i.p=function(p,c){return Mf(Object.assign(p,{method:"POST"}),c)},i.q=md,i.r=Zh,i.s=function(p){try{const c=self[p];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return _de||(_de=new Ab("ImageRasterizer")),_de},i.u=function(){return function p(c){return c?(c^Math.random()*(16>>c/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,p)}()},i.v=function(p){return!!p&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(p)},i.w=cr,i.x=mue,i.y=Yg,i.z=Qh}),o(["./shared"],function(i){function d(it){const Se=it?it.url.toString():void 0;return Se?performance.getEntriesByName(Se):[]}function u(it){if(typeof it=="number"||typeof it=="boolean"||typeof it=="string"||it==null)return JSON.stringify(it);if(Array.isArray(it)){let ze="[";for(const tt of it)ze+=`${u(tt)},`;return`${ze}]`}let Se="{";for(const ze of Object.keys(it).sort())Se+=`${ze}:${u(it[ze])},`;return`${Se}}`}function f(it){let Se="";for(const ze of i.bx)Se+=`/${u(it[ze])}`;return Se}class g{constructor(Se){this.keyCache={},this._layers={},this._layerConfigs={},Se&&this.replace(Se)}replace(Se,ze){this._layerConfigs={},this._layers={},this.update(Se,[],ze)}update(Se,ze,tt){this._options=tt;for(const Nt of Se)this._layerConfigs[Nt.id]=Nt,(this._layers[Nt.id]=i.du(Nt,this.scope,null,this._options)).compileFilter(tt),this.keyCache[Nt.id]&&delete this.keyCache[Nt.id];for(const Nt of ze)delete this.keyCache[Nt],delete this._layerConfigs[Nt],delete this._layers[Nt];this.familiesBySource={};const Mt=function(Nt,Ot){const Yt={};for(let Jt=0;Jtthis._layers[hr.id]),Yt=Ot[0];if(Yt.visibility==="none")continue;const qt=Yt.source||"";let Jt=this.familiesBySource[qt];Jt||(Jt=this.familiesBySource[qt]={});const Ps=Yt.sourceLayer||"_geojsonTileLayer";let xs=Jt[Ps];xs||(xs=Jt[Ps]=[]),xs.push(Ot)}}}const v=1*i.fl;class _{constructor(Se){const ze={},tt=[];for(const Yt in Se){const qt=Se[Yt],Jt=ze[Yt]={};for(const Ps in qt.glyphs){const xs=qt.glyphs[+Ps];if(!xs||xs.bitmap.width===0||xs.bitmap.height===0)continue;const hr=xs.metrics.localGlyph?v:1,Br={x:0,y:0,w:xs.bitmap.width+2*hr,h:xs.bitmap.height+2*hr};tt.push(Br),Jt[Ps]=Br}}const{w:Mt,h:Nt}=i.G(tt),Ot=new i.fk({width:Mt||1,height:Nt||1});for(const Yt in Se){const qt=Se[Yt];for(const Jt in qt.glyphs){const Ps=qt.glyphs[+Jt];if(!Ps||Ps.bitmap.width===0||Ps.bitmap.height===0)continue;const xs=ze[Yt][Jt],hr=Ps.metrics.localGlyph?v:1;i.fk.copy(Ps.bitmap,Ot,{x:0,y:0},{x:xs.x+hr,y:xs.y+hr},Ps.bitmap)}}this.image=Ot,this.positions=ze}}function b(it,Se,ze){it[Se]?ze&&(it[Se].center=ze):it[Se]={floorIds:new Set,center:ze||[0,0],floors:{}}}function w(it,Se,ze,tt){for(const Mt of Se)b(it,Mt),it[Mt].floors[ze]=tt,it[Mt].floorIds.add(ze)}function j(it){return{id:it.properties.id.toString(),center:it.properties.center.toString().split(";").map(Number)}}function N(it){return{id:it.properties.id.toString(),isDefault:!!it.properties.is_default&&it.properties.is_default,connections:it.properties.connected_floor_ids?new Set(it.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:it.properties.conflicted_floor_ids?new Set(it.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:it.properties.building_ids?new Set(it.properties.building_ids.toString().split(";")):new Set,name:it.properties.name.toString(),zIndex:it.properties.z_index}}function S(it,Se){return Se.every(ze=>it.properties&&it.properties[ze]!=null)}function A(it){return S(it,["type","id","name"])&&it.properties.type==="building"}function I(it){return S(it,["type","id","name","z_index"])&&it.properties.type==="floor"}i.fj(_,"GlyphAtlas");class L{constructor(Se){this.tileID=new i.aQ(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.lut=Se.lut,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.scope=Se.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Se.showCollisionBoxes,this.collectResourceTiming=!!Se.request&&Se.request.collectResourceTiming,this.promoteId=Se.promoteId,this.isSymbolTile=Se.isSymbolTile,this.tileTransform=i.aZ(Se.tileID.canonical,Se.projection),this.projection=Se.projection,this.worldview=Se.worldview,this.localizableLayerIds=Se.localizableLayerIds,this.brightness=Se.brightness,this.extraShadowCaster=!!Se.extraShadowCaster,this.tessellationStep=Se.tessellationStep,this.scaleFactor=Se.scaleFactor,this.worldview=Se.worldview,this.indoor=Se.indoor}parse(Se,ze,tt,Mt,Nt,Ot){this.status="parsing",this.data=Se,this.collisionBoxArray=new i.b3;const Yt=new i.fm(Object.keys(Se.layers).sort()),qt=new i.fn(this.tileID,this.promoteId);qt.bucketLayerIDs=[];const Jt={},Ps=new i.fo(256,256),xs={featureIndex:qt,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ps,availableImages:tt,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Nn=this.indoor.indoorState.activeFloorsVisible,Sn=function(wn,ca,ao){const zo=function(Ki,xa){if(!Ki)return i.w("No source layers defined in indoor specification"),xa;if(Ki.size===0)return xa;const Zi=Ki.difference(xa);for(const mi of Zi)i.w(`Missing source layer required in indoor specification: ${mi}`);return xa.intersection(xa)}(ca.sourceLayers,new Set(Object.keys(wn.layers))),Ua=ca.indoorState,Vo=function(Ki,xa,Zi,mi){const ta=new Set,Yi=new Set,tc=new Set,fc=new Map,jd={},kp=gl=>{const gu=fc.get(gl)||new Set;for(const Zc of ta)if((fc.get(Zc)||new Set).has(gl)||gu.has(Zc))return!0;return!1};for(const gl of xa){const gu=Ki.layers[gl];if(gu)for(let Zc=0;Zc=Zi.maxzoom||Zi.visibility==="none")continue;F(xa,this.zoom,xs.brightness,tt,this.worldview);const mi=Jt[Zi.id]=Zi.createBucket({index:qt.bucketLayerIDs.length,layers:xa,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:zo,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:Mt,worldview:this.worldview,localizable:Vo});qt.bucketLayerIDs.push(xa.map(Yi=>i.B(Yi.id,Yi.scope)));let ta=mi.prepare?mi.prepare():null;ta!=null?(ta=ta.then(()=>mi.populate(Ua,xs,this.tileID.canonical,this.tileTransform)),hr.push(ta)):mi.populate(Ua,xs,this.tileID.canonical,this.tileTransform)}}const cr=()=>{let Nn,Sn,wn,ca,ao,zo;Ps.trim();const Ua={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},Vo=()=>{if(Nn)return this.status="done",Ot(Nn);if(this.extraShadowCaster)this.status="done",Ot(null,{buckets:Object.values(Jt).filter(xa=>!xa.isEmpty()),featureIndex:qt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:xs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Sn&&wn&&ca){const xa=new _(Sn),Zi=new Map;for(const[Yi,tc]of wn.entries()){const{imagePosition:fc}=i.fu(Yi,tc,i.fv);Zi.set(Yi,fc)}const mi={};for(const Yi in Jt){const tc=Jt[Yi];tc instanceof i.b4&&(F(tc.layers,this.zoom,xs.brightness,tt,this.worldview),mi[Yi]=i.fw(tc,Sn,xa.positions,wn,Zi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,ao,this.worldview))}const ta={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(Nt,wn,ao,()=>{ta.iconsPending=!1,Ki(mi,xa,ta)}),this.rasterizeIfNeeded(Nt,ca,zo,()=>{ta.patternsPending=!1,Ki(mi,xa,ta)})}},Ki=(xa,Zi,mi,ta)=>{if(mi.iconsPending||mi.patternsPending)return;const Yi=new i.fx(wn,ca,this.lut);for(const tc in Jt){const fc=Jt[tc];if(tc in xa)i.fy(fc,xa[tc],this.showCollisionBoxes,tt,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,wn,Yi);else if(fc.hasPattern&&(fc instanceof i.ba||fc instanceof i.bb||fc instanceof i.ea)){F(fc.layers,this.zoom,xs.brightness,tt,this.worldview);const jd=Object.fromEntries(Yi.patternPositions);fc.addFeatures(xs,this.tileID.canonical,jd,tt,this.tileTransform,this.brightness)}}this.status="done",Ot(null,{buckets:Object.values(Jt).filter(tc=>!tc.isEmpty()),featureIndex:qt,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Zi.image,lineAtlas:Ps,imageAtlas:Yi,brightness:xs.brightness})};if(!this.extraShadowCaster){const xa=i.fs(xs.glyphDependencies,ta=>Object.keys(ta).map(Number));Object.keys(xa).length?Nt.send("getGlyphs",{uid:this.uid,stacks:xa},(ta,Yi)=>{Nn||(Nn=ta,Sn=Yi,Vo())},void 0,!1,Ua):Sn={};const Zi=Array.from(xs.iconDependencies.keys()).map(ta=>i.I.parse(ta));Zi.length?Nt.send("getImages",{images:Zi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ta,Yi)=>{Nn||(Nn=ta,wn=new Map,ao=this.updateImageMapAndGetImageTaskQueue(wn,Yi,xs.iconDependencies),Vo())},void 0,!1,Ua):(wn=new Map,ao=new Map);const mi=Array.from(xs.patternDependencies.keys()).map(ta=>i.I.parse(ta));mi.length?Nt.send("getImages",{images:mi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ta,Yi)=>{Nn||(Nn=ta,ca=new Map,zo=this.updateImageMapAndGetImageTaskQueue(ca,Yi,xs.patternDependencies),Vo())},void 0,!1,Ua):(ca=new Map,zo=new Map)}if(xs.elevationFeatures&&xs.elevationFeatures.length>0){const xa=[];for(const mi of Object.values(Jt))if(mi instanceof i.bb){const ta=mi.getUnevaluatedPortalGraph();ta&&xa.push(ta)}const Zi=i.ft.evaluate(xa);for(const mi of Object.values(Jt))if(mi instanceof i.bb){const ta=Se.layers[Yt.decode(mi.sourceLayerIndex)];mi.setEvaluatedPortalGraph(Zi,ta,this.tileID.canonical,xs.availableImages,xs.brightness)}}Vo()};hr.length>0?Promise.allSettled(hr).then(cr).catch(Ot):cr()}updateParameters(Se){this.scaleFactor=Se.scaleFactor,this.showCollisionBoxes=Se.showCollisionBoxes,this.projection=Se.projection,this.brightness=Se.brightness,this.tileTransform=i.aZ(Se.tileID.canonical,Se.projection),this.extraShadowCaster=Se.extraShadowCaster,this.lut=Se.lut,this.worldview=Se.worldview,this.indoor=Se.indoor}rasterizeIfNeeded(Se,ze,tt,Mt){Array.from(ze.values()).some(Nt=>Nt.usvg)?this.rasterize(Se,ze,tt,Mt):Mt()}updateImageMapAndGetImageTaskQueue(Se,ze,tt){const Mt=new Map;for(const Nt of ze.keys()){const Ot=tt.get(Nt)||[];for(const Yt of Ot){const qt=Yt.toString(),Jt=ze.get(Yt.id.toString());Jt.usvg?Mt.has(qt)||(Mt.set(qt,Yt),Se.set(qt,Object.assign({},Jt))):Se.set(qt,Jt)}}return Mt}rasterize(Se,ze,tt,Mt){this.rasterizeTask=Se.send("rasterizeImages",{scope:this.scope,tasks:tt},(Nt,Ot)=>{if(!Nt)for(const[Yt,qt]of Ot.entries()){const Jt=Object.assign(ze.get(Yt),{data:qt});ze.set(Yt,Jt)}Mt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function F(it,Se,ze,tt,Mt){const Nt=new i.ac(Se,{brightness:ze,worldview:Mt});for(const Ot of it)Ot.recalculate(Nt,tt)}class $ extends i.E{constructor(Se,ze,tt,Mt,Nt,Ot,Yt){super(),this.actor=Se,this.layerIndex=ze,this.availableImages=tt,this.availableModels=Mt,this.loadVectorData=Ot||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(Se.scheduler),this.isSpriteLoaded=Nt,this.scheduler=Se.scheduler,this.brightness=Yt}loadTile(Se,ze){const tt=Se.uid,Mt=Se&&Se.request,Nt=Mt&&Mt.collectResourceTiming,Ot=this.loading[tt]=new L(Se);Ot.abort=this.loadVectorData(Se,(Yt,qt)=>{const Jt=!this.loading[tt];if(delete this.loading[tt],Ot.cancelRasterize(),Jt||Yt||!qt)return Ot.status="done",Jt||(this.loaded[tt]=Ot),ze(Yt);const Ps=qt.rawData,xs={},hr=i.aM(qt.responseHeaders);hr&&hr.expires&&(xs.expires=hr.expires),hr&&hr.cacheControl&&(xs.cacheControl=hr.cacheControl),Ot.vectorTile=qt.vectorTile||new i.fz(new i.bt(Ps));const Br=()=>{Ot.parse(Ot.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(cr,Nn)=>{if(cr||!Nn)return ze(cr);const Sn={};if(Nt){const wn=d(Mt);wn.length>0&&(Sn.resourceTiming=JSON.parse(JSON.stringify(wn)))}ze(null,Object.assign({rawTileData:Ps.slice(0),responseHeaders:qt.responseHeaders},Nn,xs,Sn))})};this.isSpriteLoaded?Br():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Br,{type:"parseTile",isSymbolTile:Se.isSymbolTile,zoom:Se.tileZoom}):Br()}),this.loaded=this.loaded||{},this.loaded[tt]=Ot})}reloadTile(Se,ze){const tt=this.loaded,Mt=Se.uid;if(tt&&tt[Mt]){const Nt=tt[Mt];Nt.updateParameters(Se);const Ot=(Yt,qt)=>{const Jt=Nt.reloadCallback;Jt&&(delete Nt.reloadCallback,Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Jt)),ze(Yt,qt)};Nt.status==="parsing"?Nt.reloadCallback=Ot:Nt.status==="done"&&(Nt.vectorTile?Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Ot):Ot())}else ze(null,void 0)}abortTile(Se,ze){const tt=Se.uid,Mt=this.loading[tt];Mt&&(Mt.abort&&Mt.abort(),delete this.loading[tt]),ze()}removeTile(Se,ze){const tt=this.loaded,Mt=Se.uid;tt&&tt[Mt]&&delete tt[Mt],ze()}}class q{loadTile(Se,ze){const{uid:tt,encoding:Mt,rawImageData:Nt,padding:Ot}=Se,Yt=ImageBitmap&&Nt instanceof ImageBitmap?this.getImageData(Nt,Ot):Nt;ze(null,new i.fA(tt,Yt,Mt,Ot<1))}reloadTile(Se,ze){ze(null,null)}abortTile(Se,ze){ze()}removeTile(Se,ze){ze()}getImageData(Se,ze){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(Se.width,Se.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=Se.width,this.offscreenCanvas.height=Se.height,this.offscreenCanvasContext.drawImage(Se,0,0,Se.width,Se.height);const tt=this.offscreenCanvasContext.getImageData(-ze,-ze,Se.width+2*ze,Se.height+2*ze);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),tt}}i.bs.setPbf(i.bt);class H{constructor(Se){this._mrt=new i.bs(Se.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=Se.uid,this.tileID=Se.tileID,this.source=Se.source}parse(Se,ze){const tt=this._mrt;this.status="parsing",this._entireBuffer=Se;try{tt.parseHeader(Se),this._isHeaderLoaded=!0;const Mt=[];for(const Nt in tt.layers){const Ot=tt.getLayer(Nt),Yt=Ot.getDataRange(Ot.getBandList()),qt=tt.createDecodingTask(Yt),Jt=Se.slice(Yt.firstByte,Yt.lastByte+1),Ps=i.bs.performDecoding(Jt,qt).then(xs=>qt.complete(null,xs)).catch(xs=>qt.complete(xs,null));Mt.push(Ps)}Promise.allSettled(Mt).then(()=>ze(null,tt)).catch(Nt=>ze(Nt))}catch(Mt){ze(Mt)}}}class U{constructor(Se){this.actor=Se,this.loading={},this.loaded={}}loadTile(Se,ze){const tt=Se.uid,Mt=Se.request,Nt=this.loading[tt]=new H(Se),{cancel:Ot}=i.bu(Mt,(Yt,qt,Jt)=>{const Ps=!this.loading[tt];if(delete this.loading[tt],Ps||Yt||!qt)return Nt.status="done",Ps||(this.loaded[tt]=Nt),ze(Yt);Nt.parse(qt,(xs,hr)=>{if(xs||!hr)return ze(xs);ze(null,hr,Jt)}),this.loaded[tt]=Nt});Nt.abort=Ot}reloadTile(Se,ze){ze(null,void 0)}abortTile(Se,ze){const tt=Se.uid,Mt=this.loading[tt];Mt&&(Mt.abort&&Mt.abort(),delete this.loading[tt]),ze()}removeTile(Se,ze){const tt=Se.uid;this.loaded[tt]&&delete this.loaded[tt],ze()}decodeRasterArray(Se,ze){i.bs.performDecoding(Se.buffer,Se.task).then(tt=>ze(null,tt)).catch(tt=>ze(tt))}}const Q=i.fB.prototype.toGeoJSON;class se{constructor(Se){this._feature=Se,this.extent=i.al,this.type=Se.type,this.properties=Se.tags,"id"in Se&&!isNaN(Se.id)&&(this.id=parseInt(Se.id,10))}loadGeometry(){if(this._feature.type===1){const Se=[];for(const ze of this._feature.geometry)Se.push([new i.P(ze[0],ze[1])]);return Se}{const Se=[];for(const ze of this._feature.geometry){const tt=[];for(const Mt of ze)tt.push(new i.P(Mt[0],Mt[1]));Se.push(tt)}return Se}}toGeoJSON(Se,ze,tt){return Q.call(this,Se,ze,tt)}}class te{constructor(Se,ze){this.name=Se,this.extent=i.al,this.length=ze.length,this._jsonFeatures=ze}feature(Se){return new se(this._jsonFeatures[Se])}}class Y{constructor(Se){this.layers={},this.extent=i.al;for(const ze of Object.keys(Se))this.layers[ze]=new te(ze,Se[ze])}}const ce=64/4096,oe=128;class le{constructor(){this.features=new Map}clear(){this.features.clear()}load(Se=[],ze){for(const tt of Se){const Mt=tt.id;if(Mt==null)continue;let Nt=this.features.get(Mt);Nt&&this.updateCache(Nt,ze),tt.geometry?(Nt=xe(tt),this.updateCache(Nt,ze),this.features.set(Mt,Nt)):this.features.delete(Mt),this.updateCache(Nt,ze)}}updateCache(Se,ze){for(const{canonical:tt,uid:Mt}of Object.values(ze)){const{z:Nt,x:Ot,y:Yt}=tt;de(Se,Math.pow(2,Nt),Ot,Yt)&&delete ze[Mt]}}getTile(Se,ze,tt){const Mt=Math.pow(2,Se),Nt=[];for(const Ot of this.features.values())de(Ot,Mt,ze,tt)&&Nt.push(ke(Ot,Mt,ze,tt));return{features:Nt}}getFeatures(){return[...this.features.values()]}}function de({minX:it,minY:Se,maxX:ze,maxY:tt},Mt,Nt,Ot){return it<(Nt+1+ce)/Mt&&Se<(Ot+1+ce)/Mt&&ze>(Nt-ce)/Mt&&tt>(Ot-ce)/Mt}function xe(it){const{id:Se,geometry:ze,properties:tt}=it;if(!ze)return;if(ze.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:Mt,coordinates:Nt}=ze,Ot={id:Se,type:1,geometry:[],tags:tt,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Yt=Ot.geometry;if(Mt==="Point")be(Nt,Yt,Ot);else if(Mt==="MultiPoint")for(const qt of Nt)be(qt,Yt,Ot);else if(Mt==="LineString")Ot.type=2,ye(Nt,Yt,Ot);else if(Mt==="MultiLineString")Ot.type=2,ve(Nt,Yt,Ot);else if(Mt==="Polygon")Ot.type=3,ve(Nt,Yt,Ot,!0);else{if(Mt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Ot.type=3;for(const qt of Nt)ve(qt,Yt,Ot,!0)}return Ot}function be([it,Se],ze,tt){const Mt=i.aF(it);let Nt=i.aJ(Se);Nt=Nt<0?0:Nt>1?1:Nt,ze.push(Mt,Nt),tt.minX=Math.min(tt.minX,Mt),tt.minY=Math.min(tt.minY,Nt),tt.maxX=Math.max(tt.maxX,Mt),tt.maxY=Math.max(tt.maxY,Nt)}function ye(it,Se,ze,tt=!1,Mt=!1){const Nt=[];for(const Ot of it)be(Ot,Nt,ze);Se.push(Nt),tt&&function(Ot,Yt){let qt=0;for(let Jt=0,Ps=Ot.length,xs=Ps-2;Jt0===Yt)for(let Jt=0,Ps=Ot.length;Jt=Ot&&xs>=Ot||(Jt>=Ot?(Ps+=Math.round(cr*((Ot-Jt)/Br)),Jt=Ot):xs>=Ot&&(hr=Ps+Math.round(cr*((Ot-Jt)/Br)),xs=Ot),Ps>=Ot&&hr>=Ot||(Ps>=Ot?(Jt+=Math.round(Br*((Ot-Ps)/cr)),Ps=Ot):hr>=Ot&&(xs=Jt+Math.round(Br*((Ot-Ps)/cr)),hr=Ot),Yt&&Jt===Yt[Yt.length-1][0]&&Ps===Yt[Yt.length-1][1]||(Yt=[[Jt,Ps]],Mt.push(Yt)),Yt.push([xs,hr])))))}}function Ne(it,Se,ze,tt,Mt){const Nt=(ze-ce)/Se,Ot=(tt-ce)/Se,Yt=(ze+1+ce)/Se,qt=(tt+1+ce)/Se;function Jt(hr,Br){let cr=0;return hrYt&&(cr|=2),Brqt&&(cr|=8),cr}let Ps=[];for(let hr=1;hr<=8;hr*=2){let Br=it[it.length-2],cr=it[it.length-1],Nn=!(Jt(Br,cr)&hr);for(let Sn=0;Sn>31}function dt(it,Se){const{geometry:ze,type:tt}=it;let Mt=0,Nt=0;if(tt===1){Se.writeVarint(Ie(1,ze.length));for(const Ot of ze){const Yt=Ot[0]-Mt,qt=Ot[1]-Nt;Se.writeVarint(Ve(Yt)),Se.writeVarint(Ve(qt)),Mt+=Yt,Nt+=qt}}else for(const Ot of ze){Se.writeVarint(Ie(1,1));const Yt=Ot.length-(tt===3?1:0);for(let qt=0;qtit},fe=Math.fround||(Qe=new Float32Array(1),it=>(Qe[0]=+it,Qe[0]));var Qe;const at=3,rt=5,je=6;class mt{constructor(Se){this.options=Object.assign(Object.create(Rt),Se),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Se){const{log:ze,minZoom:tt,maxZoom:Mt}=this.options;ze&&console.time("total time");const Nt=`prepare ${Se.length} points`;ze&&console.time(Nt),this.points=Se;const Ot=[];for(let qt=0;qt=tt;qt--){const Jt=+Date.now();Yt=this.trees[qt]=this._createTree(this._cluster(Yt,qt)),ze&&console.log("z%d: %d clusters in %dms",qt,Yt.numItems,+Date.now()-Jt)}return ze&&console.timeEnd("total time"),this}getClusters(Se,ze){let tt=((Se[0]+180)%360+360)%360-180;const Mt=Math.max(-90,Math.min(90,Se[1]));let Nt=Se[2]===180?180:((Se[2]+180)%360+360)%360-180;const Ot=Math.max(-90,Math.min(90,Se[3]));if(Se[2]-Se[0]>=360)tt=-180,Nt=180;else if(tt>Nt){const xs=this.getClusters([tt,Mt,180,Ot],ze),hr=this.getClusters([-180,Mt,Nt,Ot],ze);return xs.concat(hr)}const Yt=this.trees[this._limitZoom(ze)],qt=Yt.range(We(tt),Ze(Ot),We(Nt),Ze(Mt)),Jt=Yt.data,Ps=[];for(const xs of qt){const hr=this.stride*xs;Ps.push(Jt[hr+rt]>1?He(Jt,hr,this.clusterProps):this.points[Jt[hr+at]])}return Ps}getChildren(Se){const ze=this._getOriginId(Se),tt=this._getOriginZoom(Se),Mt="No cluster with the specified id.",Nt=this.trees[tt];if(!Nt)throw new Error(Mt);const Ot=Nt.data;if(ze*this.stride>=Ot.length)throw new Error(Mt);const Yt=this.options.radius/(this.options.extent*Math.pow(2,tt-1)),qt=Nt.within(Ot[ze*this.stride],Ot[ze*this.stride+1],Yt),Jt=[];for(const Ps of qt){const xs=Ps*this.stride;Ot[xs+4]===Se&&Jt.push(Ot[xs+rt]>1?He(Ot,xs,this.clusterProps):this.points[Ot[xs+at]])}if(Jt.length===0)throw new Error(Mt);return Jt}getLeaves(Se,ze,tt){const Mt=[];return this._appendLeaves(Mt,Se,ze=ze||10,tt=tt||0,0),Mt}getTile(Se,ze,tt){const Mt=this.trees[this._limitZoom(Se)],Nt=Math.pow(2,Se),{extent:Ot,radius:Yt}=this.options,qt=Yt/Ot,Jt=(tt-qt)/Nt,Ps=(tt+1+qt)/Nt,xs={features:[]};return this._addTileFeatures(Mt.range((ze-qt)/Nt,Jt,(ze+1+qt)/Nt,Ps),Mt.data,ze,tt,Nt,xs),ze===0&&this._addTileFeatures(Mt.range(1-qt/Nt,Jt,1,Ps),Mt.data,Nt,tt,Nt,xs),ze===Nt-1&&this._addTileFeatures(Mt.range(0,Jt,qt/Nt,Ps),Mt.data,-1,tt,Nt,xs),xs.features.length?xs:null}getClusterExpansionZoom(Se){let ze=this._getOriginZoom(Se)-1;for(;ze<=this.options.maxZoom;){const tt=this.getChildren(Se);if(ze++,tt.length!==1)break;Se=tt[0].properties.cluster_id}return ze}_appendLeaves(Se,ze,tt,Mt,Nt){const Ot=this.getChildren(ze);for(const Yt of Ot){const qt=Yt.properties;if(qt&&qt.cluster?Nt+qt.point_count<=Mt?Nt+=qt.point_count:Nt=this._appendLeaves(Se,qt.cluster_id,tt,Mt,Nt):Nt1;let Ps,xs,hr;if(Jt)Ps=ct(ze,qt,this.clusterProps),xs=ze[qt],hr=ze[qt+1];else{const Nn=this.points[ze[qt+at]];Ps=Nn.properties;const[Sn,wn]=Nn.geometry.coordinates;xs=We(Sn),hr=Ze(wn)}const Br={type:1,geometry:[[Math.round(this.options.extent*(xs*Nt-tt)),Math.round(this.options.extent*(hr*Nt-Mt))]],tags:Ps};let cr;cr=Jt||this.options.generateId?ze[qt+at]:this.points[ze[qt+at]].id,cr!==void 0&&(Br.id=cr),Ot.features.push(Br)}}_limitZoom(Se){return Math.max(this.options.minZoom,Math.min(Math.floor(+Se),this.options.maxZoom+1))}_cluster(Se,ze){const{radius:tt,extent:Mt,reduce:Nt,minPoints:Ot}=this.options,Yt=tt/(Mt*Math.pow(2,ze)),qt=Se.data,Jt=[],Ps=this.stride;for(let xs=0;xsze&&(Sn+=qt[ca+rt])}if(Sn>Nn&&Sn>=Ot){let wn,ca=hr*Nn,ao=Br*Nn,zo=-1;const Ua=(xs/Ps<<5)+(ze+1)+this.points.length;for(const Vo of cr){const Ki=Vo*Ps;if(qt[Ki+2]<=ze)continue;qt[Ki+2]=ze;const xa=qt[Ki+rt];ca+=qt[Ki]*xa,ao+=qt[Ki+1]*xa,qt[Ki+4]=Ua,Nt&&(wn||(wn=this._map(qt,xs,!0),zo=this.clusterProps.length,this.clusterProps.push(wn)),Nt(wn,this._map(qt,Ki)))}qt[xs+4]=Ua,Jt.push(ca/Sn,ao/Sn,1/0,Ua,-1,Sn),Nt&&Jt.push(zo)}else{for(let wn=0;wn1)for(const wn of cr){const ca=wn*Ps;if(!(qt[ca+2]<=ze)){qt[ca+2]=ze;for(let ao=0;ao>5}_getOriginZoom(Se){return(Se-this.points.length)%32}_map(Se,ze,tt){if(Se[ze+rt]>1){const Ot=this.clusterProps[Se[ze+je]];return tt?Object.assign({},Ot):Ot}const Mt=this.points[Se[ze+at]].properties,Nt=this.options.map(Mt);return tt&&Nt===Mt?Object.assign({},Nt):Nt}}function He(it,Se,ze){return{type:"Feature",id:it[Se+at],properties:ct(it,Se,ze),geometry:{type:"Point",coordinates:[(tt=it[Se],360*(tt-.5)),ht(it[Se+1])]}};var tt}function ct(it,Se,ze){const tt=it[Se+rt],Mt=tt>=1e4?`${Math.round(tt/1e3)}k`:tt>=1e3?Math.round(tt/100)/10+"k":tt,Nt=it[Se+je],Ot=Nt===-1?{}:Object.assign({},ze[Nt]);return Object.assign(Ot,{cluster:!0,cluster_id:it[Se+at],point_count:tt,point_count_abbreviated:Mt})}function We(it){return it/360+.5}function Ze(it){const Se=Math.sin(it*Math.PI/180),ze=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return ze<0?0:ze>1?1:ze}function ht(it){const Se=(180-360*it)*Math.PI/180;return 360*Math.atan(Math.exp(Se))/Math.PI-90}function Ke(it,Se,ze,tt){let Mt=tt;const Nt=Se+(ze-Se>>1);let Ot,Yt=ze-Se;const qt=it[Se],Jt=it[Se+1],Ps=it[ze],xs=it[ze+1];for(let hr=Se+3;hrMt)Ot=hr,Mt=Br;else if(Br===Mt){const cr=Math.abs(hr-Nt);crtt&&(Ot-Se>3&&Ke(it,Se,Ot,tt),it[Ot+2]=Mt,ze-Ot>3&&Ke(it,Ot,ze,tt))}function qe(it,Se,ze,tt,Mt,Nt){let Ot=Mt-ze,Yt=Nt-tt;if(Ot!==0||Yt!==0){const qt=((it-ze)*Ot+(Se-tt)*Yt)/(Ot*Ot+Yt*Yt);qt>1?(ze=Mt,tt=Nt):qt>0&&(ze+=Ot*qt,tt+=Yt*qt)}return Ot=it-ze,Yt=Se-tt,Ot*Ot+Yt*Yt}function Je(it,Se,ze,tt){const Mt={id:it??null,type:Se,geometry:ze,tags:tt,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")Lt(Mt,ze);else if(Se==="Polygon")Lt(Mt,ze[0]);else if(Se==="MultiLineString")for(const Nt of ze)Lt(Mt,Nt);else if(Se==="MultiPolygon")for(const Nt of ze)Lt(Mt,Nt[0]);return Mt}function Lt(it,Se){for(let ze=0;ze0&&(Ot+=tt?(Mt*Ps-Jt*Nt)/2:Math.sqrt(Math.pow(Jt-Mt,2)+Math.pow(Ps-Nt,2))),Mt=Jt,Nt=Ps}const Yt=Se.length-3;Se[2]=1,Ke(Se,0,Yt,ze),Se[Yt+2]=1,Se.size=Math.abs(Ot),Se.start=0,Se.end=Se.size}function Qt(it,Se,ze,tt){for(let Mt=0;Mt1?1:ze}function bt(it,Se,ze,tt,Mt,Nt,Ot,Yt){if(tt/=Se,Nt>=(ze/=Se)&&Ot=tt)return null;const qt=[];for(const Jt of it){const Ps=Jt.geometry;let xs=Jt.type;const hr=Mt===0?Jt.minX:Jt.minY,Br=Mt===0?Jt.maxX:Jt.maxY;if(hr>=ze&&Br=tt)continue;let cr=[];if(xs==="Point"||xs==="MultiPoint")ws(Ps,cr,ze,tt,Mt);else if(xs==="LineString")ir(Ps,cr,ze,tt,Mt,!1,Yt.lineMetrics);else if(xs==="MultiLineString")oa(Ps,cr,ze,tt,Mt,!1);else if(xs==="Polygon")oa(Ps,cr,ze,tt,Mt,!0);else if(xs==="MultiPolygon")for(const Nn of Ps){const Sn=[];oa(Nn,Sn,ze,tt,Mt,!0),Sn.length&&cr.push(Sn)}if(cr.length){if(Yt.lineMetrics&&xs==="LineString"){for(const Nn of cr)qt.push(Je(Jt.id,xs,Nn,Jt.tags));continue}xs!=="LineString"&&xs!=="MultiLineString"||(cr.length===1?(xs="LineString",cr=cr[0]):xs="MultiLineString"),xs!=="Point"&&xs!=="MultiPoint"||(xs=cr.length===3?"Point":"MultiPoint"),qt.push(Je(Jt.id,xs,cr,Jt.tags))}}return qt.length?qt:null}function ws(it,Se,ze,tt,Mt){for(let Nt=0;Nt=ze&&Ot<=tt&&ri(Se,it[Nt],it[Nt+1],it[Nt+2])}}function ir(it,Se,ze,tt,Mt,Nt,Ot){let Yt=Rr(it);const qt=Mt===0?no:Da;let Jt,Ps,xs=it.start;for(let Sn=0;Snze&&(Ps=qt(Yt,wn,ca,zo,Ua,ze),Ot&&(Yt.start=xs+Jt*Ps)):Vo>tt?Ki=ze&&(Ps=qt(Yt,wn,ca,zo,Ua,ze),xa=!0),Ki>tt&&Vo<=tt&&(Ps=qt(Yt,wn,ca,zo,Ua,tt),xa=!0),!Nt&&xa&&(Ot&&(Yt.end=xs+Jt*Ps),Se.push(Yt),Yt=Rr(it)),Ot&&(xs+=Jt)}let hr=it.length-3;const Br=it[hr],cr=it[hr+1],Nn=Mt===0?Br:cr;Nn>=ze&&Nn<=tt&&ri(Yt,Br,cr,it[hr+2]),hr=Yt.length-3,Nt&&hr>=3&&(Yt[hr]!==Yt[0]||Yt[hr+1]!==Yt[1])&&ri(Yt,Yt[0],Yt[1],Yt[2]),Yt.length&&Se.push(Yt)}function Rr(it){const Se=[];return Se.size=it.size,Se.start=it.start,Se.end=it.end,Se}function oa(it,Se,ze,tt,Mt,Nt){for(const Ot of it)ir(Ot,Se,ze,tt,Mt,Nt,!1)}function ri(it,Se,ze,tt){it.push(Se,ze,tt)}function no(it,Se,ze,tt,Mt,Nt){const Ot=(Nt-Se)/(tt-Se);return ri(it,Nt,ze+(Mt-ze)*Ot,1),Ot}function Da(it,Se,ze,tt,Mt,Nt){const Ot=(Nt-ze)/(Mt-ze);return ri(it,Se+(tt-Se)*Ot,Nt,1),Ot}function yn(it,Se){const ze=[];for(let tt=0;tt0&&Se.size<(Mt?Ot:tt))return void(ze.numPoints+=Se.length/3);const Yt=[];for(let qt=0;qtOt)&&(ze.numSimplified++,Yt.push(Se[qt],Se[qt+1])),ze.numPoints++;Mt&&function(qt,Jt){let Ps=0;for(let xs=0,hr=qt.length,Br=hr-2;xs0===Jt)for(let xs=0,hr=qt.length;xs
24)throw new Error("maxZoom should be in the 0-24 range");if(ze.promoteId&&ze.generateId)throw new Error("promoteId and generateId cannot be used together.");let Mt=function(Nt,Ot){const Yt=[];if(Nt.type==="FeatureCollection")for(let qt=0;qt1&&console.time("creation"),Br=this.tiles[hr]=Gr(Se,ze,tt,Mt,Jt),this.tileCoords.push({z:ze,x:tt,y:Mt}),Ps)){Ps>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",ze,tt,Mt,Br.numFeatures,Br.numPoints,Br.numSimplified),console.timeEnd("creation"));const xa=`z${ze}`;this.stats[xa]=(this.stats[xa]||0)+1,this.total++}if(Br.source=Se,Nt==null){if(ze===Jt.indexMaxZoom||Br.numPoints<=Jt.indexMaxPoints)continue}else{if(ze===Jt.maxZoom||ze===Nt)continue;if(Nt!=null){const xa=Nt-ze;if(tt!==Ot>>xa||Mt!==Yt>>xa)continue}}if(Br.source=null,Se.length===0)continue;Ps>1&&console.time("clipping");const cr=.5*Jt.buffer/Jt.extent,Nn=.5-cr,Sn=.5+cr,wn=1+cr;let ca=null,ao=null,zo=null,Ua=null,Vo=bt(Se,xs,tt-cr,tt+Sn,0,Br.minX,Br.maxX,Jt),Ki=bt(Se,xs,tt+Nn,tt+wn,0,Br.minX,Br.maxX,Jt);Se=null,Vo&&(ca=bt(Vo,xs,Mt-cr,Mt+Sn,1,Br.minY,Br.maxY,Jt),ao=bt(Vo,xs,Mt+Nn,Mt+wn,1,Br.minY,Br.maxY,Jt),Vo=null),Ki&&(zo=bt(Ki,xs,Mt-cr,Mt+Sn,1,Br.minY,Br.maxY,Jt),Ua=bt(Ki,xs,Mt+Nn,Mt+wn,1,Br.minY,Br.maxY,Jt),Ki=null),Ps>1&&console.timeEnd("clipping"),qt.push(ca||[],ze+1,2*tt,2*Mt),qt.push(ao||[],ze+1,2*tt,2*Mt+1),qt.push(zo||[],ze+1,2*tt+1,2*Mt),qt.push(Ua||[],ze+1,2*tt+1,2*Mt+1)}}getTile(Se,ze,tt){Se=+Se,ze=+ze,tt=+tt;const Mt=this.options,{extent:Nt,debug:Ot}=Mt;if(Se<0||Se>24)return null;const Yt=1<1&&console.log("drilling down to z%d-%d-%d",Se,ze,tt);let Jt,Ps=Se,xs=ze,hr=tt;for(;!Jt&&Ps>0;)Ps--,xs>>=1,hr>>=1,Jt=this.tiles[qa(Ps,xs,hr)];return Jt&&Jt.source?(Ot>1&&(console.log("found parent tile z%d-%d-%d",Ps,xs,hr),console.time("drilling down")),this.splitTile(Jt.source,Ps,xs,hr,Se,ze,tt),Ot>1&&console.timeEnd("drilling down"),this.tiles[qt]?Zt(this.tiles[qt],Nt):null):null}}function qa(it,Se,ze){return 32*((1<Jt.tags&&"3d_elevation_id"in Jt.tags&&"source"in Jt.tags&&Jt.tags.source==="elevation",Nt=tt.features.filter(Jt=>Mt(Jt));let Ot={_geojsonTileLayer:tt.features};Nt.length>0&&(Ot={_geojsonTileLayer:tt.features.filter(Jt=>!Mt(Jt)),hd_road_elevation:Nt});const Yt=new Y(Ot),qt=function(Jt){const Ps=new i.bt;for(const xs of Object.keys(Jt))Ps.writeMessage(3,Ae,{name:xs,features:Jt[xs]});return Ps.finish()}(Ot).buffer;Se(null,{vectorTile:Yt,rawData:qt})}class Ka extends ${constructor(Se,ze,tt,Mt,Nt,Ot,Yt){super(Se,ze,tt,Mt,Nt,Jr,Yt),Ot&&(this.loadGeoJSON=Ot),this._dynamicIndex=new le}loadData(Se,ze){const tt=Se&&Se.request,Mt=tt&&tt.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(Se,(Nt,Ot)=>{if(Nt||!Ot)return ze(Nt);if(typeof Ot!="object")return ze(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));{try{if(Se.filter){const qt=i.U(Se.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(qt.result==="error")throw new Error(qt.value.map(Jt=>`${Jt.key}: ${Jt.message}`).join(", "));Ot.features=Ot.features.filter(Jt=>qt.value.evaluate({zoom:0},Jt))}Se.dynamic?(Ot.type==="Feature"&&(Ot={type:"FeatureCollection",features:[Ot]}),Se.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Ot.features,this.loaded),Se.cluster&&(Ot.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=Se.cluster?new mt(function({superclusterOptions:qt,clusterProperties:Jt}){if(!Jt||!qt)return qt;const Ps={},xs={},hr={accumulated:null,zoom:0},Br={properties:null},cr=Object.keys(Jt);for(const Nn of cr){const[Sn,wn]=Jt[Nn],ca=i.U(wn),ao=i.U(typeof Sn=="string"?[Sn,["accumulated"],["get",Nn]]:Sn);Ps[Nn]=ca.value,xs[Nn]=ao.value}return qt.map=Nn=>{Br.properties=Nn;const Sn={};for(const wn of cr)Sn[wn]=Ps[wn].evaluate(hr,Br);return Sn},qt.reduce=(Nn,Sn)=>{Br.properties=Sn;for(const wn of cr)hr.accumulated=Nn[wn],Nn[wn]=xs[wn].evaluate(hr,Br)},qt}(Se)).load(Ot.features):Se.dynamic?this._dynamicIndex:function(qt,Jt){return new la(qt,Jt)}(Ot,Se.geojsonVtOptions)}catch(qt){return ze(qt)}const Yt={};if(Mt){const qt=d(tt);qt&&(Yt.resourceTiming={},Yt.resourceTiming[Se.source]=JSON.parse(JSON.stringify(qt)))}ze(null,Yt)}})}reloadTile(Se,ze){const tt=this.loaded;return tt&&tt[Se.uid]?Se.partial?ze(null,void 0):super.reloadTile(Se,ze):this.loadTile(Se,ze)}loadGeoJSON(Se,ze){if(Se.request)i.m(Se.request,ze);else{if(typeof Se.data!="string")return ze(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return ze(null,JSON.parse(Se.data))}catch{return ze(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(Se,ze){try{ze(null,this._geoJSONIndex.getClusterExpansionZoom(Se.clusterId))}catch(tt){ze(tt)}}getClusterChildren(Se,ze){try{ze(null,this._geoJSONIndex.getChildren(Se.clusterId))}catch(tt){ze(tt)}}getClusterLeaves(Se,ze){try{ze(null,this._geoJSONIndex.getLeaves(Se.clusterId,Se.limit,Se.offset))}catch(tt){ze(tt)}}}class Dl{constructor(Se,ze,tt){this.tileID=new i.aQ(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=Se.projection,this.brightness=ze,this.worldview=tt}parse(Se,ze,tt,Mt){this.status="parsing";const Nt=new i.aQ(tt.tileID.overscaledZ,tt.tileID.wrap,tt.tileID.canonical.z,tt.tileID.canonical.x,tt.tileID.canonical.y),Ot=[],Yt=ze.familiesBySource[tt.source],qt=new i.fn(Nt,tt.promoteId);qt.bucketLayerIDs=[],qt.is3DTile=!0,i.fC(Se).then(Jt=>{if(!Jt)return Mt(new Error("Could not parse tile"));const Ps=Jt.json.extensionsUsed&&Jt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Jt.json.asset.extras&&Jt.json.asset.extras.MAPBOX_mesh_features,xs=Jt.json.extensionsUsed&&Jt.json.extensionsUsed.includes("EXT_meshopt_compression"),hr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Br in Yt)for(const cr of Yt[Br]){const Nn=cr[0];qt.bucketLayerIDs.push(cr.map(ca=>i.B(ca.id,ca.scope))),Nn.recalculate(hr,[]);const Sn=i.fD(Jt,1/i.d7(tt.tileID.canonical)),wn=new i.fE(cr,Sn,Nt,Ps,xs,this.brightness,qt,this.worldview);Ps||(wn.needsUpload=!0),Ot.push(wn),wn.evaluate(Nn)}this.status="done",Mt(null,{buckets:Ot,featureIndex:qt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Jt=>Mt(new Error(Jt.message)))}}class Lo{constructor(Se,ze,tt,Mt,Nt,Ot,Yt,qt){this.actor=Se,this.layerIndex=ze,this.availableImages=tt,this.availableModels=Mt,this.brightness=Yt,this.loading={},this.loaded={},this.worldview=qt}loadTile(Se,ze){const tt=Se.uid,Mt=this.loading[tt]=new Dl(Se,this.brightness,this.worldview);i.bu(Se.request,(Nt,Ot)=>{const Yt=!this.loading[tt];return delete this.loading[tt],Yt||Nt?(Mt.status="done",Yt||(this.loaded[tt]=Mt),ze(Nt)):Ot&&Ot.byteLength!==0?void Mt.parse(Ot,this.layerIndex,Se,(qt,Jt)=>{Mt.status="done",this.loaded=this.loaded||{},this.loaded[tt]=Mt,qt||!Jt?ze(qt):ze(null,Jt)}):(Mt.status="done",this.loaded[tt]=Mt,ze())})}reloadTile(Se,ze){const tt=this.loaded,Mt=Se.uid;if(tt&&tt[Mt]){const Nt=tt[Mt];Nt.projection=Se.projection,Nt.brightness=Se.brightness;const Ot=(Yt,qt)=>{Nt.reloadCallback&&(delete Nt.reloadCallback,this.loadTile(Se,ze)),ze(Yt,qt)};Nt.status==="parsing"?Nt.reloadCallback=Ot:Nt.status==="done"&&this.loadTile(Se,ze)}}abortTile(Se,ze){const tt=Se.uid;this.loading[tt]&&delete this.loading[tt],ze()}removeTile(Se,ze){const tt=this.loaded,Mt=Se.uid;tt&&tt[Mt]&&delete tt[Mt],ze()}}class Kc{constructor(Se){this.self=Se,this.actor=new i.fG(Se,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new i.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=i.cm({name:"mercator"}),this.workerSourceTypes={vector:$,geojson:Ka,"raster-dem":q,"raster-array":U,"batched-model":Lo},this.workerSources={},this.self.registerWorkerSource=(ze,tt)=>{if(this.workerSourceTypes[ze])throw new Error(`Worker source with name "${ze}" already registered.`);this.workerSourceTypes[ze]=tt},this.self.registerRTLTextPlugin=ze=>{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=ze.applyArabicShaping,i.fH.processBidirectionalText=ze.processBidirectionalText,i.fH.processStyledBidirectionalText=ze.processStyledBidirectionalText;for(const tt of this.rtlPluginParsingListeners)tt(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(Se,ze,tt){delete this.layerIndexes[Se],delete this.availableImages[Se],delete this.availableModels[Se],delete this.workerSources[Se],tt()}checkIfReady(Se,ze,tt){tt()}setReferrer(Se,ze){this.referrer=ze}spriteLoaded(Se,ze){this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={});const{scope:tt,isLoaded:Mt}=ze;if(this.isSpriteLoaded[Se][tt]=Mt,this.workerSources[Se]&&this.workerSources[Se][tt])for(const Nt in this.workerSources[Se][tt]){const Ot=this.workerSources[Se][tt][Nt];for(const Yt in Ot){const qt=Ot[Yt];qt instanceof $&&(qt.isSpriteLoaded=Mt,qt.fire(new i.z("isSpriteLoaded")))}}}setImages(Se,ze,tt){this.availableImages[Se]||(this.availableImages[Se]={});const{scope:Mt,images:Nt}=ze;if(this.availableImages[Se][Mt]=Nt,this.workerSources[Se]&&this.workerSources[Se][Mt]){for(const Ot in this.workerSources[Se][Mt]){const Yt=this.workerSources[Se][Mt][Ot];for(const qt in Yt)Yt[qt].availableImages=Nt}tt()}else tt()}setModels(Se,{scope:ze,models:tt},Mt){if(this.availableModels[Se]||(this.availableModels[Se]={}),this.availableModels[Se][ze]=tt,this.workerSources[Se]&&this.workerSources[Se][ze]){for(const Nt in this.workerSources[Se][ze]){const Ot=this.workerSources[Se][ze][Nt];for(const Yt in Ot)Ot[Yt].availableModels=tt}Mt()}else Mt()}setProjection(Se,ze){this.projections[Se]=i.cm(ze)}setBrightness(Se,ze,tt){this.brightness=ze,tt()}setWorldview(Se,ze,tt){this.worldview=ze,tt()}setLayers(Se,ze,tt){this.getLayerIndex(Se,ze.scope).replace(ze.layers,ze.options),tt()}updateLayers(Se,ze,tt){this.getLayerIndex(Se,ze.scope).update(ze.layers,ze.removedIds,ze.options),tt()}loadTile(Se,ze,tt){ze.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,ze.type,ze.source,ze.scope).loadTile(ze,tt)}decodeRasterArray(Se,ze,tt){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).decodeRasterArray(ze,tt)}reloadTile(Se,ze,tt){ze.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,ze.type,ze.source,ze.scope).reloadTile(ze,tt)}abortTile(Se,ze,tt){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).abortTile(ze,tt)}removeTile(Se,ze,tt){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).removeTile(ze,tt)}removeSource(Se,ze,tt){if(!(this.workerSources[Se]&&this.workerSources[Se][ze.scope]&&this.workerSources[Se][ze.scope][ze.type]&&this.workerSources[Se][ze.scope][ze.type][ze.source]))return;const Mt=this.workerSources[Se][ze.scope][ze.type][ze.source];delete this.workerSources[Se][ze.scope][ze.type][ze.source],Mt.removeSource!==void 0?Mt.removeSource(ze,tt):tt()}loadWorkerSource(Se,ze,tt){try{this.self.importScripts(ze.url),tt()}catch(Mt){tt(Mt)}}syncRTLPluginState(Se,ze,tt){if(i.fH.isParsed())tt(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(tt);else try{i.fH.setState(ze);const Mt=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||Mt==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(Mt),i.fH.isParsed()?tt(null,!0):this.rtlPluginParsingListeners.push(tt))}catch(Mt){tt(Mt)}}setDracoUrl(Se,ze){this.dracoUrl=ze}getAvailableImages(Se,ze){this.availableImages[Se]||(this.availableImages[Se]={});let tt=this.availableImages[Se][ze];return tt||(tt=[]),tt}getAvailableModels(Se,ze){this.availableModels[Se]||(this.availableModels[Se]={});let tt=this.availableModels[Se][ze];return tt||(tt={}),tt}getLayerIndex(Se,ze){this.layerIndexes[Se]||(this.layerIndexes[Se]={});let tt=this.layerIndexes[Se][ze];return tt||(tt=this.layerIndexes[Se][ze]=new g,tt.scope=ze),tt}getWorkerSource(Se,ze,tt,Mt){const Nt=this.workerSources;return Nt[Se]||(Nt[Se]={}),Nt[Se][Mt]||(Nt[Se][Mt]={}),Nt[Se][Mt][ze]||(Nt[Se][Mt][ze]={}),this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={}),Nt[Se][Mt][ze][tt]||(Nt[Se][Mt][ze][tt]=new this.workerSourceTypes[ze]({send:(Ot,Yt,qt,Jt,Ps,xs)=>this.actor.send(Ot,Yt,qt,Se,Ps,xs),scheduler:this.actor.scheduler},this.getLayerIndex(Se,Mt),this.getAvailableImages(Se,Mt),this.getAvailableModels(Se,Mt),this.isSpriteLoaded[Se][Mt],void 0,this.brightness,this.worldview)),Nt[Se][Mt][ze][tt]}rasterizeImagesWorker(Se,ze,tt){const Mt=new Map;for(const[Nt,{image:Ot,imageVariant:Yt}]of ze.tasks.entries()){const qt=this.imageRasterizer.rasterize(Yt,Ot,ze.scope,Se);Mt.set(Nt,qt)}tt(void 0,Mt)}removeRasterizedImages(Se,ze,tt){this.imageRasterizer.removeImagesFromCacheByIds(ze.imageIds,ze.scope,Se),tt()}enforceCacheSizeLimit(Se,ze){i.fJ(ze)}getWorkerPerformanceMetrics(Se,ze,tt){tt(void 0,void 0)}}return i.fF(self)&&(self.worker=new Kc(self)),Kc}),o(["./shared"],function(i){var d="3.17.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},f={mark(C){performance.mark(C)},measure(C,h,x){performance.measure(C,h,x)}};function g(C){const h=C.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 v,_={},b=function(){if(v)return _;function C(T){return!h(T)}function h(T){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var R,z,V=new Blob([""],{type:"text/javascript"}),X=URL.createObjectURL(V);try{z=new Worker(X),R=!0}catch{R=!1}return z&&z.terminate(),URL.revokeObjectURL(X),R}()?function(){var R=document.createElement("canvas");R.width=R.height=1;var z=R.getContext("2d");if(!z)return!1;var V=z.getImageData(0,0,1,1);return V&&V.width===R.width}()?(x[D=T&&T.failIfMajorPerformanceCaveat]===void 0&&(x[D]=function(R){var z,V=function(X){var re=document.createElement("canvas"),ae=Object.create(C.webGLContextAttributes);return ae.failIfMajorPerformanceCaveat=X,re.getContext("webgl2",ae)}(R);if(!V)return!1;try{z=V.createShader(V.VERTEX_SHADER)}catch{return!1}return!(!z||V.isContextLost())&&(V.shaderSource(z,"void main() {}"),V.compileShader(z),V.getShaderParameter(z,V.COMPILE_STATUS)===!0)}(D)),x[D]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var D}v=1,_.supported=C,_.notSupportedReason=h;var x={};return C.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function w(C,h,x){const T=document.createElement(C);return h!=null&&(T.className=h),x&&x.appendChild(T),T}function j(C,h,x){const T=document.createElementNS("http://www.w3.org/2000/svg",C);for(const D of Object.keys(h))T.setAttributeNS(null,D,String(h[D]));return x&&x.appendChild(T),T}const N=typeof document<"u"?document.documentElement&&document.documentElement.style:null,S=N&&N.userSelect!==void 0?"userSelect":"WebkitUserSelect";let A;function I(){N&&S&&(A=N[S],N[S]="none")}function L(){N&&S&&(N[S]=A)}function F(C){C.preventDefault(),C.stopPropagation(),window.removeEventListener("click",F,!0)}function $(){window.addEventListener("click",F,!0),window.setTimeout(()=>{window.removeEventListener("click",F,!0)},0)}function q(C,h){const x=C.getBoundingClientRect();return Q(C,x,h)}function H(C,h){const x=C.getBoundingClientRect(),T=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(h,x){return this._transformRequestFn&&this._transformRequestFn(h,x)||{url:h}}normalizeStyleURL(h,x){if(!i.h(h))return h;const T=oe(h);return T.params.push(`sdk=js-${d}`),T.path=`/styles/v1${T.path}`,this._makeAPIURL(T,this._customAccessToken||x)}normalizeGlyphsURL(h,x){if(!i.h(h))return h;const T=oe(h);return T.path=`/fonts/v1${T.path}`,this._makeAPIURL(T,this._customAccessToken||x)}normalizeModelURL(h,x){if(!i.h(h))return h;const T=oe(h);return T.path=`/models/v1${T.path}`,this._makeAPIURL(T,this._customAccessToken||x)}normalizeSourceURL(h,x,T,D){if(!i.h(h))return h;const R=oe(h);return R.path=`/v4/${R.authority}.json`,R.params.push("secure"),T&&R.params.push(`language=${T}`),D&&R.params.push(`worldview=${D}`),this._makeAPIURL(R,this._customAccessToken||x)}normalizeIconsetURL(h,x){const T=oe(h);return i.h(h)?(T.path=`/styles/v1${T.path}/iconset.pbf`,this._makeAPIURL(T,this._customAccessToken||x)):le(T)}normalizeSpriteURL(h,x,T,D){const R=oe(h);return i.h(h)?(R.path=`/styles/v1${R.path}/sprite${x}${T}`,this._makeAPIURL(R,this._customAccessToken||D)):(R.path+=`${x}${T}`,le(R))}normalizeTileURL(h,x,T){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=oe(h);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${x||T&&D.authority!=="raster"&&T===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 R=this._customAccessToken||function(z){for(const V of z){const X=V.match(/^access_token=(.*)$/);if(X)return X[1]}return null}(D.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&R&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,R)}canonicalizeTileURL(h,x){const T=oe(h);if(!T.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!T.path.match(/\.[\w]+$/))return h;let D="mapbox://";T.path.match(/^\/raster\/v1\//)?D+=`raster/${T.path.replace(`/${i.e.RASTER_URL_PREFIX}/`,"")}`:T.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${T.path.replace(`/${i.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${T.path.replace(`/${i.e.TILE_URL_VERSION}/`,"")}`;let R=T.params;return x&&(R=R.filter(z=>!z.match(/^access_token=/))),R.length&&(D+=`?${R.join("&")}`),D}canonicalizeTileset(h,x){const T=!!x&&i.h(x),D=[];for(const R of h.tiles||[])i.j(R)?D.push(this.canonicalizeTileURL(R,T)):D.push(R);return D}_makeAPIURL(h,x){const T="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=oe(i.e.API_URL);if(h.protocol=D.protocol,h.authority=D.authority,h.protocol==="http"){const R=h.params.indexOf("secure");R>=0&&h.params.splice(R,1)}if(D.path!=="/"&&(h.path=`${D.path}${h.path}`),!i.e.REQUIRE_ACCESS_TOKEN)return le(h);if(x=x||i.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!x)throw new Error(`An API access token is required to use Mapbox GL. ${T}`);if(x[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${T}`)}return h.params=h.params.filter(R=>R.indexOf("access_token")===-1),h.params.push(`access_token=${x||""}`),le(h)}}const ce=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function oe(C){const h=C.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 le(C){const h=C.params.length?`?${C.params.join("&")}`:"";return`${C.protocol}://${C.authority}${C.path}${h}`}const de="mapbox.eventData";function xe(C){if(!C)return null;const h=C.split(".");if(!h||h.length!==3)return null;try{return JSON.parse(i.l(h[1]))}catch{return null}}class be{constructor(h){this.type=h,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(h){const x=xe(i.e.ACCESS_TOKEN);let T="";return T=x&&x.u?i.f(x.u):i.e.ACCESS_TOKEN||"",h?`${de}.${h}:${T}`:`${de}:${T}`}fetchEventData(){const h=i.s("localStorage"),x=this.getStorageKey(),T=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(h)try{const R=localStorage.getItem(x);R&&(this.eventData=JSON.parse(R));const z=localStorage.getItem(T);z&&(this.anonId=z);const V=localStorage.getItem(D);V&&(this.anonIdTimestamp=Number(V));const X=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(x,JSON.stringify(this.eventData)),z&&localStorage.setItem(D,z.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(h){}postEvent(h,x,T,D){if(!i.e.EVENTS_URL)return;const R=oe(i.e.EVENTS_URL);R.params.push(`access_token=${D||i.e.ACCESS_TOKEN||""}`);const z={event:this.type,created:new Date(h).toISOString()},V=x?Object.assign(z,x):z,X={url:le(R),headers:{"Content-Type":"text/plain"},body:JSON.stringify([V])};this.pendingRequest=i.p(X,re=>{this.pendingRequest=null,T(re),this.saveEventData(),this.processRequests(D)})}queueRequest(h,x){this.queue.push(h),this.processRequests(x)}}class ye extends be{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 x=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:x},h)}processRequests(h){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:x,payload:T}=this.queue.shift();this.postEvent(x,T,()=>{},h)}}const ve=new class extends be{constructor(C){super("appUserTurnstile"),this._customAccessToken=C}postTurnstileEvent(C,h){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(C)&&C.some(x=>i.h(x)||i.j(x))&&this.queueRequest(Date.now(),h)}processRequests(C){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const h=xe(i.e.ACCESS_TOKEN),x=h?h.u:i.e.ACCESS_TOKEN;let T=x!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),T=!0);const D=this.queue.shift();if(this.eventData.lastSuccess){const R=new Date(this.eventData.lastSuccess),z=new Date(D),V=(D-this.eventData.lastSuccess)/864e5;T=T||V>=1||V<-1||R.getDate()!==z.getDate()}else T=!0;T?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:se,"enabled.telemetry":!1,userId:this.anonId},R=>{R||(this.eventData.lastSuccess=D,this.eventData.tokenU=x)},C):this.processRequests()}},ke=ve.postTurnstileEvent.bind(ve),Ge=new class extends be{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(C,h,x,T){this.skuToken=h,this.errorCb=T,i.e.EVENTS_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:C,timestamp:Date.now()},x):this.errorCb(new Error(te)))}processRequests(C){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:x}=this.queue.shift();h&&this.success[h]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(x,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:se,skuToken:this.skuToken,userId:this.anonId},T=>{T?this.errorCb(T):h&&(this.success[h]=!0)},C))}remove(){this.errorCb=null}},Ne=Ge.postMapLoadEvent.bind(Ge),Ae=new class extends be{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(C){let h=this.mapInstanceIdMap.get(C);return h||(h=i.u(),this.mapInstanceIdMap.set(C,h)),h}getEventId(C){const h=this.eventIdPerMapInstanceMap.get(C)||0;return this.eventIdPerMapInstanceMap.set(C,h+1),h}postStyleLoadEvent(C,h){const{map:x,style:T,importedStyles:D}=h;if(!i.e.EVENTS_URL||!C&&!i.e.ACCESS_TOKEN)return;const R=this.getMapInstanceId(x),z={mapInstanceId:R,eventId:this.getEventId(R),style:T};D.length&&(z.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:z},C)}processRequests(C){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,payload:x}=this.queue.shift();this.postEvent(h,x,()=>{},C)}},Pe=Ae.postStyleLoadEvent.bind(Ae),Fe=new ye({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Ie=Fe.postMetricsEvent.bind(Fe),Ve=new ye({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),dt=Ve.postMetricsEvent.bind(Ve),Le=new class extends be{constructor(){super("gljs.performance")}postPerformanceEvent(C,h){i.e.EVENTS_URL&&(C||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:h},C)}processRequests(C){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,performanceData:x}=this.queue.shift(),T=function(D){const R=performance.getEntriesByType("resource"),z=performance.getEntriesByType("mark"),V=function(pe){const Me={};if(pe){for(const Ce in pe)if(Ce!=="other")for(const $e of pe[Ce]){const Be=`${Ce}ResolveRangeMin`,Xe=`${Ce}ResolveRangeMax`,ot=`${Ce}RequestCount`,et=`${Ce}RequestCachedCount`;Me[Be]=Math.min(Me[Be]||1/0,$e.startTime),Me[Xe]=Math.max(Me[Xe]||-1/0,$e.responseEnd);const Ct=vt=>{Me[vt]===void 0&&(Me[vt]=0),++Me[vt]};$e.transferSize!==void 0&&$e.transferSize===0&&Ct(et),Ct(ot)}}return Me}(function(pe,Me){const Ce={};if(pe)for(const $e of pe){const Be=Me($e);Ce[Be]===void 0&&(Ce[Be]=[]),Ce[Be].push($e)}return Ce}(R,g)),X=window.devicePixelRatio,re=navigator.connection||navigator.mozConnection||navigator.webkitConnection,ae=re?re.effectiveType:void 0,me={counters:[],metadata:[],attributes:[]},he=(pe,Me,Ce)=>{Ce!=null&&pe.push({name:Me,value:Ce.toString()})};for(const pe in V)he(me.counters,pe,V[pe]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(he(me.counters,"interactionRangeMin",D.interactionRange[0]),he(me.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const pe of Object.values(u)){const Me=z.find(Ce=>Ce.name===pe);Me&&he(me.counters,pe,Me.startTime)}return he(me.counters,"visibilityHidden",D.visibilityHidden),he(me.attributes,"style",function(pe){if(pe)for(const Me of pe){const Ce=Me.name.split("?")[0];if(i.i(Ce)){const $e=Ce.split("/").slice(-2);if($e.length===2)return`mapbox://styles/${$e[0]}/${$e[1]}`}}}(R)),he(me.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),he(me.attributes,"fogEnabled",D.fogEnabled?"true":"false"),he(me.attributes,"projection",D.projection),he(me.attributes,"zoom",D.zoom),he(me.metadata,"devicePixelRatio",X),he(me.metadata,"connectionEffectiveType",ae),he(me.metadata,"navigatorUserAgent",navigator.userAgent),he(me.metadata,"screenWidth",window.screen.width),he(me.metadata,"screenHeight",window.screen.height),he(me.metadata,"windowWidth",window.innerWidth),he(me.metadata,"windowHeight",window.innerHeight),he(me.metadata,"mapWidth",D.width/X),he(me.metadata,"mapHeight",D.height/X),he(me.metadata,"webglRenderer",D.renderer),he(me.metadata,"webglVendor",D.vendor),he(me.metadata,"sdkVersion",d),he(me.metadata,"sdkIdentifier","mapbox-gl-js"),me}(x);for(const D of T.metadata);for(const D of T.counters);for(const D of T.attributes);this.postEvent(h,T,()=>{},C)}},Rt=Le.postPerformanceEvent.bind(Le),fe=new class extends be{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(C,h,x,T){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const D=oe(i.e.API_URL+i.e.SESSION_PATH);D.params.push(`sku=${h||""}`),D.params.push(`access_token=${T||i.e.ACCESS_TOKEN||""}`);const R={url:le(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(R,z=>{this.pendingRequest=null,x(z),this.saveEventData(),this.processRequests(T)})}getSessionAPI(C,h,x,T){this.skuToken=h,this.errorCb=T,i.e.SESSION_PATH&&i.e.API_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:C,timestamp:Date.now()},x):this.errorCb(new Error(te)))}processRequests(C){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:x}=this.queue.shift();h&&this.success[h]||this.getSession(x,this.skuToken,T=>{T?this.errorCb(T):h&&(this.success[h]=!0)},C)}remove(){this.errorCb=null}},Qe=fe.getSessionAPI.bind(fe),at=new Set;function rt(C,h){h?at.add(C):at.delete(C)}class je{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,x){this._updatedSourceCaches[h]=x,this.setDirty()}discardSourceCacheUpdate(h){delete this._updatedSourceCaches[h]}updateLayer(h){const x=h.scope;this._updatedLayers[x]=this._updatedLayers[x]||new Set,this._updatedLayers[x].add(h.id),this.setDirty()}removeLayer(h){const x=h.scope;this._removedLayers[x]=this._removedLayers[x]||{},this._updatedLayers[x]=this._updatedLayers[x]||new Set,this._removedLayers[x][h.id]=h,this._updatedLayers[x].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 x in this._updatedLayers)h[x]=h[x]||{},h[x].updatedIds=Array.from(this._updatedLayers[x].values());for(const x in this._removedLayers)h[x]=h[x]||{},h[x].removedIds=Object.keys(this._removedLayers[x]);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,x){this._updatedImages[x]=this._updatedImages[x]||new Set,this._updatedImages[x].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 mt(C){const{userImage:h}=C;return!!(h&&h.render&&h.render())&&(C.data.replace(new Uint8Array(h.data.buffer)),!0)}class He extends i.E{constructor(h){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.dirty=!0,this.spriteFormat=h,h!=="raster"&&i.r()&&(this.imageRasterizerDispatcher=new i.D(i.t(),this,"Image Rasterizer Worker",1))}addScope(h){this.loaded.set(h,!1),this.imageProviders.set(h,new Map),this.images.set(h,new Map),this.updatedImages.set(h,new Set),this.callbackDispatchedThisFrame.set(h,new Set),this.patterns.set(h,new Map),this.atlasImage.set(h,new i.q({width:1,height:1}))}removeScope(h){this.loaded.delete(h),this.imageProviders.delete(h),this.images.delete(h),this.updatedImages.delete(h),this.callbackDispatchedThisFrame.delete(h),this.patterns.delete(h),this.atlasImage.delete(h);const x=this.atlasTexture.get(h);x&&(x.destroy(),this.atlasTexture.delete(h))}addImageProvider(h,x){this.imageProviders.has(x)||this.imageProviders.set(x,new Map),this.imageProviders.get(x).set(h.id,h)}removeImageProvider(h,x){this.imageProviders.has(x)&&this.imageProviders.get(x).delete(h)}getPendingImageProviders(){const h=[];for(const x of this.imageProviders.values())for(const T of x.values())T.hasPendingRequests()&&h.push(T);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,x){if(this.loaded.get(x)!==h&&(this.loaded.set(x,h),h)){for(const{ids:T,callback:D}of this.requestors)this._notify(T,x,D);this.requestors=[]}}hasImage(h,x){return!!this.getImage(h,x)}getImage(h,x){return this.images.get(x).get(h.toString())}addImage(h,x,T){this._validate(h,T)&&this.images.get(x).set(h.toString(),T)}_validate(h,x){let T=!0;return this._validateStretch(x.stretchX,x.data&&x.data.width)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchX" value`))),T=!1),this._validateStretch(x.stretchY,x.data&&x.data.height)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchY" value`))),T=!1),this._validateContent(x.content,x)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "content" value`))),T=!1),T}_validateStretch(h,x){if(!h)return!0;let T=0;for(const D of h){if(D[0]i.I.from(x))}getImages(h,x,T){const D=[],R=[],z=this.imageProviders.get(x);for(const ae of h){if(!ae.iconsetId){D.push(ae);continue}const me=z.get(ae.iconsetId);me&&(this.getImage(ae,x)?R.push(ae):me.addPendingRequest(ae))}if(D.length===0)return void this._notify(R,x,T);let V=!0;const X=!!this.loaded.get(x),re=this.images.get(x);if(!X)for(const ae of D)re.has(ae.toString())||(V=!1);X||V?this._notify(D,x,T):this.requestors.push({ids:D,scope:x,callback:T})}rasterizeImages(h,x){const T=new Map,{tasks:D,scope:R}=h;for(const[z,V]of D.entries()){const X=this.getImage(V.id,R);X&&T.set(z,{image:X,imageVariant:V})}this._rasterizeImages(R,T,x)}_rasterizeImages(h,x,T){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:x,scope:h},T);else{const D=new Map;for(const[R,{image:z,imageVariant:V}]of x.entries())D.set(R,this.imageRasterizer.rasterize(V,z,h,0));T(void 0,D)}}getUpdatedImages(h){return this.updatedImages.get(h)||new Set}_notify(h,x,T){const D=this.images.get(x),R=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 V=D.get(z.toString());if(!V){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 X={data:V.usvg?null:V.data.clone(),pixelRatio:V.pixelRatio,sdf:V.sdf,usvg:V.usvg,version:V.version,stretchX:V.stretchX,stretchY:V.stretchY,content:V.content,hasRenderCallback:!!(V.userImage&&V.userImage.render)};V.usvg&&Object.assign(X,{width:V.icon.usvg_tree.width,height:V.icon.usvg_tree.height}),R.set(i.I.toString(z),X)}T(null,R)}getPixelSize(h){const{width:x,height:T}=this.atlasImage.get(h);return{width:x,height:T}}getPattern(h,x,T){const D=h.toString(),R=this.patterns.get(x),z=R.get(D),V=this.getImage(h,x);if(!V)return null;if(z){if(z.position.version===V.version)return z.position;z.position.version=V.version}else{if(V.usvg&&!V.data){const X=this.getPatternInFlightId(D,x);if(this.patternsInFlight.has(X))return null;this.patternsInFlight.add(X);const re=new i.A(h).scaleSelf(i.o.devicePixelRatio),ae=new Map([[re.toString(),{image:V,imageVariant:re}]]);return this._rasterizeImages(x,ae,(me,he)=>this.storePatternImage(re,x,V,T,he)),null}this.storePattern(h,x,V)}return this._updatePatternAtlas(x,T),R.get(D).position}getPatternInFlightId(h,x){return i.B(h,x)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,x,T,D,R){const z=h.toString(),V=R?R.get(z):void 0;V&&(T.data=V,this.storePattern(h.id,x,T),this._updatePatternAtlas(x,D),this.patternsInFlight.delete(this.getPatternInFlightId(h.id.toString(),x)))}storePattern(h,x,T){const D={w:T.data.width+2*i.C,h:T.data.height+2*i.C,x:0,y:0},R=new i.F(D,T,i.C);this.patterns.get(x).set(h.toString(),{bin:D,position:R})}destroyAtlasTextures(){for(const h of this.atlasTexture.values())h&&h.destroy();this.atlasTexture.clear()}bind(h,x){const T=h.gl;let D=this.atlasTexture.get(x);D?this.dirty&&(D.update(this.atlasImage.get(x)),this.dirty=!1):(D=new i.T(h,this.atlasImage.get(x),T.RGBA8),this.atlasTexture.set(x,D)),D.bind(T.LINEAR,T.CLAMP_TO_EDGE)}_updatePatternAtlas(h,x){const T=this.patterns.get(h),D=Array.from(T.values()).map(({bin:re})=>re),{w:R,h:z}=i.G(D),V=this.atlasImage.get(h);V.resize({width:R||1,height:z||1});const X=this.images.get(h);for(const[re,{bin:ae,position:me}]of T.entries()){let he=me.padding;const pe=ae.x+he,Me=ae.y+he,Ce=X.get(re).data,$e=Ce.width,Be=Ce.height;he=he>1?he-1:he,i.q.copy(Ce,V,{x:0,y:0},{x:pe,y:Me},{width:$e,height:Be},x),i.q.copy(Ce,V,{x:0,y:Be-he},{x:pe,y:Me-he},{width:$e,height:he},x),i.q.copy(Ce,V,{x:0,y:0},{x:pe,y:Me+Be},{width:$e,height:he},x),i.q.copy(Ce,V,{x:$e-he,y:0},{x:pe-he,y:Me},{width:he,height:Be},x),i.q.copy(Ce,V,{x:0,y:0},{x:pe+$e,y:Me},{width:he,height:Be},x),i.q.copy(Ce,V,{x:$e-he,y:Be-he},{x:pe-he,y:Me-he},{width:he,height:he},x),i.q.copy(Ce,V,{x:0,y:Be-he},{x:pe+$e,y:Me-he},{width:he,height:he},x),i.q.copy(Ce,V,{x:0,y:0},{x:pe+$e,y:Me+Be},{width:he,height:he},x),i.q.copy(Ce,V,{x:$e-he,y:0},{x:pe-he,y:Me+Be},{width:he,height:he},x)}this.dirty=!0}beginFrame(){for(const h of this.images.keys())this.callbackDispatchedThisFrame.set(h,new Set)}dispatchRenderCallbacks(h,x){const T=this.images.get(x);for(const D of h){if(this.callbackDispatchedThisFrame.get(x).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(x).add(D.toString());const R=T.get(D.toString());mt(R)&&this.updateImage(D,x,R)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function ct(C){const h=C.value,x=C.valueSpec,T=C.style,D=C.styleSpec,R=C.key,z=C.arrayElementValidator||yn;if(!Array.isArray(h))return[new i.V(R,h,`array expected, ${i.K(h)} found`)];if(x.length&&h.length!==x.length)return[new i.V(R,h,`array length ${x.length} expected, length ${h.length} found`)];if(x["min-length"]&&h.lengthD)return[new i.V(h,x,`${x} is greater than the maximum value ${D}`)]}return[]}function Ze(C){const h=C.key,x=C.value;if(!i.H(x))return[new i.V(h,x,`object expected, ${i.K(x)} found`)];const T=C.valueSpec,D=i.J(x.type);let R,z,V,X={};const re=D!=="categorical"&&x.property===void 0,ae=!re,me=function(Ce){const $e=Ce.stops;return Array.isArray($e)&&Array.isArray($e[0])&&i.H($e[0][0])}(x),he=ea({key:C.key,value:C.value,valueSpec:C.styleSpec.function,style:C.style,styleSpec:C.styleSpec,objectElementValidators:{stops:function(Ce){if(D==="identity")return[new i.V(Ce.key,Ce.value,'identity function may not have a "stops" property')];let $e=[];const Be=Ce.value;return $e=$e.concat(ct({key:Ce.key,value:Be,valueSpec:Ce.valueSpec,style:Ce.style,styleSpec:Ce.styleSpec,arrayElementValidator:pe})),Array.isArray(Be)&&Be.length===0&&$e.push(new i.V(Ce.key,Be,"array must have at least one stop")),$e},default:function(Ce){return yn({key:Ce.key,value:Ce.value,valueSpec:T,style:Ce.style,styleSpec:Ce.styleSpec})}}});return D==="identity"&&re&&he.push(new i.V(C.key,C.value,'missing required property "property"')),D==="identity"||x.stops||he.push(new i.V(C.key,C.value,'missing required property "stops"')),D==="exponential"&&T.expression&&!i.M(T)&&he.push(new i.V(C.key,C.value,"exponential functions not supported")),C.styleSpec.$version>=8&&(ae&&!i.N(T)?he.push(new i.V(C.key,C.value,"property functions not supported")):re&&!i.O(T)&&he.push(new i.V(C.key,C.value,"zoom functions not supported"))),D!=="categorical"&&!me||x.property!==void 0||he.push(new i.V(C.key,C.value,'"property" property is required')),he;function pe(Ce){let $e=[];const Be=Ce.value,Xe=Ce.key;if(!Array.isArray(Be))return[new i.V(Xe,Be,`array expected, ${i.K(Be)} found`)];if(Be.length!==2)return[new i.V(Xe,Be,`array length 2 expected, length ${Be.length} found`)];if(me){if(!i.H(Be[0]))return[new i.V(Xe,Be,`object expected, ${i.K(Be[0])} found`)];const ot=Be[0];if(ot.zoom===void 0)return[new i.V(Xe,Be,"object stop key must have zoom")];if(ot.value===void 0)return[new i.V(Xe,Be,"object stop key must have value")];const et=i.J(ot.zoom);if(typeof et!="number")return[new i.V(Xe,ot.zoom,"stop zoom values must be numbers")];if(V&&V>et)return[new i.V(Xe,ot.zoom,"stop zoom values must appear in ascending order")];et!==V&&(V=et,z=void 0,X={}),$e=$e.concat(ea({key:`${Xe}[0]`,value:Be[0],valueSpec:{zoom:{}},style:Ce.style,styleSpec:Ce.styleSpec,objectElementValidators:{zoom:We,value:Me}}))}else $e=$e.concat(Me({key:`${Xe}[0]`,value:Be[0],style:Ce.style,styleSpec:Ce.styleSpec},Be));return i.Q(i.S(Be[1]))?$e.concat([new i.V(`${Xe}[1]`,Be[1],"expressions are not allowed in function stops.")]):$e.concat(yn({key:`${Xe}[1]`,value:Be[1],valueSpec:T,style:Ce.style,styleSpec:Ce.styleSpec}))}function Me(Ce,$e){const Be=i.K(Ce.value),Xe=i.J(Ce.value),ot=Ce.value!==null?Ce.value:$e;if(R){if(Be!==R)return[new i.V(Ce.key,ot,`${Be} stop domain type must match previous stop domain type ${R}`)]}else R=Be;if(Be!=="number"&&Be!=="string"&&Be!=="boolean"&&typeof Xe!="number"&&typeof Xe!="string"&&typeof Xe!="boolean")return[new i.V(Ce.key,ot,"stop domain value must be a number, string, or boolean")];if(Be!=="number"&&D!=="categorical"){let et=`number expected, ${Be} found`;return i.N(T)&&D===void 0&&(et+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Ce.key,ot,et)]}return D!=="categorical"||Be!=="number"||typeof Xe=="number"&&isFinite(Xe)&&Math.floor(Xe)===Xe?D!=="categorical"&&Be==="number"&&typeof Xe=="number"&&typeof z=="number"&&z!==void 0&&Xenew i.V(`${C.key}${T.key}`,C.value,T.message));const x=h.value.expression||h.value._styleExpression.expression;if(C.expressionContext==="property"&&C.propertyKey==="text-font"&&!x.outputDefined())return[new i.V(C.key,C.value,`Invalid data expression for "${C.propertyKey}". Output values must be contained as literals within the expression.`)];if(C.expressionContext==="property"&&C.propertyType==="layout"&&!i.Z(x))return[new i.V(C.key,C.value,'"feature-state" data expressions are not supported with layout properties.')];if(C.expressionContext==="filter")return Ke(x,C);if(C.expressionContext==="appearance")return qe(x,C);if(C.expressionContext&&C.expressionContext.indexOf("cluster")===0){if(!i.X(x,["zoom","feature-state"]))return[new i.V(C.key,C.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(C.expressionContext==="cluster-initial"&&!i.Y(x))return[new i.V(C.key,C.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ke(C,h){const x=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)x.delete(D);if(x.size===0)return[];const T=[];return C instanceof i._&&x.has(C.name)?[new i.V(h.key,h.value,`["${C.name}"] expression is not supported in a filter for a ${h.object.type} layer with id: ${h.object.id}`)]:(C.eachChild(D=>{T.push(...Ke(D,h))}),T)}function qe(C,h){const x=new Set;if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)x.add(D);if(x.size===0)return[];const T=[];return C instanceof i._&&!x.has(C.name)?[new i.V(h.key,h.value,`["${C.name}"] is not an allowed parameter`)]:(C.eachChild(D=>{T.push(...qe(D,h))}),T)}function Je(C){const h=C.key,x=C.value,T=C.valueSpec,D=[];return Array.isArray(T.values)?T.values.indexOf(i.J(x))===-1&&D.push(new i.V(h,x,`expected one of [${T.values.join(", ")}], ${JSON.stringify(x)} found`)):Object.keys(T.values).indexOf(i.J(x))===-1&&D.push(new i.V(h,x,`expected one of [${Object.keys(T.values).join(", ")}], ${JSON.stringify(x)} found`)),D}function Lt(C){return i.a2(i.S(C.value))?ht(Object.assign({},C,{expressionContext:"filter",valueSpec:C.styleSpec[`filter_${C.layerType||"fill"}`]})):zt(C)}function zt(C){const h=C.value,x=C.key;if(!Array.isArray(h))return[new i.V(x,h,`array expected, ${i.K(h)} found`)];if(h.length<1)return[new i.V(x,h,"filter array must have at least 1 element")];const T=C.styleSpec;let D=Je({key:`${x}[0]`,value:h[0],valueSpec:T.filter_operator});const R=()=>{h.length>=2&&(i.a0(h[1])||D.push(new i.V(`${x}[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(x,h,`"$type" cannot be use with operator "${h[0]}"`)),h.length!==3&&D.push(new i.V(x,h,`filter array for operator "${h[0]}" must have 3 elements`)),R();break;case"==":case"!=":h.length!==3&&D.push(new i.V(x,h,`filter array for operator "${h[0]}" must have 3 elements`)),R();break;case"in":case"!in":R();break;case"any":case"all":case"none":for(let z=1;z{re in x&&h.push(new i.V(T,x[re],`"${re}" is prohibited for ref layers`))}),D.layers.forEach(re=>{i.J(re.id)===V&&(X=re)}),X?X.ref?h.push(new i.V(T,x.ref,"ref cannot reference another ref layer")):z=i.J(X.type):typeof V=="string"&&h.push(new i.V(T,x.ref,`ref layer "${V}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(x.source)if(i.a0(x.source)){const X=D.sources&&D.sources[x.source],re=X&&i.J(X.type);X?re==="vector"&&z==="raster"?h.push(new i.V(T,x.source,`layer "${x.id}" requires a raster source`)):re==="raster"&&z!=="raster"?h.push(new i.V(T,x.source,`layer "${x.id}" requires a vector source`)):re!=="vector"||x["source-layer"]?re==="raster-dem"&&z!=="hillshade"?h.push(new i.V(T,x.source,"raster-dem source can only be used with layer type 'hillshade'.")):re!=="raster-array"||["raster","raster-particle"].includes(z)?z==="line"&&x.paint&&(x.paint["line-gradient"]||x.paint["line-trim-offset"])&&re==="geojson"&&!X.lineMetrics?h.push(new i.V(T,x,`layer "${x.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):z==="raster-particle"&&re!=="raster-array"&&h.push(new i.V(T,x.source,`layer "${x.id}" requires a 'raster-array' source.`)):h.push(new i.V(T,x.source,"raster-array source can only be used with layer type 'raster'.")):h.push(new i.V(T,x,`layer "${x.id}" must specify a "source-layer"`)):h.push(new i.V(T,x.source,`source "${x.source}" not found`))}else h.push(new i.V(`${T}.source`,x.source,'"source" must be a string'));else h.push(new i.V(T,x,'missing required property "source"'));return h=h.concat(ea({key:T,value:x,valueSpec:R.layer,style:C.style,styleSpec:C.styleSpec,objectElementValidators:{"*":()=>[],type:()=>yn({key:`${T}.type`,value:x.type,valueSpec:R.layer.type,style:C.style,styleSpec:C.styleSpec,object:x,objectKey:"type"}),filter:X=>Lt(Object.assign({layerType:z},X)),layout:X=>ea({layer:x,key:X.key,value:X.value,valueSpec:{},style:X.style,styleSpec:X.styleSpec,objectElementValidators:{"*":re=>Qt(Object.assign({layerType:z},re))}}),paint:X=>ea({layer:x,key:X.key,value:X.value,valueSpec:{},style:X.style,styleSpec:X.styleSpec,objectElementValidators:{"*":re=>Kt(Object.assign({layerType:z,layer:x},re))}}),appearances(X){const re=ct({key:X.key,value:X.value,valueSpec:X.valueSpec,style:X.style,styleSpec:X.styleSpec,arrayElementValidator:he=>function(pe){const{key:Me,layer:Ce,layerType:$e}=pe,Be=i.J(pe.value),Xe=i.J(Be.name),ot=i.J(Be.condition),et=ea({key:Me,value:Be,valueSpec:pe.styleSpec.appearance,style:pe.style,styleSpec:pe.styleSpec,objectElementValidators:{condition:Ct=>function(vt){const jt=[];return jt.push(...ht({key:vt.key,value:vt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),jt}(Object.assign({layer:Ce,layerType:$e},Ct)),properties:Ct=>function(vt){const jt=[],{styleSpec:xt,layer:pt,layerType:Et}=vt,Ht=xt[`paint_${Et}`],Ut=xt[`layout_${Et}`],ts=vt.object[vt.objectKey];for(const ss in ts){const ps=ss in Ht?"paint":ss in Ut?"layout":void 0;if(!ps){jt.push(new i.V(vt.key,ss,`unknown property "${ss}" for layer type "${Et}"`));continue}const zs=Object.assign({},vt,{key:`${vt.key}.${ss}`,object:ts,objectKey:ss,layer:pt,layerType:Et,value:ts[ss],valueSpec:ps==="paint"?Ht[ss]:Ut[ss]});jt.push(...is(zs,ps))}return jt}(Object.assign({layer:Ce,layerType:$e},Ct))}});return Xe!=="hidden"&&ot===void 0&&et.push(new i.V(pe.key,"name",'Appearance with name different than "hidden" must have a condition')),et}(Object.assign({layerType:z,layer:x},he))}),ae=Array.isArray(X.value)?X.value:[],me=new Set;return ae.forEach((he,pe)=>{const Me=i.J(he.name);if(Me)if(me.has(Me)){const Ce=i.J(x.id);re.push(new i.V(X.key,Me,`Duplicated appearance name "${Me}" for layer "${Ce}"`))}else me.add(Me)}),re}}})),h}function dr({key:C,value:h}){return i.a0(h)?[]:[new i.V(C,h,`string expected, ${i.K(h)} found`)]}const bt={promoteId:function C({key:h,value:x}){if(i.a0(x))return dr({key:h,value:x});if(Array.isArray(x)){const D=[],R=i.S(x),z=i.U(R);return z.result==="error"&&z.value.forEach(V=>{D.push(new i.V(`${h}${V.key}`,null,`${V.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(x))return[new i.V(h,x,`string, expression or object expected, "${i.K(x)}" found`)];const T=[];for(const D in x)T.push(...C({key:`${h}.${D}`,value:x[D]}));return T}};function ws(C){const h=C.value,x=C.key,T=C.styleSpec,D=C.style;if(!i.H(h))return[new i.V(x,h,`object expected, ${i.K(h)} found`)];if(!("type"in h))return[new i.V(x,h,'"type" is required')];const R=i.J(h.type);let z=[];switch(["vector","raster","raster-dem","raster-array"].includes(R)&&("url"in h||"tiles"in h||z.push(new i.a3(x,h,'Either "url" or "tiles" is required.'))),R){case"vector":case"raster":case"raster-dem":case"raster-array":return z=z.concat(ea({key:x,value:h,valueSpec:T[`source_${R.replace("-","_")}`],style:C.style,styleSpec:T,objectElementValidators:bt})),z;case"geojson":if(z=ea({key:x,value:h,valueSpec:T.source_geojson,style:D,styleSpec:T,objectElementValidators:bt}),"cluster"in h&&"clusterProperties"in h){if(!i.H(h.clusterProperties))return[new i.V(`${x}.clusterProperties`,h,`object expected, ${i.K(h)} found`)];for(const V in h.clusterProperties){const X=h.clusterProperties[V];if(!Array.isArray(X))return[new i.V(`${x}.clusterProperties.${V}`,X,"array expected")];const[re,ae]=X,me=typeof re=="string"?[re,["accumulated"],["get",V]]:re;z.push(...ht({key:`${x}.${V}.map`,value:ae,expressionContext:"cluster-map"})),z.push(...ht({key:`${x}.${V}.reduce`,value:me,expressionContext:"cluster-reduce"}))}}return z;case"video":return ea({key:x,value:h,valueSpec:T.source_video,style:D,styleSpec:T});case"image":return ea({key:x,value:h,valueSpec:T.source_image,style:D,styleSpec:T});case"canvas":return[new i.V(x,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Je({key:`${x}.type`,value:h.type,valueSpec:{values:ir(T)}})}}function ir(C){return C.source.reduce((h,x)=>{const T=C[x];return T.type.type==="enum"&&(h=h.concat(Object.keys(T.type.values||{}))),h},[])}function Rr(C){const h=C.value,x=C.styleSpec,T=x.light,D=C.style;if(h===void 0)return[];if(!i.H(h))return[new i.V("light",h,`object expected, ${i.K(h)} found`)];let R=[];for(const z in h){const V=z.match(/^(.*)-transition$/),X=z.match(/^(.*)-use-theme$/);R=R.concat(X&&T[X[1]]?yn({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:x}):V&&T[V[1]]&&T[V[1]].transition?yn({key:z,value:h[z],valueSpec:x.transition,style:D,styleSpec:x}):T[z]?yn({key:z,value:h[z],valueSpec:T[z],style:D,styleSpec:x}):[new i.V(z,h[z],`unknown property "${z}"`)])}return R}function oa(C){const h=C.value;if(!h)return[];const x=C.key;if(!i.H(h))return[new i.V(x,h,`object expected, ${i.K(h)} found`)];let T=[];const D=C.styleSpec,R=D["light-3d"],z=C.style,V=C.style.lights;for(const ae of["type","id"])if(!(ae in h))return T=T.concat([new i.V(x,h,`missing property "${ae}"`)]),T;if(!i.a0(h.type))return T=T.concat([new i.V(`${x}.type`,h.type,"string expected")]),T;if(V)for(let ae=0;ae[],array:ct,boolean:function(C){const h=C.value,x=C.key;return i.$(h)?[]:[new i.V(x,h,`boolean expected, ${i.K(h)} found`)]},number:We,color:function({key:C,value:h}){return i.a0(h)?i.a1.parseCSSColor(h)===null?[new i.V(C,h,`color expected, "${h}" found`)]:[]:[new i.V(C,h,`color expected, ${i.K(h)} found`)]},enum:Je,filter:Lt,function:Ze,layer:fs,object:ea,source:ws,model:i.a7,light:Rr,"light-3d":oa,terrain:ri,fog:no,string:dr,formatted:function(C){return dr(C).length===0?[]:ht(C)},resolvedImage:function(C){return dr(C).length===0?[]:ht(C)},projection:function(C){const h=C.value,x=C.styleSpec,T=x.projection,D=C.style;if(i.H(h)){let R=[];for(const z in h)R=R.concat(yn({key:z,value:h[z],valueSpec:T[z],style:D,styleSpec:x}));return R}return i.a0(h)?[]:[new i.V("projection",h,`object or string expected, ${i.K(h)} found`)]},import:function(C){const h=C.key,{value:x,styleSpec:T}=C;if(!i.H(x))return[new i.V(h,x,"import must be an object")];const{data:D,...R}=x;Object.defineProperty(R,"__line__",{value:x.__line__,enumerable:!1});let z=ea(Object.assign({},C,{value:R,valueSpec:T.import}));return i.J(R.id)===""&&z.push(new i.V(`${C.key}.id`,R,"import id can't be an empty string")),D&&(z=z.concat(yr(D,T,{key:`${C.key}.data`}))),z},iconset:function(C){const h=C.value,x=C.key,T=C.styleSpec,D=C.style;if(!i.H(h))return[new i.V(x,h,"object expected")];if(!h.type)return[new i.V(x,h,'"type" is required')];const R=i.J(h.type);let z=[];if(z=z.concat(ea({key:x,value:h,valueSpec:T[`iconset_${R}`],style:D,styleSpec:T})),function(V,X){return!(V!=="source"||!X.source)}(R,h)){const V=D.sources&&D.sources[h.source],X=V&&i.J(V.type);V?X!=="raster-array"&&z.push(new i.V(x,h.source,`iconset cannot be used with a source of type ${String(X)}, it only be used with a "raster-array" source type`)):z.push(new i.V(x,h.source,`source "${h.source}" not found`))}return z}};function yn(C,h=!1){const x=C.value,T=C.valueSpec,D=C.styleSpec;if(T.expression){if(i.a4(i.J(x)))return Ze(C);if(i.Q(i.S(x)))return ht(C)}if(T.type&&Da[T.type]){const R=Da[T.type](C);return h===!0&&R.length>0&&Array.isArray(C.value)?ht(C):R}return ea(Object.assign({},C,{valueSpec:T.type?D[T.type]:T}))}function ea(C){const h=C.key,x=C.value,T=C.valueSpec||{},D=C.objectElementValidators||{},R=C.style,z=C.styleSpec;if(!i.H(x))return[new i.V(h,x,`object expected, ${i.K(x)} found`)];let V=[];for(const X in x){const re=X.split(".")[0];let ae;D[re]?ae=D[re]:T[re]?ae=yn:D["*"]?ae=D["*"]:T["*"]&&(ae=yn),ae?V=V.concat(ae({key:(h&&`${h}.`)+X,value:x[X],valueSpec:T[re]||T["*"],style:R,styleSpec:z,object:x,objectKey:X},x)):V.push(new i.a3(h,x[X],`unknown property "${X}"`))}for(const X in T){if(D[X])continue;const re=T[X];re.required&&re.default===void 0&&x[X]===void 0&&V.push(new i.V(h,x,`missing required property "${X}"`))}return V}function Zt({key:C,value:h}){const x=dr({key:C,value:h});if(x.length)return x;const T=h;return T.indexOf("{fontstack}")===-1&&x.push(new i.V(C,h,'"glyphs" url must include a "{fontstack}" token')),T.indexOf("{range}")===-1&&x.push(new i.V(C,h,'"glyphs" url must include a "{range}" token')),x}function yr(C,h=i.a6,x={}){return ea({key:x.key||"",value:C,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:C,objectElementValidators:{glyphs:Zt}})}function Gr(C,h=i.a6){return ze(yr(C,h))}const Dn=C=>ze(ws(C)),rs=C=>ze(Rr(C)),An=C=>ze(oa(C)),la=C=>ze(ri(C)),qa=C=>ze(no(C)),Jr=C=>ze(function(h){const x=h.value,T=h.style,D=h.styleSpec,R=D.snow;if(x===void 0)return[];if(!i.H(x))return[new i.V("snow",x,`object expected, ${i.K(x)} found`)];let z=[];for(const V in x){const X=V.match(/^(.*)-transition$/);z=z.concat(X&&R[X[1]]&&R[X[1]].transition?yn({key:V,value:x[V],valueSpec:D.transition,style:T,styleSpec:D}):R[V]?yn({key:V,value:x[V],valueSpec:R[V],style:T,styleSpec:D}):[new i.a3(V,x[V],`unknown property "${V}"`)])}return z}(C)),Ka=C=>ze(function(h){const x=h.value,T=h.style,D=h.styleSpec,R=D.rain;if(x===void 0)return[];if(!i.H(x))return[new i.V("rain",x,`object expected, ${i.K(x)} found`)];let z=[];for(const V in x){const X=V.match(/^(.*)-transition$/);z=z.concat(X&&R[X[1]]&&R[X[1]].transition?yn({key:V,value:x[V],valueSpec:D.transition,style:T,styleSpec:D}):R[V]?yn({key:V,value:x[V],valueSpec:R[V],style:T,styleSpec:D}):[new i.a3(V,x[V],`unknown property "${V}"`)])}return z}(C)),Dl=C=>ze(fs(C)),Lo=C=>ze(Lt(C)),Kc=C=>ze(Kt(C)),it=C=>ze(Qt(C)),Se=C=>ze(i.a7(C));function ze(C){return C.slice().sort((h,x)=>h.line&&x.line?h.line-x.line:0)}function tt(C,h){let x=!1;if(h&&h.length)for(const T of h)T instanceof i.a3?i.w(T.message):(C.fire(new i.y(new Error(T.message))),x=!0);return x}const Mt=i.a6.light;let Nt;class Ot extends i.E{constructor(h,x="flat"){super(),this._transitionable=new i.a8(Nt||(Nt=new i.a9({anchor:new i.aa(Mt.anchor),position:new i.ab(Mt.position),color:new i.aa(Mt.color),intensity:new i.aa(Mt.intensity)}))),this.setLight(h,x),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,x,T={}){this._validate(rs,h,T)||(this._transitionable.setTransitionOrValue(h),this.id=x)}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,x,T){return(!T||T.validate!==!1)&&tt(this,h.call(Gr,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Yt=i.a6.terrain;let qt=class extends i.E{constructor(C,h,x,T,D){super(),this.scope=x,this._transitionable=new i.a8(new i.a9({source:new i.aa(Yt.source),exaggeration:new i.aa(Yt.exaggeration)}),x,T),this._transitionable.setTransitionOrValue(C,T),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=h,this.worldview=D}get(){return this._transitionable.serialize()}set(C,h){this._transitionable.setTransitionOrValue(C,h)}updateTransitions(C){this._transitioning=this._transitionable.transitioned(C,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(C){this.properties=this._transitioning.possiblyEvaluate(C)}getExaggeration(C){return this._transitioning.possiblyEvaluate(new i.ac(C,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const C=this._transitionable._values.exaggeration;if(!C)return null;const h=C.value.expression;if(!h)return null;let x=-1,T=-1,D=1;for(const R of h.zoomStops)D=h.evaluate(new i.ac(R,{worldview:this.worldview})),D>.01?(x=R,T=-1):T=R;return D<.01&&x>0&&T>x?[x,T]:null}isZoomDependent(){const C=this._transitionable._values.exaggeration;return C!=null&&C.value!=null&&C.value.expression!=null&&C.value.expression instanceof i.ad}};const Jt=45,Ps=65,xs=.05;function hr(C,h,x,T){const D=i.ah(Jt,Ps,x),[R,z]=Br(C,T);let V=1-Math.min(1,Math.exp((h-R)/(z-R)*-6));return V*=V*V,V=Math.min(1,1.00747*V),V*D*C.alpha}function Br(C,h){const x=.5/Math.tan(.5*h);return[C.range[0]+x,C.range[1]+x]}function cr(C,h,x,T,D){const R=i.af([],[h,x,T],D.mercatorFogMatrix);return hr(C,i.ag(R),D.pitch,D._fov)}function Nn(C,h,x,T,D,R,z){const V=[[x,T,0],[D,T,0],[D,R,0],[x,R,0]];let X=Number.MAX_VALUE,re=-Number.MAX_VALUE;for(const ae of V){const me=i.af([],ae,h),he=i.ag(me);X=Math.min(X,he),re=Math.max(re,he)}return[hr(C,X,z.pitch,z._fov),hr(C,re,z.pitch,z._fov)]}const Sn=i.a6.fog;class wn extends i.E{constructor(h,x,T,D){super();const R=new i.a9({range:new i.aa(Sn.range),color:new i.aa(Sn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(Sn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(Sn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(Sn["horizon-blend"]),"star-intensity":new i.aa(Sn["star-intensity"]),"vertical-range":new i.aa(Sn["vertical-range"])});this._transitionable=new i.a8(R,T,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=x,this.properties=new i.ai(R),this.scope=T}get state(){const h=this._transform,x=h.projection.name==="globe",T=i.aj(h.zoom),D=this.properties.get("range"),R=[.5,3];return{range:x?[i.ak(R[0],D[0],T),i.ak(R[1],D[1],T)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(h,x,T={}){if(this._validate(qa,h,T))return;const D=Object.assign({},h);for(const R of Object.keys(Sn))D[R]===void 0&&(D[R]=Sn[R].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,x)}getOpacity(h){if(!this._transform.projection.supportsFog)return 0;const x=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.ah(Jt,Ps,h))*x.a}getOpacityAtLatLng(h,x){return this._transform.projection.supportsFog?function(T,D,R){const z=i.ae.fromLngLat(D),V=R.elevation?R.elevation.getAtPointOrZero(z):0;return cr(T,z.x,z.y,V,R)}(this.state,h,x):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const x=this._transform.calculateFogTileMatrix(h.toUnwrapped());return Nn(this.state,x,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,x,T,D,R){return this._transform.projection.supportsFog?Nn(this.state,h,x,T,D,R,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?Br(this.state,h):[0,1]}isVisibleOnFrustum(h){if(!this._transform.projection.supportsFog)return!1;const x=[4,5,6,7];for(const T of x){const D=h.points[T];let R;if(D[2]>=0)R=D;else{const z=h.points[T-4];R=i.am(z,D,z[2]/(z[2]-D[2]))}if(cr(this.state,R[0],R[1],0,this._transform)>=xs)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,x,T){return(!T||T.validate!==!1)&&tt(this,h.call(Gr,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let ca,ao,zo,Ua,Vo=class extends i.E{constructor(C,h,x,T){super();const D=ca||(ca=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,x,new Map(T)),this.set(C,T),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=x}get state(){const C=this.properties.get("opacity"),h=this.properties.get("color"),x=this.properties.get("direction"),T=i.an(x[0]),D=-Math.max(i.an(x[1]),.01),R=[Math.cos(T)*Math.cos(D),Math.sin(T)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette"),V=this.properties.get("vignette-color");return V.a=z,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*C),direction:R,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:V}}get(){return this._transitionable.serialize()}set(C,h,x={}){if(this._validate(Jr,C,x))return;const T=Object.assign({},C),D=i.a6.snow;for(const R of Object.keys(D))T[R]===void 0&&(T[R]=D[R].default);this._options=T,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(C){this._transitionable.setTransitionOrValue(this._options,new Map(C))}updateTransitions(C){this._transitioning=this._transitionable.transitioned(C,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(C){this.properties=this._transitioning.possiblyEvaluate(C)}_validate(C,h,x){return(!x||x.validate!==!1)&&tt(this,C.call(Gr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},Ki=class extends i.E{constructor(C,h,x,T){super();const D=ao||(ao=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,x,new Map(T)),this.set(C,T),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=x}get state(){const C=this.properties.get("opacity"),h=this.properties.get("color"),x=this.properties.get("direction"),T=i.an(x[0]),D=-Math.max(i.an(x[1]),.01),R=[Math.cos(T)*Math.cos(D),Math.sin(T)*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*C),direction:R,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(C,h,x={}){if(this._validate(Ka,C,x))return;const T=Object.assign({},C),D=i.a6.rain;for(const R of Object.keys(D))T[R]===void 0&&(T[R]=D[R].default);this._options=T,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(C){this._transitionable.setTransitionOrValue(this._options,new Map(C))}updateTransitions(C){this._transitioning=this._transitionable.transitioned(C,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(C){this.properties=this._transitioning.possiblyEvaluate(C)}_validate(C,h,x){return(!x||x.validate!==!1)&&tt(this,C.call(Gr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class xa extends i.E{constructor(h,x,T,D){super(),this.scope=T,this._options=h,this.properties=new i.ai(x),this._transitionable=new i.a8(x,T,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,x){this._options=h,this._transitionable.setTransitionOrValue(h.properties,x)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}class Zi{constructor(h,x,T){this.screenBounds=h,this.cameraPoint=T.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=x,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,T)}static createFromScreenPoints(h,x){let T,D;if(h instanceof i.P||typeof h[0]=="number"){const R=i.P.convert(h);T=[R],D=x.isPointAboveHorizon(R)}else{const R=i.P.convert(h[0]),z=i.P.convert(h[1]),V=R.add(z)._div(2);T=[R,z],D=i.aq(R,z).every(X=>x.isPointAboveHorizon(X))&&x.isPointAboveHorizon(V)}return new Zi(T,D,x)}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 x=this.screenBounds[0],T=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(x,T,0,!1);return this.cameraPoint.y>T.y&&(this.cameraPoint.x>x.x&&this.cameraPoint.x=T.x?D[2]=this.cameraPoint:this.cameraPoint.x<=x.x&&(D[3]=this.cameraPoint)),i.ar(D,h)}bufferedCameraGeometryGlobe(h){const x=this.screenBounds[0],T=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(x,T,h),R=this.cameraPoint.clone();switch(3*((R.y>x.y)+(R.y>T.y))+((R.x>x.x)+(R.x>T.x))){case 0:D[0]=R,D[4]=R.clone();break;case 1:D.splice(1,0,R);break;case 2:D[1]=R;break;case 3:D.splice(4,0,R);break;case 5:D.splice(2,0,R);break;case 6:D[3]=R;break;case 7:D.splice(3,0,R);break;case 8:D[2]=R}return D}containsTile(h,x,T,D=0){const R=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/x._pixelsPerMercatorPixel+1,z=T?this._bufferedCameraMercator(R,x):this._bufferedScreenMercator(R,x);let V=h.tileID.wrap+(z.unwrapped?D:0);const X=z.polygon.map($e=>i.as(h.tileTransform,$e,V));if(!i.at(X,0,0,i.al,i.al))return;V=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const re=this.screenGeometryMercator.polygon.map($e=>i.au(h.tileTransform,$e,V)),ae=re.map($e=>new i.P($e[0],$e[1])),me=x.getFreeCameraOptions().position||new i.ae(0,0,0),he=i.au(h.tileTransform,me,V),pe=re.map($e=>{const Be=i.av($e,$e,he);return i.aw(Be,Be),new i.ax(he,Be)}),Me=i.ay(h,1,x.zoom)*x._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:ae,tilespaceRays:pe,bufferedTilespaceGeometry:X,bufferedTilespaceBounds:(Ce=i.az(X),Ce.min.x=i.aA(Ce.min.x,0,i.al),Ce.min.y=i.aA(Ce.min.y,0,i.al),Ce.max.x=i.aA(Ce.max.x,0,i.al),Ce.max.y=i.aA(Ce.max.y,0,i.al),Ce),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:Me};var Ce}_bufferedScreenMercator(h,x){const T=Yi(h);if(this._screenRaycastCache[T])return this._screenRaycastCache[T];{let D;return D=x.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(h),x):{polygon:this.bufferedScreenGeometry(h).map(R=>x.pointCoordinate3D(R)),unwrapped:!0},this._screenRaycastCache[T]=D,D}}_bufferedCameraMercator(h,x){const T=Yi(h);if(this._cameraRaycastCache[T])return this._cameraRaycastCache[T];{let D;return D=x.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(h),x):{polygon:this.bufferedCameraGeometry(h).map(R=>x.pointCoordinate3D(R)),unwrapped:!0},this._cameraRaycastCache[T]=D,D}}_projectAndResample(h,x){const T=function(R,z){const V=i.aB([],z.pixelMatrix,z.globeMatrix),X=[0,-i.aD,0,1],re=[0,i.aD,0,1],ae=[0,0,0,1];i.aC(X,X,V),i.aC(re,re,V),i.aC(ae,ae,V);const me=new i.P(X[0]/X[3],X[1]/X[3]),he=new i.P(re[0]/re[3],re[1]/re[3]),pe=i.aE(R,me)&&X[3]1?mi(R.slice(0,$e),z):[],ot=$enew i.P(ta(jt.x),jt.y)),ot=ot.map(jt=>new i.P(ta(jt.x),jt.y));const et=[...Xe];et.length===0&&et.push(ot[ot.length-1]);const Ct=i.ak(et[et.length-1].y,(ot.length===0?Xe[0]:ot[0]).y,Be);let vt;return vt=pe?[new i.P(0,Ct),new i.P(0,0),new i.P(1,0),new i.P(1,Ct)]:[new i.P(1,Ct),new i.P(1,1),new i.P(0,1),new i.P(0,Ct)],et.push(...vt),ot.length===0?et.push(Xe[0]):et.push(...ot),{polygon:et.map(jt=>new i.ae(jt.x,jt.y)),unwrapped:!1}}(h,x);if(T)return T;const D=function(R,z){let V=!1,X=-1/0,re=0;for(let me=0;meX&&(X=R[me].x,re=me);for(let me=0;me.5&&(pe.x{me.x-=1}),{polygon:R,unwrapped:V}}(mi(h,x).map(R=>new i.P(ta(R.x),R.y)),x);return{polygon:D.polygon.map(R=>new i.ae(R.x,R.y)),unwrapped:D.unwrapped}}}function mi(C,h){return i.aG(C,x=>{const T=h.pointCoordinate3D(x);x.x=T.x,x.y=T.y},1/256)}function ta(C){return C<0?1+C%1:C%1}function Yi(C){return 100*C|0}function tc(C,h,x,T,D){const R=function(V,X){if(V)return D(V);if(X){if(C.url&&X.tiles&&C.tiles&&delete C.tiles,X.variants){if(!Array.isArray(X.variants))return D(new Error("variants must be an array"));for(const ae of X.variants){if(ae==null||typeof ae!="object"||ae.constructor!==Object)return D(new Error("variant must be an object"));if(!Array.isArray(ae.capabilities))return D(new Error("capabilities must be an array"));if(ae.capabilities.length===1&&ae.capabilities[0]==="meshopt"){X=Object.assign(X,ae);break}}}const re=i.aH(Object.assign({},X,C),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);re.tiles=h.canonicalizeTileset(re,C.url),D(null,re)}},z=function(V,X,re){if(!V)return null;if(!X&&!re)return V;re=re||V.worldview_default;const ae=Object.values(V.language||{});if(ae.length===0)return null;const me=Object.values(V.worldview||{});if(me.length===0)return null;const he=ae.every(Me=>Me===X),pe=me.every(Me=>Me===re);return he&&pe?V:X in(V.language_options||{})||re in(V.worldview_options||{})?null:V.language_options&&V.worldview_options?V:null}(C.data,x,T);return z?i.o.frame(()=>R(null,z)):C.url?i.m(h.transformRequest(h.normalizeSourceURL(C.url,null,x,T),i.R.Source),R):i.o.frame(()=>{const{data:V,...X}=C;R(null,X)})}function fc(C,h){const x=Math.pow(2,h.z),T=Math.floor(i.aF(C.getWest())*x),D=Math.floor(i.aJ(C.getNorth())*x),R=Math.ceil(i.aF(C.getEast())*x),z=Math.ceil(i.aJ(C.getSouth())*x);return h.x>=T&&h.x=D&&h.ythis.maxzoom||h.z{if(this._tileJSONRequest=null,this._loaded=!0,D)x&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${x}`),T&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${T}`),this.fire(new i.y(D));else if(R){if(Object.assign(this,R),this.hasWorldviews=!!R.worldview_options,R.worldview_default&&(this.worldviewDefault=R.worldview_default),R.vector_layers){this.vectorLayers=R.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const z of R.vector_layers)this.vectorLayerIds.push(z.id),R.worldview&&R.worldview[z.source]&&this.localizableLayerIds.add(z.id)}this.tileBounds=jd.fromTileJSON(R),ke(R.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,x){const T=h.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(T),R=this.map._requestManager.transformRequest(D,i.R.Tile),z=this.map.style?this.map.style.getLut(this.scope):null,V=z?{image:z.image.clone()}:null,X={request:R,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:V,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(T)&&(X.localizableLayerIds=this.localizableLayerIds),X.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=x:h.request=h.actor.send("reloadTile",X,re.bind(this));else if(h.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready)h.request=h.actor.send("loadTile",X,re.bind(this),void 0,!0);else{const ae=i.aL.call({deduped:this._deduped},X,(me,he)=>{if(me||!he)re.call(this,me);else{const pe=i.aM(he.responseHeaders);X.data={rawData:he.rawData.slice(0),expires:pe.expires,cacheControl:pe.cacheControl},h.actor&&h.actor.send("loadTile",X,re.bind(this),void 0,!0)}},!0);h.request={cancel:ae}}function re(ae,me){return delete h.request,h.aborted?x(null):ae&&ae instanceof i.aN&&ae.status!==404?x(ae):(me&&me.resourceTiming&&(h.resourceTiming=me.resourceTiming),this.map._refreshExpiredTiles&&me&&h.setExpiryData(me),h.loadVectorData(me,this.map.painter),i.aO(this.dispatcher),x(null,me),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,x){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 gl extends i.E{constructor(h,x,T,D){super(),this.id=h,this.dispatcher=T,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"},x),Object.assign(this,i.aH(x,["url","scheme","tileSize"]))}load(h){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const x=this.map.getWorldview();this._tileJSONRequest=tc(this._options,this.map._requestManager,null,x,(T,D)=>{this._tileJSONRequest=null,this._loaded=!0,T?this.fire(new i.y(T)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(R=>R.id)),this.tileBounds=jd.fromTileJSON(D),ke(D.tiles),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),h&&h(T)})}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,x){const T=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),T,this.tileSize);h.request=i.n(this.map._requestManager.transformRequest(D,i.R.Tile),(R,z,V)=>{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(R)return h.state="errored",x(R);if(!z)return x(null);const X=i.aM(V);this.map._refreshExpiredTiles&&h.setExpiryData(X),h.setTexture(z,this.map.painter),h.state="loaded",i.aO(this.dispatcher),x(null)})}abortTile(h,x){h.request&&(h.request.cancel(),delete h.request),x&&x()}unloadTile(h,x){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(),x&&x()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function gu([C,h],x,T,{scaled:D=!0}={}){const{tileSize:R,buffer:z}=T,{x:V,y:X,z:re}=x;if(!isFinite(V)||!isFinite(X)||!isFinite(re))throw new Error("Invalid MRT header");const ae=2**re,me=ae*i.aF(C),he=ae*i.aJ(h);return function([pe,Me],Ce,{scaled:$e=!0}={}){if(!Ce)throw new Error("bandView is undefined");const{data:Be,tileSize:Xe,buffer:ot,offset:et,scale:Ct,dimension:vt}=Ce;if(pe<-ot||pe>Xe+ot||Me<-ot||Me>Xe+ot)throw new Error(`Point (${pe}, ${Me}) out of bounds for tileSize=${Xe}, buffer=${ot}`);const jt=(Me+ot)*(Xe+2*ot)+(pe+ot);if(new Uint32Array(Be.buffer)[jt]===4294967295)return null;let xt=[];xt=$e?[]:new Ce.data.constructor(vt);for(let pt=0;pt{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(V)return V.name==="AbortError"?void 0:(h.state="errored",x(V));if(this.map._refreshExpiredTiles&&X){const ae=i.aM(re);h.setExpiryData(ae)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!X)return x(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=X}x(null)};h.request=this.partial?h.fetchHeader(void 0,z.bind(this)):h.actor.send("loadTile",R,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,x){const T=h.texturePerLayer;if(h.flushAllQueues(),T.size){h.destroy(!1);for(const D of T.values())this.map.painter.saveTileTexture(D)}else h.destroy()}prepareTile(h,x,T,D){h._isHeaderLoaded&&(h.state!=="empty"&&(h.state="reloading"),h.fetchBandForRender(x,T,D,(R,z)=>{if(R)return h.state="errored",this.fire(new i.y(R)),void this.triggerRepaint(h);z&&(h._isHeaderLoaded=!0,h.setTexturePerLayer(T,z,this.map.painter),h.state="loaded",this.triggerRepaint(h))}))}getInitialBand(h){if(!this.rasterLayers)return 0;const x=this.rasterLayers.find(({id:R})=>R===h),T=x&&x.fields,D=T&&T.bands&&T.bands;return D?D[0]:0}getTextureDescriptor(h,x,T){if(!h)return;const D=x.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let R=null;x instanceof i.aR?R=x.paint.get("raster-array-band"):x instanceof i.aS&&(R=x.paint.get("raster-particle-array-band"));const z=R||this.getInitialBand(D);if(z==null)return;if(!h.textureDescriptorPerLayer.get(x.id))return void this.prepareTile(h,D,x.id,z);if(h.updateNeeded(x.id,z)&&!T)return;const V=h.textureDescriptorPerLayer.get(x.id);return Object.assign({},V,{texture:h.texturePerLayer.get(x.id)})}getImages(h,x){const T=new Map;for(const D of h)for(const R of x){const[z,V]=R.split("/"),X=D.getLayer(z);if(!X||!X.hasBand(V)||!X.hasDataForBand(V))continue;const{bytes:re,tileSize:ae,buffer:me}=X.getBandView(V),he=ae+2*me,pe={data:new i.q({width:he,height:he},re),pixelRatio:2,sdf:!1,usvg:!1,version:0};T.set(R,pe)}return T}queryRasterArrayValueByBandId(h,x,T){const D=x._mrt;return new Promise(R=>{const z={},V=new Set;for(const[X,re]of Object.entries(D.layers)){if(T.layerName&&X!==T.layerName)continue;const ae={};z[X]=ae;for(const{bands:me}of re.dataIndex)for(const he of me)T.bands&&!T.bands.includes(he)||(V.add(i.B(X,he)),x.fetchBand(X,null,he,pe=>{i.o.frame(()=>{ae[he]=pe?null:gu([h.lng,h.lat],D,re.getBandView(he)),V.delete(i.B(X,he)),V.size===0&&R(z)})},!1))}V.size===0&&R(z)})}_loadTileForQuery(h,x){if(this._loadTileLoaded[h.uid])return void x(null,h._mrt);if(this._loadTilePending[h.uid])return void this._loadTilePending[h.uid].push(x);this._loadTilePending[h.uid]=[x];const T=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(T,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},(R,z,V)=>{if(R)return this._loadTilePending[h.uid].forEach(X=>X(R,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(X=>X(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const X=i.aM(V);h.setExpiryData(X)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(X=>X(null,z)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,x,T){return new Promise((D,R)=>{this._loadTileForQuery(x,(z,V)=>{z?R(z):D(V?this.queryRasterArrayValueByBandId(h,x,T):null)})})}queryRasterArrayValue(h,x){const T=i.aT.convert(h),D=this.findLoadedParent(T);return D&&D._mrt?x.bands||!this.partial?this.queryRasterArrayValueByBandId(T,D,x):this.queryRasterArrayValueByAllBands(T,D,x):Promise.resolve(null)}findLoadedParent(h){const x=i.ae.fromLngLat(h,this.map.transform.tileSize),T=this.maxzoom+1,D=1<0&&(V[new i.aQ(C.overscaledZ,D,h.z,T,h.y-1).key]={backfilled:!1},V[new i.aQ(C.overscaledZ,C.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},V[new i.aQ(C.overscaledZ,z,h.z,R,h.y-1).key]={backfilled:!1}),h.y+1{if(this._loaded=!0,this._pendingLoad=null,T)this.fire(new i.y(T));else{const R={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&D&&D.resourceTiming&&D.resourceTiming[this.id]&&(R.resourceTiming=D.resourceTiming[this.id]),C&&(this._partialReload=!0),this.fire(new i.z("data",R)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(C),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const C=i.B(this.id,this.scope);this.map.style.clearSource(C),this._updateWorkerData()}loadTile(C,h){const x=C.actor?"reloadTile":"loadTile";C.actor=this.actor;const T=this.map.style?this.map.style.getLut(this.scope):null,D=T?{image:T.image.clone()}:null,R=this._partialReload,z={type:this.type,uid:C.uid,tileID:C.tileID,tileZoom:C.tileZoom,zoom:C.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:C.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:R,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};C.request=this.actor.send(x,z,(V,X)=>R&&!X?(C.state="loaded",h(null)):(delete C.request,C.destroy(!1),C.aborted?h(null):V?h(V):(C.loadVectorData(X,this.map.painter,x==="reloadTile"),h(null))),void 0,x==="loadTile")}abortTile(C){C.request&&(C.request.cancel(),delete C.request),C.aborted=!0}unloadTile(C,h){this.actor.send("removeTile",{uid:C.uid,type:this.type,source:this.id,scope:this.scope}),C.destroy()}onRemove(C){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(C,h,x,T){super(C,h,x,T),this.roundZoom=!0,this.type="video",this.options=h}load(){this._loaded=!1;const C=this.options;this.urls=[];for(const h of C.urls)this.urls.push(this.map._requestManager.transformRequest(h,i.R.Source).url);i.aV(this.urls,(h,x)=>{this._loaded=!0,h?this.fire(new i.y(h)):x&&(this.video=x,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(C){if(this.video){const h=this.video.seekable;Ch.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=C}}getVideo(){return this.video}onAdd(C){this.map||(this.map=C,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 C=this.map.painter.context,h=C.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(C,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(C)}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(C,h,x,T){super(),this.type="batched-model",this.id=C,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=x,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(T)}onAdd(C){this.map=C,this.load()}reload(){this.cancelTileJSONRequest();const C=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(C))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(C){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,x=this.map.getWorldview();this._tileJSONRequest=tc(this._options,this.map._requestManager,h,x,(T,D)=>{this._tileJSONRequest=null,this._loaded=!0,T?(h&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${h}`),x&&x.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${x}`),this.fire(new i.y(T))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new jd(D.bounds,this.minzoom,this.maxzoom)),ke(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"}))),C&&C(T)})}hasTransition(){return!1}hasTile(C){return!this.tileBounds||this.tileBounds.contains(C.canonical)}loaded(){return this._loaded}loadTile(C,h){const x=this.map._requestManager.normalizeTileURL(C.tileID.canonical.url(this.tiles,this.scheme)),T={request:this.map._requestManager.transformRequest(x,i.R.Tile),data:void 0,uid:C.uid,tileID:C.tileID,tileZoom:C.tileZoom,zoom:C.tileID.overscaledZ,tileSize:this.tileSize*C.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:C.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(C.actor&&C.state!=="expired")if(C.state==="loading")C.reloadCallback=h;else{if(C.buckets){const R=Object.values(C.buckets);for(const z of R)z.dirty=!0;return void(C.state="loaded")}C.request=C.actor.send("reloadTile",T,D.bind(this))}else C.actor=this.dispatcher.getActor(),C.request=C.actor.send("loadTile",T,D.bind(this),void 0,!0);function D(R,z){return C.aborted?h(null):R&&R.status!==404?h(R):(this.map._refreshExpiredTiles&&z&&C.setExpiryData(z),C.loadModelData(z,this.map.painter),C.state="loaded",void h(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(C,h,x,T){super(C,h,x,T),h.coordinates?Array.isArray(h.coordinates)&&h.coordinates.length===4&&!h.coordinates.some(D=>!Array.isArray(D)||D.length!==2||D.some(R=>typeof R!="number"))||this.fire(new i.y(new i.V(`sources.${C}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${C}`,null,'missing required property "coordinates"'))),h.animate&&typeof h.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${C}`,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.${C}`,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.${C}`,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(C){this.map=C,this.load(),this.canvas&&this.animate&&this.play()}onRemove(C){this.pause()}prepare(){let C=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,C=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,C=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const h=this.map.painter.context;this.texture?!C&&!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 C of[this.canvas.width,this.canvas.height])if(isNaN(C)||C<=0)return!0;return!1}},custom:class extends i.E{constructor(C,h,x,T){super(),this.id=C,this.type="custom",this._dataType="raster",this._dispatcher=x,this._implementation=h,this.setEventedParent(T),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 jd(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(C){this.map=C,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(C),this.load()}onRemove(C){this._implementation.onRemove&&this._implementation.onRemove(C)}hasTile(C){if(this._implementation.hasTile){const{x:h,y:x,z:T}=C.canonical;return this._implementation.hasTile({x:h,y:x,z:T})}return!this.tileBounds||this.tileBounds.contains(C.canonical)}loadTile(C,h){const{x,y:T,z:D}=C.tileID.canonical,R=new AbortController;C.request=Promise.resolve(this._implementation.loadTile({x,y:T,z:D},{signal:R.signal})).then((function(z){return delete C.request,C.aborted?(C.state="unloaded",h(null)):z===void 0?(C.state="errored",h(null)):z===null?(this.loadTileData(C,{width:this.tileSize,height:this.tileSize,data:null}),C.state="loaded",h(null)):function(V){return V instanceof ImageData||V instanceof HTMLCanvasElement||V instanceof ImageBitmap||V instanceof HTMLImageElement}(z)?(this.loadTileData(C,z),C.state="loaded",void h(null)):(C.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"&&(C.state="errored",h(z))}),C.request.cancel=()=>R.abort()}loadTileData(C,h){C.setTexture(h,this.map.painter)}unloadTile(C,h){if(C.texture&&C.texture instanceof i.T?(C.destroy(!1),C.texture&&C.texture instanceof i.T&&this.map.painter.saveTileTexture(C.texture)):C.destroy(),this._implementation.unloadTile){const{x,y:T,z:D}=C.tileID.canonical;this._implementation.unloadTile({x,y:T,z:D})}h&&h()}abortTile(C,h){C.request&&C.request.cancel&&(C.request.cancel(),delete C.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(C=>({x:C.canonical.x,y:C.canonical.y,z:C.canonical.z}))}_clearTiles(){const C=i.B(this.id,this.scope);this.map.style.clearSource(C)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},xl=function(C,h,x,T){const D=new Zh[h.type](C,h,x,T);if(D.id!==C)throw new Error(`Expected Source id to be ${C} instead of ${D.id}`);return i.aY(["load","abort","unload","serialize","prepare"],D),D};function Sf(C,h,x=""){return`${x}:${h.id||""}:${h.layer.id}:${function(T){if("layerId"in T)return`layer:${T.layerId}`;{const{featuresetId:D,importId:R}=T;return`featureset:${D}${R?`:import:${R}`:""}`}}(C.target)}`}function Kg(C,h,x,T=""){if(C.uniqueFeatureID){const D=Sf(C,h,T);if(x.has(D))return!0;x.add(D)}return!1}function Q0(C,h,x,T,D=!1){const R=h.sourceCache.transform,z=h.sourceCache.tilesIn(C,h.has3DLayers,D);z.sort(Om);const V=[];for(const X of z){const re=X.tile.queryRenderedFeatures(h,X,x,T,R,D);Object.keys(re).length&&V.push({wrappedTileID:X.tile.tileID.wrapped().key,queryResults:re})}for(const X in h.layers){const re=h.layers[X];if(re.styleLayer){const ae=re.styleLayer.queryRenderedFeatures(C,h.sourceCache,T);Object.keys(ae).length&&V.push({wrappedTileID:0,queryResults:ae})}}return V.length===0?{}:function(X){const re={},ae={};for(const me of X){const he=me.queryResults,pe=me.wrappedTileID,Me=ae[pe]=ae[pe]||{};for(const Ce in he){const $e=he[Ce],Be=Me[Ce]=Me[Ce]||{},Xe=re[Ce]=re[Ce]||[];for(const ot of $e)Be[ot.featureIndex]||(Be[ot.featureIndex]=!0,Xe.push(ot))}}return re}(V)}function J0(C,h,x,T,D,R){const z={},V=T.queryRenderedSymbols(C),X=[];for(const re of Object.keys(V).map(Number))X.push(D[re]);X.sort(Om);for(const re of X){const ae=re.featureIndex.lookupSymbolFeatures(V[re.bucketInstanceId],re.bucketIndex,re.sourceLayerIndex,h,x,R);for(const me in ae){const he=z[me]=z[me]||[],pe=ae[me];pe.sort((Me,Ce)=>{const $e=re.featureSortOrder;if($e){const Be=$e.indexOf(Me.featureIndex);return $e.indexOf(Ce.featureIndex)-Be}return Ce.featureIndex-Me.featureIndex});for(const Me of pe)he.push(Me)}}return z}function ev(C,h){const x=C.getRenderableIds().map(R=>C.getTileByID(R)),T=[],D={};for(let R=0;Rh.getLayer(R)).filter(Boolean);if(D.length!==0){T.layers=D,T.stateDependentLayerIds&&(T.stateDependentLayers=T.stateDependentLayerIds.map(R=>D.filter(z=>z.id===R)[0]));for(const R of D)x[R.fqid]=T}}return x}const kd=32,oh=33,ld=new Uint16Array(8184);for(let C=0;C<2046;C++){let h=C+2,x=0,T=0,D=0,R=0,z=0,V=0;for(1&h?D=R=z=kd:x=T=V=kd;(h>>=1)>1;){const re=x+D>>1,ae=T+R>>1;1&h?(D=x,R=T,x=z,T=V):(x=D,T=R,D=z,R=V),z=re,V=ae}const X=4*C;ld[X+0]=x,ld[X+1]=T,ld[X+2]=D,ld[X+3]=R}const Yc=new Uint16Array(2178),Nd=new Uint8Array(1089),Np=new Uint16Array(1089);function Sp(C){return C===0?-.03125:C===32?.03125:0}const Yh={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 Xh{constructor(h,x,T,D,R,z){this.tileID=h,this.uid=i.b2(),this.uses=0,this.tileSize=x,this.tileZoom=T,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=R,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 x=h+this.timeAdded;xT)D=!1;else if(x)if(this.expirationTimeT.appearances&&T.appearances.length>0))return!0;return!1}updateBuckets(h,x){if(!this.latestFeatureIndex||!h.style)return;const T=h.style.listImages(),D=h.style.getBrightness();for(const R in this.buckets){if(!h.style.hasLayer(R))continue;const z=this.buckets[R],V=z.layers[0],X=V.sourceLayer||"_geojsonTileLayer",re=h.style.getLayerSourceCache(V);let ae={};re&&(ae=re._state.getState(X,void 0));const me=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},he=Object.keys(ae).length>0&&!x;z.hasAppearances=z.layers.some(Ce=>Ce.appearances&&Ce.appearances.length>0);const pe=he?z.stateDependentLayers:z.layers;if(he&&z.stateDependentLayers.length!==0||x){const Ce=this.latestFeatureIndex.loadVTLayers();z.update(ae,Ce[X],T,me,pe,x,D)}if(he&&z.stateDependentLayers.length!==0||x||z.hasAppearances){const Ce={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};z.updateAppearances(this.tileID.canonical,ae,T,Ce)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&re&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(re.id,this.tileID);const Me=h&&h.style&&h.style.getOwnLayer(R);Me&&(this.queryPadding=Math.max(this.queryPadding,Me.queryRadius(z)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;$e--){const Be=4*$e,Xe=ld[Be+0],ot=ld[Be+1],et=ld[Be+2],Ct=ld[Be+3],vt=Xe+et>>1,jt=ot+Ct>>1,xt=vt+jt-ot,pt=jt+Xe-vt,Et=ot*oh+Xe,Ht=Ct*oh+et,Ut=jt*oh+vt,ts=Math.hypot((Yc[2*Et+0]+Yc[2*Ht+0])/2-Yc[2*Ut+0],(Yc[2*Et+1]+Yc[2*Ht+1])/2-Yc[2*Ut+1])>=16;Nd[Ut]=Nd[Ut]||(ts?1:0),$e<1022&&(Nd[Ut]=Nd[Ut]||Nd[(ot+pt>>1)*oh+(Xe+xt>>1)]||Nd[(Ct+pt>>1)*oh+(et+xt>>1)])}const me=new i.b1,he=new i.b0;let pe=0;function Me($e,Be){const Xe=Be*oh+$e;return Np[Xe]===0&&(me.emplaceBack(Yc[2*Xe+0],Yc[2*Xe+1],$e*i.al/kd,Be*i.al/kd),Np[Xe]=++pe),Np[Xe]-1}function Ce($e,Be,Xe,ot,et,Ct){const vt=$e+Xe>>1,jt=Be+ot>>1;if(Math.abs($e-et)+Math.abs(Be-Ct)>1&&Nd[jt*oh+vt])Ce(et,Ct,$e,Be,vt,jt),Ce(Xe,ot,et,Ct,vt,jt);else{const xt=Me($e,Be),pt=Me(Xe,ot),Et=Me(et,Ct);he.emplaceBack(xt,pt,Et)}}return Ce(0,0,kd,kd,kd,0),Ce(kd,kd,0,0,0,kd),{vertices:me,indices:he}}(this.tileID.canonical,x);D=z.vertices,R=z.indices}else{D=new i.b1,R=new i.b0;for(const{x:V,y:X}of T)D.emplaceBack(V,X,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let V=0;V0&&(X=i.bl(new Float64Array(16),x.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,x,z,X,V),this._makeGlobeTileDebugTextBuffer(h,D,x,z,X,V)}_globePoint(h,x,T,D,R,z,V){let X=i.bm(h,x,T);if(z){const re=1<.5?pe=-1:he<-.5&&(pe=1);let Me=(h/i.al+T.x)/re+pe,Ce=(x/i.al+T.y)/re;Me=(Me-ae)*D._pixelsPerMercatorPixel+ae,Ce=(Ce-me)*D._pixelsPerMercatorPixel+me;const $e=[Me*D.worldSize,Ce*D.worldSize,0];i.af($e,$e,z),X=i.bn(X,$e,V)}return i.af(X,X,R)}_makeGlobeTileDebugBorderBuffer(h,x,T,D,R,z){const V=new i.bd,X=new i.be,re=new i.bo,ae=(he,pe,Me,Ce,$e)=>{const Be=(Me-he)/($e-1),Xe=(Ce-pe)/($e-1),ot=V.length;for(let et=0;et<$e;et++){const Ct=he+et*Be,vt=pe+et*Xe;V.emplaceBack(Ct,vt);const jt=this._globePoint(Ct,vt,x,T,D,R,z);re.emplaceBack(jt[0],jt[1],jt[2]),X.emplaceBack(ot+et)}},me=i.al;ae(0,0,me,0,16),ae(me,0,me,me,16),ae(me,me,0,me,16),ae(0,me,0,0,16),this._tileDebugIndexBuffer=h.createIndexBuffer(X),this._tileDebugBuffer=h.createVertexBuffer(V,i.bf.members),this._globeTileDebugBorderBuffer=h.createVertexBuffer(re,i.bp.members),this._tileDebugSegments=i.bg.simpleSegment(0,0,V.length,X.length)}_makeGlobeTileDebugTextBuffer(h,x,T,D,R,z){const V=i.al/4,X=new i.bd,re=new i.b0,ae=new i.bo,me=25;re.reserve(32),X.reserve(me),ae.reserve(me);const he=(pe,Me)=>me*pe+Me;for(let pe=0;pe{if(R)x(R);else try{const X=T.getHeaderLength(z);if(X>h)return void(this.request=this.fetchHeader(X,x));T.parseHeader(z),this._isHeaderLoaded=!0;let re=0;for(const ae of Object.values(T.layers))re=Math.max(re,ae.dataIndex[ae.dataIndex.length-1].lastByte);z.byteLength>=re&&(this.entireBuffer=z),x(null,this.entireBuffer||z,V)}catch(X){x(X)}}),this.request}fetchBandForRender(h,x,T,D){this.fetchBand(h,x,T,R=>{if(R)return void D(R);this.updateTextureDescriptor(h,x,T);const z=this.textureDescriptorPerLayer.get(x);D(null,z?z.img:null)})}fetchBand(h,x,T,D,R=!0){const z=this._mrt;if(!this._isHeaderLoaded||!z)return void D(new Error("Tile header is not ready"));const V=this.actor;if(!V)return void D(new Error("Can't fetch tile band without an actor"));let X;const re=i.B(String(T),i.B(this.tileID.key,h));let ae=this._taskQueue.get(re);ae?ae.add(D):(ae=new Set,ae.add(D),this._taskQueue.set(re,ae));const me=(Ce,$e)=>{X.complete(Ce,$e),Ce?D(Ce):(ae.forEach(Be=>Be(null,$e)),this._taskQueue.delete(re))},he=(Ce,$e)=>{if(Ce)return D(Ce);const Be=V.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:$e,task:X},me,void 0,!0);if(x!==null){const Xe=this._workQueuePerLayer.get(x)||[];Xe.push(()=>{Be&&Be.cancel(),X.cancel()}),this._workQueuePerLayer.has(x)||this._workQueuePerLayer.set(x,Xe)}};let pe;try{pe=z.getLayer(h)}catch(Ce){if(this.state==="reloading")return;throw Ce}if(!pe)return void D(new Error(`Unknown sourceLayer "${h}"`));if(pe.hasDataForBand(T))return ae.forEach(Ce=>Ce(null,null)),void this._taskQueue.delete(re);const Me=pe.getDataRange([T]);if(X=z.createDecodingTask(Me),!X||X.tasks.length)if(x!==null&&this.flushQueues(x),this.entireBuffer)he(null,this.entireBuffer.slice(Me.firstByte,Me.lastByte+1));else{const Ce=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Me.firstByte}-${Me.lastByte}`}}),$e=i.bu(Ce,he);if(x!==null){const Be=this._fetchQueuePerLayer.get(x)||[];Be.push(()=>{$e.cancel(),X.cancel()}),this._fetchQueuePerLayer.has(x)||this._fetchQueuePerLayer.set(x,Be)}}}updateNeeded(h,x){return(!this.textureDescriptorPerLayer.get(h)||this.textureDescriptorPerLayer.get(h).band!==x||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(h,x,T){if(!this._mrt)return;const D=this._mrt.getLayer(h);if(!D||!D.hasBand(T)||!D.hasDataForBand(T))return;const{bytes:R,tileSize:z,buffer:V,offset:X,scale:re}=D.getBandView(T),ae=z+2*V,me=new i.q({width:ae,height:ae},R),he=this.texturePerLayer.get(x);he&&he instanceof i.T&&he.update(me,{premultiply:!1}),this.textureDescriptorPerLayer.set(x,{layer:h,band:T,img:me,buffer:V,offset:X,tileSize:z,format:D.pixelFormat,mix:[re,256*re,65536*re,16777216*re]})}destroy(h=!1){if(super.destroy(h),delete this._mrt,!h)for(const x of this.texturePerLayer.values())x&&x instanceof i.T&&x.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 hy{constructor(h,x){this.max=h,this.onRemove=x,this.reset()}reset(){for(const h in this.data)for(const x of this.data[h])x.timeout&&clearTimeout(x.timeout),this.onRemove(x.value);return this.data={},this.order=[],this}add(h,x,T){const D=h.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const R={value:x,timeout:void 0};if(T!==void 0&&(R.timeout=setTimeout(()=>{this.remove(h,R)},T)),this.data[D].push(R),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 x=this.data[h].shift();return x.timeout&&clearTimeout(x.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),x.value}getByKey(h){const x=this.data[h];return x?x[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,x){if(!this.has(h))return this;const T=h.wrapped().key,D=x===void 0?0:this.data[T].indexOf(x),R=this.data[T][D];return this.data[T].splice(D,1),R.timeout&&clearTimeout(R.timeout),this.data[T].length===0&&delete this.data[T],this.onRemove(R.value),this.order.splice(this.order.indexOf(T),1),this}setMaxSize(h){for(this.max=h;this.order.length>this.max;){const x=this._getAndRemoveByKey(this.order[0]);x&&this.onRemove(x)}return this}filter(h){const x=[];for(const T in this.data)for(const D of this.data[T])h(D.value)||x.push(D);for(const T of x)this.remove(T.value.tileID,T)}}class Cf{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,x,T){const D=String(x);if(this.stateChanges[h]=this.stateChanges[h]||{},this.stateChanges[h][D]=this.stateChanges[h][D]||{},Object.assign(this.stateChanges[h][D],T),this.deletedStates[h]===null){this.deletedStates[h]={};for(const R in this.state[h])R!==D&&(this.deletedStates[h][R]=null)}else if(this.deletedStates[h]&&this.deletedStates[h][D]===null){this.deletedStates[h][D]={};for(const R in this.state[h][D])T[R]||(this.deletedStates[h][D][R]=null)}else for(const R in T)this.deletedStates[h]&&this.deletedStates[h][D]&&this.deletedStates[h][D][R]===null&&delete this.deletedStates[h][D][R]}removeFeatureState(h,x,T){if(this.deletedStates[h]===null)return;const D=String(x);if(this.deletedStates[h]=this.deletedStates[h]||{},T&&x!==void 0)this.deletedStates[h][D]!==null&&(this.deletedStates[h][D]=this.deletedStates[h][D]||{},this.deletedStates[h][D][T]=null);else if(x!==void 0)if(this.stateChanges[h]&&this.stateChanges[h][D])for(T in this.deletedStates[h][D]={},this.stateChanges[h][D])this.deletedStates[h][D][T]=null;else this.deletedStates[h][D]=null;else this.deletedStates[h]=null}getState(h,x){const T=this.state[h]||{},D=this.stateChanges[h]||{},R=this.deletedStates[h];if(R===null)return{};if(x!==void 0){const V=String(x),X=Object.assign({},T[V],D[V]);if(R){const re=R[x];if(re===null)return{};for(const ae in re)delete X[ae]}return X}const z=Object.assign({},T,D);if(R)for(const V in R)delete z[V];return z}initializeTileState(h,x){h.refreshFeatureState(x)}coalesceChanges(h,x){const T={};for(const D in this.stateChanges){this.state[D]=this.state[D]||{};const R={};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]),R[z]=this.state[D][z];T[D]=R}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const R={};if(this.deletedStates[D]===null)for(const z in this.state[D])R[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 V of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][V];R[z]=this.state[D][z]}T[D]=T[D]||{},Object.assign(T[D],R)}if(this.stateChanges={},this.deletedStates={},Object.keys(T).length!==0)for(const D in h)h[D].refreshFeatureState(x)}}class ul extends i.E{constructor(h,x,T){super(),this.id=h,this._onlySymbols=T,x.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))}),x.on("error",()=>{this._sourceErrored=!0}),this._source=x,this._tiles={},this._cache=new hy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=x.minTileCacheSize,this._maxTileCacheSize=x.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Cf,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,x){return h.isSymbolTile=this._onlySymbols,h.isExtraShadowCaster=this._shadowCasterTiles[h.tileID.key],this._source.loadTile(h,x)}_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 x in this._tiles){const T=this._tiles[x];T.upload(h,this.map?this.map.painter:void 0),T.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(tv).map(h=>h.key)}getRenderableIds(h,x){const T=[];for(const D in this._tiles)this._isIdRenderable(+D,h,x)&&T.push(this._tiles[D]);return h?T.sort((D,R)=>{const z=D.tileID,V=R.tileID,X=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),re=new i.P(V.canonical.x,V.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-V.overscaledZ||re.y-X.y||re.x-X.x}).map(D=>D.tileID.key):T.map(D=>D.tileID).sort(tv).map(D=>D.key)}hasRenderableParent(h){const x=this.findLoadedParent(h,0);return!!x&&this._isIdRenderable(x.tileID.key)}_isIdRenderable(h,x,T){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(x||!this._tiles[h].holdingForFade())&&(T||!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,x){const T=this._tiles[h];T&&(T.state!=="loading"&&(T.state=x),this._loadTile(T,this._tileLoaded.bind(this,T,h,x)))}_tileLoaded(h,x,T,D,R){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 V=this.map.painter.terrain;this.update(this.transform,V.getScaledDemTileSize(),!0),V.resetTileLookupCache(this.id)}else this.update(this.transform)}return}h.timeAdded=i.o.now(),T==="expired"&&(h.refreshedUponExpiration=!0),this._setTileReloadTimer(x,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;R&&R.responseHeaders&&(z=R.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:h,coord:h.tileID,sourceCacheId:this.id,responseHeaders:z}))}_backfillDEM(h){const x=this.getRenderableIds();for(let D=0;D1||(Math.abs(z)>1&&(Math.abs(z+X)===1?z+=X:Math.abs(z-X)===1&&(z-=X)),R.dem&&D.dem&&(D.dem.backfillBorder(R.dem,z,V),D.neighboringTiles&&D.neighboringTiles[re]&&(D.neighboringTiles[re].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,x,T,D){for(const R in this._tiles){let z=this._tiles[R];if(D[R]||!z.hasData()||z.tileID.overscaledZ<=x||z.tileID.overscaledZ>T)continue;let V=z.tileID;for(;z&&z.tileID.overscaledZ>x+1;){const re=z.tileID.scaledTo(z.tileID.overscaledZ-1);z=this._tiles[re.key],z&&z.hasData()&&(V=re)}let X=V;for(;X.overscaledZ>x;)if(X=X.scaledTo(X.overscaledZ-1),h[X.key]){D[V.key]=V;break}}}findLoadedParent(h,x){if(h.key in this._loadedParentTiles){const T=this._loadedParentTiles[h.key];return T&&T.tileID.overscaledZ>=x?T:null}for(let T=h.overscaledZ-1;T>=x;T--){const D=h.scaledTo(T),R=this._getLoadedTile(D);if(R)return R}}_getLoadedTile(h){const x=this._tiles[h.key];return x&&x.hasData()?x:this._cache.getByKey(this._source.reparseOverscaled?h.wrapped().key:h.canonical.key)}updateCacheSize(h,x){x=x||this._source.tileSize;const T=Math.ceil(h.width/x)+1,D=Math.ceil(h.height/x)+1,R=Math.floor(T*D*5),z=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,R):R,V=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(V)}handleWrapJump(h){const x=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,x){const T={};for(const D in this._tiles){const R=this._tiles[D];R.tileID=R.tileID.unwrapTo(R.tileID.wrap+x),T[R.tileID.key]=R}this._tiles=T;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,x,T,D,R){if(this.transform=h,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!T)return;this.updateCacheSize(h,x),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const z=this._source.type==="batched-model";let V,X=this._source.maxzoom;const re=this.map&&this.map.painter?this.map.painter._terrain:null;if(re&&re.sourceCache===this&&re.attenuationRange()){const he=re.attenuationRange()[0],pe=Math.floor(he)-Math.log2(re.getDemUpscale());X>pe&&(X=pe)}if(this.used||this.usedForTerrain){if(this._source.tileID)V=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(he=>new i.aQ(he.canonical.z,he.wrap,he.canonical.z,he.canonical.x,he.canonical.y));else if(this.tileCoverLift!==0){const he=h.clone();he.tileCoverLift=this.tileCoverLift,V=he.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:X,roundZoom:this._source.roundZoom&&!T,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(V.push(new i.aQ(1,0,1,0,0)),V.push(new i.aQ(1,0,1,1,0)),V.push(new i.aQ(1,0,1,0,1)),V.push(new i.aQ(1,0,1,1,1)))}else if(V=h.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:X,roundZoom:this._source.roundZoom&&!T,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const he=this._source.hasTile.bind(this._source);V=V.filter(pe=>he(pe))}}else V=[];if(V.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!Mf(this._source.type)){const he=h.coveringZoomLevel({tileSize:x||this._source.tileSize,roundZoom:this._source.roundZoom&&!T}),pe=Math.min(he,this._source.maxzoom);if(z){const Me=h.extendTileCover(V,pe);for(const Ce of Me)V.push(Ce)}else if(R){const Me=h.extendTileCoverToNearPlane(V,this.transform.getFrustum(pe),pe);for(const Ce of Me)V.push(Ce)}else if(this.castsShadows&&D){const Me=h.extendTileCover(V,pe,D,16);for(const Ce of Me)this._shadowCasterTiles[Ce.key]=!0,V.push(Ce)}}const ae=this._updateRetainedTiles(V);if(Mf(this._source.type)&&V.length!==0){const he={},pe={},Me=Object.keys(ae);for(const $e of Me){const Be=ae[$e],Xe=this._tiles[$e];if(!Xe||Xe.fadeEndTime&&Xe.fadeEndTime<=i.o.now())continue;const ot=this.findLoadedParent(Be,Math.max(Be.overscaledZ-ul.maxOverzooming,this._source.minzoom));ot&&(this._addTile(ot.tileID),he[ot.tileID.key]=ot.tileID),pe[$e]=Be}const Ce=V[V.length-1].overscaledZ;for(const $e in this._tiles){const Be=this._tiles[$e];if(ae[$e]||!Be.hasData())continue;let Xe=Be.tileID;for(;Xe.overscaledZ>Ce;){Xe=Xe.scaledTo(Xe.overscaledZ-1);const ot=this._tiles[Xe.key];if(ot&&ot.hasData()&&pe[Xe.key]){ae[$e]=Be.tileID;break}}}for(const $e in he)ae[$e]||(this._coveredTiles[$e]=!0,ae[$e]=he[$e])}for(const he in ae)this._tiles[he].clearFadeHold();const me=i.bv(this._tiles,ae);for(const he of me){const pe=this._tiles[he];pe.hasSymbolBuckets&&!pe.holdingForFade()?pe.setHoldDuration(this.map._fadeDuration):pe.hasSymbolBuckets&&!pe.symbolFadeFinished()||this._removeTile(+he)}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 x={};if(h.length===0)return x;const T={},D=h.reduce((re,ae)=>Math.min(re,ae.overscaledZ),1/0),R=h[0].overscaledZ,z=Math.max(R-ul.maxOverzooming,this._source.minzoom),V=Math.max(R+ul.maxUnderzooming,this._source.minzoom),X={};for(const re of h){const ae=this._addTile(re);x[re.key]=re,ae.hasData()||D=this._source.maxzoom){const he=re.children(this._source.maxzoom)[0],pe=this.getTile(he);if(pe&&pe.hasData()){x[he.key]=he;continue}}else{const he=re.children(this._source.maxzoom);if(x[he[0].key]&&x[he[1].key]&&x[he[2].key]&&x[he[3].key])continue}let me=ae.wasRequested();for(let he=re.overscaledZ-1;he>=z;--he){const pe=re.scaledTo(he);if(T[pe.key]||(T[pe.key]=!0,ae=this.getTile(pe),!ae&&me&&(ae=this._addTile(pe)),ae&&(x[pe.key]=pe,me=ae.wasRequested(),ae.hasData())))break}}return x}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const x=[];let T,D=this._tiles[h].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){T=this._loadedParentTiles[D.key];break}x.push(D.key);const R=D.scaledTo(D.overscaledZ-1);if(T=this._getLoadedTile(R),T)break;D=R}for(const R of x)this._loadedParentTiles[R]=T}}_addTile(h){let x=this._tiles[h.key];if(x)return x.isExtraShadowCaster!==!0||this._shadowCasterTiles[h.key]||this._reloadTile(h.key,"reloading"),x;x=this._cache.getAndRemove(h),x&&(this._setTileReloadTimer(h.key,x),x.tileID=h,this._state.initializeTileState(x,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,x)));const T=!!x;if(!T){const D=this.map?this.map.painter:null,R=this._source.tileSize*h.overscaleFactor();x=this._source.type==="raster-array"?new Xc(h,R,this.transform.tileZoom,D,this._isRaster):new Xh(h,R,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(x,this._tileLoaded.bind(this,x,h.key,x.state))}return x.uses++,this._tiles[h.key]=x,T||this._source.fire(new i.z("dataloading",{tile:x,coord:x.tileID,dataType:"source"})),x}_setTileReloadTimer(h,x){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const T=x.getExpiryTimeout();T&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},T))}_removeTile(h){const x=this._tiles[h];x&&(x.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),x.uses>0||(x.hasData()&&x.state!=="reloading"||x.state==="empty"?this._cache.add(x.tileID,x,x.getExpiryTimeout()):(x.aborted=!0,this._abortTile(x),this._unloadTile(x))))}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,x,T){const D=[],R=this.transform;if(!R)return D;const z=R.projection.name==="globe",V=i.aF(R.center.lng);for(const X in this._tiles){const re=this._tiles[X];if(T&&re.clearQueryDebugViz(),re.holdingForFade())continue;let ae;if(z){const me=re.tileID.canonical;if(me.z===0){const he=[Math.abs(i.aA(V,...Ru(me,-1))-V),Math.abs(i.aA(V,...Ru(me,1))-V)];ae=[0,2*he.indexOf(Math.min(...he))-1]}else{const he=[Math.abs(i.aA(V,...Ru(me,-1))-V),Math.abs(i.aA(V,...Ru(me,0))-V),Math.abs(i.aA(V,...Ru(me,1))-V)];ae=[he.indexOf(Math.min(...he))-1]}}else ae=[0];for(const me of ae){const he=h.containsTile(re,R,x,me);he&&D.push(he)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,x){const T=this.getRenderableIds(h,x).map(R=>this._tiles[R].tileID),D=this.transform.projection.name==="globe";for(const R of T)R.projMatrix=this.transform.calculateProjMatrix(R.toUnwrapped()),R.expandedProjMatrix=D?this.transform.calculateProjMatrix(R.toUnwrapped(),!1,!0):R.projMatrix;return T}sortCoordinatesByDistance(h){const x=h.slice(),T=this.transform._camera.position,D=this.transform._camera.forward(),R={};for(const z of x){const V=1/(1<R[z.key]-R[V.key]),x}hasTransition(){if(this._source.hasTransition())return!0;if(Mf(this._source.type))for(const h in this._tiles){const x=this._tiles[h];if(x.fadeEndTime!==void 0&&x.fadeEndTime>=i.o.now())return!0}return!1}setFeatureState(h,x,T){this._state.updateState(h=h||"_geojsonTileLayer",x,T)}removeFeatureState(h,x,T){this._state.removeFeatureState(h=h||"_geojsonTileLayer",x,T)}getFeatureState(h,x){return this._state.getState(h=h||"_geojsonTileLayer",x)}setDependencies(h,x,T){const D=this._tiles[h];D&&D.setDependencies(x,T)}reloadTilesForDependencies(h,x){for(const T in this._tiles)this._tiles[T].hasDependency(h,x)&&this._reloadTile(+T,"reloading");this._cache.filter(T=>!T.hasDependency(h,x))}_preloadTiles(h,x){if(!this._sourceLoaded){const X=()=>{this._sourceLoaded&&(this._source.off("data",X),this._preloadTiles(h,x))};return void this._source.on("data",X)}const T=new Map,D=Array.isArray(h)?h:[h],R=this.map.painter.terrain,z=this.usedForTerrain&&R?R.getScaledDemTileSize():this._source.tileSize;for(const X of D){const re=X.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 ae of re)T.set(ae.key,ae);this.usedForTerrain&&X.updateElevation(!1)}const V=Array.from(T.values());i.bw(V,(X,re)=>{const ae=new Xh(X,this._source.tileSize*X.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(ae,me=>{this._source.type==="raster-dem"&&ae.dem&&this._backfillDEM(ae),re(me,ae)})},x)}}function tv(C,h){const x=Math.abs(2*C.wrap)-+(C.wrap<0),T=Math.abs(2*h.wrap)-+(h.wrap<0);return C.overscaledZ-h.overscaledZ||T-x||h.canonical.y-C.canonical.y||h.canonical.x-C.canonical.x}function Mf(C){return C==="raster"||C==="image"||C==="video"||C==="custom"}function Ru(C,h){const x=1<0:T.type==="building"?D=!T.isHidden(h)&&T.paint.get("building-opacity")>0:T.type==="model"&&(D=!T.isHidden(h)&&T.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!D&&x.visible,x.visible=D}}updateZOffset(h,x){this.currentBuildingBuckets=[];for(const D of this.layers){const R=D.layer,z=this.style.getLayerSourceCache(R);let V=1;R.type==="fill-extrusion"?V=D.visible?R.paint.get("fill-extrusion-vertical-scale"):0:R.type==="building"&&(V=D.visible?R.paint.get("building-vertical-scale"):0);let X=z?z.getTile(x):null;if(!X&&z)for(const re in z._tiles){const ae=z._tiles[re];if(x.canonical.isChildOf(ae.tileID.canonical)){X=ae;break}}this.currentBuildingBuckets.push({bucket:X?X.getBucket(R):null,tileID:X?X.tileID:x,verticalScale:V})}h.hasAnyZOffset=!1;let T=!1;for(let D=0;D{T in h&&(x[T]=h[T])}),x}function my(C){C=C.slice();const h=Object.create(null);for(let x=0;x0?(D-z)/V:0;return this.points[R].mult(1-X).add(this.points[x].mult(X))}}class Y_{constructor(h,x,T){const D=this.boxCells=[],R=this.circleCells=[];this.xCellCount=Math.ceil(h/T),this.yCellCount=Math.ceil(x/T);for(let z=0;zthis.width||D<0||x>this.height)return!R&&[];const V=[];if(h<=0&&x<=0&&this.width<=T&&this.height<=D){if(R)return!0;for(let X=0;X0:V}_queryCircle(h,x,T,D,R){const z=h-T,V=h+T,X=x-T,re=x+T;if(V<0||z>this.width||re<0||X>this.height)return!D&&[];const ae=[];return this._forEachCell(z,X,V,re,this._queryCellCircle,ae,{hitTest:D,circle:{x:h,y:x,radius:T},seenUids:{box:{},circle:{}}},R),D?ae.length>0:ae}query(h,x,T,D,R){return this._query(h,x,T,D,!1,R)}hitTest(h,x,T,D,R){return this._query(h,x,T,D,!0,R)}hitTestCircle(h,x,T,D){return this._queryCircle(h,x,T,!0,D)}_queryCell(h,x,T,D,R,z,V,X){const re=V.seenUids,ae=this.boxCells[R];if(ae!==null){const he=this.bboxes;for(const pe of ae)if(!re.box[pe]){re.box[pe]=!0;const Me=4*pe;if(h<=he[Me+2]&&x<=he[Me+3]&&T>=he[Me+0]&&D>=he[Me+1]&&(!X||X(this.boxKeys[pe]))){if(V.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[pe],x1:he[Me],y1:he[Me+1],x2:he[Me+2],y2:he[Me+3]})}}}const me=this.circleCells[R];if(me!==null){const he=this.circles;for(const pe of me)if(!re.circle[pe]){re.circle[pe]=!0;const Me=3*pe;if(this._circleAndRectCollide(he[Me],he[Me+1],he[Me+2],h,x,T,D)&&(!X||X(this.circleKeys[pe]))){if(V.hitTest)return z.push(!0),!0;{const Ce=he[Me],$e=he[Me+1],Be=he[Me+2];z.push({key:this.circleKeys[pe],x1:Ce-Be,y1:$e-Be,x2:Ce+Be,y2:$e+Be})}}}}}_queryCellCircle(h,x,T,D,R,z,V,X){const re=V.circle,ae=V.seenUids,me=this.boxCells[R];if(me!==null){const pe=this.bboxes;for(const Me of me)if(!ae.box[Me]){ae.box[Me]=!0;const Ce=4*Me;if(this._circleAndRectCollide(re.x,re.y,re.radius,pe[Ce+0],pe[Ce+1],pe[Ce+2],pe[Ce+3])&&(!X||X(this.boxKeys[Me])))return z.push(!0),!0}}const he=this.circleCells[R];if(he!==null){const pe=this.circles;for(const Me of he)if(!ae.circle[Me]){ae.circle[Me]=!0;const Ce=3*Me;if(this._circlesCollide(pe[Ce],pe[Ce+1],pe[Ce+2],re.x,re.y,re.radius)&&(!X||X(this.circleKeys[Me])))return z.push(!0),!0}}}_forEachCell(h,x,T,D,R,z,V,X){const re=this._convertToXCellCoord(h),ae=this._convertToYCellCoord(x),me=this._convertToXCellCoord(T),he=this._convertToYCellCoord(D);for(let pe=re;pe<=me;pe++)for(let Me=ae;Me<=he;Me++)if(R.call(this,h,x,T,D,this.xCellCount*Me+pe,z,V,X))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,x,T,D,R,z){const V=D-h,X=R-x,re=T+z;return re*re>V*V+X*X}_circleAndRectCollide(h,x,T,D,R,z,V){const X=(z-D)/2,re=Math.abs(h-(D+X));if(re>X+T)return!1;const ae=(V-R)/2,me=Math.abs(x-(R+ae));if(me>ae+T)return!1;if(re<=X||me<=ae)return!0;const he=re-X,pe=me-ae;return he*he+pe*pe<=T*T}}const yt={unknown:0,flipRequired:1,flipNotRequired:2},Ns=Math.tan(85*Math.PI/180);function Hs(C,h,x,T,D,R,z){const V=i.bC();if(x)if(R.name==="globe"){const X=i.bD(D,h);i.aB(V,V,X)}else{const X=i.bE([],z);V[0]=X[0],V[1]=X[1],V[4]=X[2],V[5]=X[3],T||i.bB(V,V,D.angle)}else i.aB(V,D.labelPlaneMatrix,C);return V}function an(C,h,x,T,D,R,z){const V=Hs(C,h,x,T,D,R,z);return R.name==="globe"&&x||(V[2]=V[6]=V[10]=V[14]=0),V}function on(C,h,x,T,D,R,z){if(x){if(R.name==="globe"){const V=Hs(C,h,x,T,D,R,z);return i.bl(V,V),i.aB(V,C,V),V}{const V=i.bz(C),X=i.bA([]);return X[0]=z[0],X[1]=z[1],X[4]=z[2],X[5]=z[3],i.aB(V,V,X),T||i.bB(V,V,-D.angle),V}}return D.glCoordMatrix}function Jn(C,h,x,T){const D=[C,h,x,1];x?i.aC(D,D,T):Dr(D,D,T);const R=D[3];return D[0]/=R,D[1]/=R,D[2]/=R,D}function Fr(C,h){return Math.min(.5+C/h*.5,1.5)}function Xi(C,h){const x=C[0]/C[3],T=C[1]/C[3];return x>=-h[0]&&x<=h[0]&&T>=-h[1]&&T<=h[1]}function Tf(C,h,x,T,D,R,z,V,X,re,ae=1){const me=x.transform,he=T?C.textSizeData:C.iconSizeData,pe=i.bK(he,x.transform.zoom,ae),Me=me.projection.name==="globe",Ce=[256/x.width*2+1,256/x.height*2+1],$e=T?C.text.dynamicLayoutVertexArray:C.icon.dynamicLayoutVertexArray;$e.clear();let Be=null;Me&&(Be=T?C.text.globeExtVertexArray:C.icon.globeExtVertexArray);const Xe=C.lineVertexArray,ot=T?C.text.placedSymbolArray:C.icon.placedSymbolArray,et=x.transform.width/x.transform.height;let Ct,vt=!1;for(let jt=0;jtMath.abs(x)?{useVertical:!0}:C===i.bL.vertical?T>0?{needsFlipping:!0}:null:h!==yt.unknown&&function(D,R){return D===0||Math.abs(R/D)>Ns}(x,T)?h===yt.flipRequired?{needsFlipping:!0}:null:x<0?{needsFlipping:!0}:null}function gy(C,h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e,Be,Xe,ot){const et=h/24,Ct=C.lineOffsetX*et,vt=C.lineOffsetY*et,{lineStartIndex:jt,glyphStartIndex:xt,numGlyphs:pt,segment:Et,writingMode:Ht,flipState:Ut}=C,ts=jt+C.lineLength,ss=ps=>{if(ae){const[ls,es,As]=ps.up,Xs=re.length;i.bN(ae,Xs+0,ls,es,As),i.bN(ae,Xs+1,ls,es,As),i.bN(ae,Xs+2,ls,es,As),i.bN(ae,Xs+3,ls,es,As)}const[zs,Xt,Dt]=ps.point;i.bO(re,zs,Xt,Dt,ps.angle)};if(pt>1){const ps=Rm(et,V,Ct,vt,x,me,he,C,X,R,pe,Ce,!1,$e,Be,Xe,ot);if(!ps)return{notEnoughRoom:!0};if(T&&!x){let[zs,Xt,Dt]=ps.first.point,[ls,es,As]=ps.last.point;[zs,Xt]=Jn(zs,Xt,Dt,z),[ls,es]=Jn(ls,es,As,z);const Xs=Ur(Ht,Ut,(ls-zs)*Me,es-Xt);if(C.flipState=Xs&&Xs.needsFlipping?yt.flipRequired:yt.flipNotRequired,Xs)return Xs}ss(ps.first);for(let zs=xt+1;zs0?ls:Jh(he,Dt,zs,1,D,void 0,$e,Be.canonical),As=Ur(Ht,Ut,(es[0]-zs[0])*Me,es[1]-zs[1]);if(C.flipState=As&&As.needsFlipping?yt.flipRequired:yt.flipNotRequired,As)return As}const ps=rv(et*V.getoffsetX(xt),Ct,vt,x,me,he,Et,jt,ts,X,R,pe,Ce,!1,!1,$e,Be,Xe,ot);if(!ps)return{notEnoughRoom:!0};ss(ps)}return{}}function xy(C,h,x,T,D){const{x:R,y:z,z:V}=T.projectTilePoint(C.x,C.y,h);if(!D)return Jn(R,z,V,x);const[X,re,ae]=D.getElevation(C,D.elevation,D.elevationFeature);return Jn(R+X,z+re,V+ae,x)}function Jh(C,h,x,T,D,R,z,V){const X=xy(C.sub(h)._unit()._add(C),V,D,z,R);return i.av(X,x,X),i.aw(X,X),i.bH(X,x,X,T)}function rv(C,h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e,Be,Xe){const ot=T?C-h:C+h;let et=ot>0?1:-1,Ct=0;T&&(et*=-1,Ct=Math.PI),et<0&&(Ct+=Math.PI);let vt=V+z+(et>0?0:1)|0,jt=D,xt=D,pt=0,Et=0;const Ht=Math.abs(ot),Ut=[],ts=[];let ss=R,ps=ss,zs=i.bF([]);const Xt=()=>Jh(ps,ss,xt,Ht-pt+1,ae,he,Ce,$e.canonical);for(;pt+Et<=Ht;){if(vt+=et,vt=X)return null;if(xt=jt,ps=ss,Ut.push(xt),pe&&ts.push(ps),ss=new i.P(re.getx(vt),re.gety(vt)),jt=me[vt],!jt){const br=xy(ss,$e.canonical,ae,Ce,he);jt=br[3]>0?me[vt]=br:Xt()}pt+=Et;const Bs=i.av([],jt,xt),kr=i.bG(xt,jt);if(x&&kr>0&&Et>0&&i.bJ(zs,Bs)/(Et*kr)0,ot),jt=re*vt.perspectiveRatio,xt=(T.x1*x+V.x-T.padding)*jt+vt.point.x,pt=(T.y1*x+V.y-T.padding)*jt+vt.point.y,Et=(T.x2*x+V.x+T.padding)*jt+vt.point.x,Ht=(T.y2*x+V.y+T.padding)*jt+vt.point.y,Ut=vt.perspectiveRatio<=.55||vt.occluded;return!this.isInsideGrid(xt,pt,Et,Ht)||!X&&this.grid.hitTest(xt,pt,Et,Ht,me)||Ut?{box:[],offscreen:!1,occluded:vt.occluded}:{box:[xt,pt,Et,Ht],offscreen:this.isOffscreen(xt,pt,Et,Ht),occluded:!1}}placeCollisionCircles(h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e){const Be=[],Xe=this.transform.elevation,ot=h.getProjection(),et=h.elevationType==="road",Ct=!!Xe||et,vt=i.bV.getAtTileOffsetFunc($e,this.transform.center.lat,this.transform.worldSize,ot),jt=new i.P(T.tileAnchorX,T.tileAnchorY),xt=new i.P(T.tileAnchorX,T.tileAnchorY);let{x:pt,y:Et,z:Ht}=ot.projectTilePoint(xt.x,xt.y,$e.canonical),Ut=null;if(Ct){const kr=et?h.getElevationFeatureForText(D):null;Ut={getElevation:vt,elevation:Xe,elevationFeature:kr};const[br,or,mr]=vt(jt,Xe,kr);pt+=br,Et+=or,Ht+=mr}const ts=ot.name==="globe",ss=this.projectAndGetPerspectiveRatio(X,pt,Et,Ht,$e,ts||!!Xe||this.transform.pitch>0,ot),{perspectiveRatio:ps}=ss,zs=(he?V/ps:V*ps)/i.bY,Xt=Jn(pt,Et,Ht,re),Dt=T.lineOffsetX*zs,ls=T.lineOffsetY*zs,es=i.an(h.layers[0].layout.get("text-max-angle")),As=Math.cos(es),Xs=ss.signedDistanceFromCamera>0?Rm(zs,z,Dt,ls,et&&T.flipState===1,Xt,xt,T,R,re,{},Ct&&!he?Ut:null,he&&Ct,ot,$e,he,As):null;let ur=!1,Ws=!1,Bs=!0;if(Xs&&!ss.occluded){const kr=.5*Me*ps+Ce,br=new i.P(-100,-100),or=new i.P(this.screenRightBoundary,this.screenBottomBoundary),mr=new Yg,{first:$r,last:jn}=Xs,da=$r.path.length;let Va=[];for(let vn=da-1;vn>=1;vn--)Va.push($r.path[vn]);for(let vn=1;vn(Ct&&!ts&&(ui=vt(nivn[3]<=0)&&(Va=[]));let Oa=[];if(Va.length>0){let vn=1/0,Ya=-1/0,ui=1/0,ni=-1/0;for(const Ea of Va)vn=Math.min(vn,Ea[0]),ui=Math.min(ui,Ea[1]),Ya=Math.max(Ya,Ea[0]),ni=Math.max(ni,Ea[1]);Ya>=br.x&&vn<=or.x&&ni>=br.y&&ui<=or.y&&(Oa=[Va.map(Ea=>new i.P(Ea[0],Ea[1]))],(vnor.x||uior.y)&&(Oa=i.bW(Oa,br.x,br.y,or.x,or.y)))}for(const vn of Oa){mr.reset(vn,.25*kr);let Ya=0;Ya=mr.length<=.5*kr?1:Math.ceil(mr.paddedLength/Tr)+1;for(let ui=0;ui0?(i.aC(X,X,h),this.fogState&&R&&V.name!=="globe"&&(re=function(he,pe,Me,Ce,$e,Be){const Xe=Be.calculateFogTileMatrix($e),ot=[pe,Me,Ce];return i.af(ot,ot,Xe),hr(he,i.ag(ot),Be.pitch,Be._fov)}(this.fogState,x,T,D,R.toUnwrapped(),this.transform)>.9)):Dr(X,X,h);const ae=X[3];return{point:new i.P((X[0]/ae+1)/2*this.transform.width+va,(-X[1]/ae+1)/2*this.transform.height+va),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(V)/ae*.5,1.5),signedDistanceFromCamera:ae,occluded:z&&X[2]>ae||re}}isOffscreen(h,x,T,D){return T=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(h,x,T,D){return T>=0&&h=0&&xT.collisionGroupID===x}}return this.collisionGroups[h]}}function cd(C,h,x,T,D){const{horizontalAlign:R,verticalAlign:z}=i.c1(C),V=-(R-.5)*h,X=-(z-.5)*x,re=i.c2(C,T);return new i.P(V+re[0]*D,X+re[1]*D)}function rl(C,h,x,T,D){const R=new i.P(C,h);return x&&R._rotate(T?D:-D),R}class wce{constructor(h,x,T,D,R,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new di(this.transform,R),this.buildingIndex=z,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=x,this.retainedQueryData={},this.collisionGroups=new Q_(T),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,x,T,D,R=1){const z=T.getBucket(x),V=T.latestFeatureIndex;if(!z||!V||x.fqid!==z.layerIds[0])return;const X=z.layers[0].layout,re=z.layers[0].paint,ae=T.collisionBoxArray,me=Math.pow(2,this.transform.zoom-T.tileID.overscaledZ),he=T.tileSize/i.al,pe=T.tileID.toUnwrapped();this.transform.setProjection(z.projection);const Me=(Ce=T.tileID,$e=z.getProjection(),Be=this.transform,$e.name===this.projection?Be.calculateProjMatrix(Ce.toUnwrapped()):Z_(Be,$e,Ce));var Ce,$e,Be;const Xe=X.get("text-pitch-alignment")==="map",ot=X.get("text-rotation-alignment")==="map";x.compileFilter(x.options);const et=x.dynamicFilter(),Ct=x.dynamicFilterNeedsFeature(),vt=this.transform.calculatePixelsToTileUnitsMatrix(T),jt=an(Me,T.tileID.canonical,Xe,ot,this.transform,z.getProjection(),vt);let xt=null;const pt=z.getProjection().createInversionMatrix(this.transform,T.tileID.canonical);if(Xe){const Dt=on(Me,T.tileID.canonical,Xe,ot,this.transform,z.getProjection(),vt);xt=i.aB([],this.transform.labelPlaneMatrix,Dt)}let Et=null;et&&T.latestFeatureIndex&&(Et={unwrappedTileID:pe,dynamicFilter:et,dynamicFilterNeedsFeature:Ct}),this.retainedQueryData[z.bucketInstanceId]=new X_(z.bucketInstanceId,V,z.sourceLayerIndex,z.index,T.tileID);const[Ht,Ut]=z.layers[0].layout.get("text-size-scale-range"),ts=i.aA(R,Ht,Ut),[ss,ps]=X.get("icon-size-scale-range"),zs=i.aA(R,ss,ps),Xt={bucket:z,layout:X,paint:re,posMatrix:Me,invMatrix:pt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:jt,labelToScreenMatrix:xt,clippingData:Et,scale:me,textPixelRatio:he,holdingForFade:T.holdingForFade(),collisionBoxArray:ae,partiallyEvaluatedTextSize:i.bK(z.textSizeData,this.transform.zoom,ts),partiallyEvaluatedIconSize:i.bK(z.iconSizeData,this.transform.zoom,zs),collisionGroup:this.collisionGroups.get(z.sourceID),latestFeatureIndex:T.latestFeatureIndex};if(D)for(const Dt of z.sortKeyRanges){const{sortKey:ls,symbolInstanceStart:es,symbolInstanceEnd:As}=Dt;h.push({sortKey:ls,symbolInstanceStart:es,symbolInstanceEnd:As,parameters:Xt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Xt})}attemptAnchorPlacement(h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e,Be,Xe,ot,et,Ct){const{textOffset0:vt,textOffset1:jt,crossTileID:xt}=Ce,pt=[vt,jt],Et=cd(h,z,V,pt,X),Ht=this.collisionIndex.placeCollisionBox(Be,X,x,T,D,R,rl(Et.x,Et.y,re,ae,this.transform.angle),Me,me,he,pe.predicate);if(ot){const Ut=Be.getSymbolInstanceIconSize(Ct,this.transform.zoom,Ce.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Be,Ut,ot,T,D,R,rl(Et.x,Et.y,re,ae,this.transform.angle),Me,me,he,pe.predicate).box.length===0)return}if(Ht.box.length>0){let Ut;return this.prevPlacement&&this.prevPlacement.variableOffsets[xt]&&this.prevPlacement.placements[xt]&&this.prevPlacement.placements[xt].text&&(Ut=this.prevPlacement.variableOffsets[xt].anchor),this.variableOffsets[xt]={textOffset:pt,width:z,height:V,anchor:h,textScale:X,prevAnchor:Ut},this.markUsedJustification(Be,h,Ce,Xe),Be.allowVerticalPlacement&&(this.markUsedOrientation(Be,Xe,Ce),this.placedOrientations[xt]=Xe),{shift:Et,placedGlyphBoxes:Ht}}}placeLayerBucketPart(h,x,T,D,R=1){const{bucket:z,layout:V,paint:X,posMatrix:re,textLabelPlaneMatrix:ae,labelToScreenMatrix:me,clippingData:he,textPixelRatio:pe,mercatorCenter:Me,invMatrix:Ce,holdingForFade:$e,collisionBoxArray:Be,partiallyEvaluatedTextSize:Xe,partiallyEvaluatedIconSize:ot,collisionGroup:et,latestFeatureIndex:Ct}=h.parameters,vt=V.get("text-optional"),jt=V.get("icon-optional"),xt=V.get("text-allow-overlap"),pt=V.get("icon-allow-overlap"),Et=V.get("text-rotation-alignment")==="map",Ht=V.get("icon-rotation-alignment")==="map",Ut=V.get("text-pitch-alignment")==="map",ts=X.get("symbol-z-offset"),ss=V.get("symbol-elevation-reference")==="sea",ps=V.get("symbol-placement"),[zs,Xt]=V.get("text-size-scale-range"),[Dt,ls]=V.get("icon-size-scale-range"),es=i.aA(R,zs,Xt),As=i.aA(R,Dt,ls),Xs=V.get("text-variable-anchor"),ur=Et&&ps!=="point",Ws=Ht&&ps!=="point",Bs=Xs&&z.hasTextData(),kr=z.hasIconTextFit()&&Bs&&z.hasIconData();this.transform.setProjection(z.projection);const br=Bs||ur,or=Ws||kr;let mr=xt&&(pt||!z.hasIconData()||jt),$r=pt&&(xt||!z.hasTextData()||vt);const jn=!ts.isConstant();!z.collisionArrays&&Be&&z.deserializeCollisionBoxes(Be),T&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Be,es,As);const da=(Tr,Oa,vn)=>{const{crossTileID:Ya,numVerticalGlyphVertices:ui}=Tr;let ni=null;if(he&&he.dynamicFilterNeedsFeature||jn){const bo=this.retainedQueryData[z.bucketInstanceId];ni=Ct.loadFeature({featureIndex:Tr.featureIndex,bucketIndex:bo.bucketIndex,sourceLayerIndex:bo.sourceLayerIndex,layoutVertexArrayOffset:0});const Do=ni.properties?ni.properties.worldview:null;if(z.localizable&&z.worldview&&typeof Do=="string")if(Do==="all")ni.properties.$localized=!0;else{if(!Do.split(",").includes(z.worldview))return;ni.properties.$localized=!0,ni.properties.worldview=z.worldview}}if(he&&!(0,he.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:z.worldview},ni,this.retainedQueryData[z.bucketInstanceId].tileID.canonical,new i.P(Tr.tileAnchorX,Tr.tileAnchorY),this.transform.calculateDistanceTileData(he.unwrappedTileID)))return this.placements[Ya]=new ti(!1,!1,!1,!0),void x.add(Ya);const Ea=ts.evaluate(ni,{});if(x.has(Ya))return;if($e)return void(this.placements[Ya]=new ti(!1,!1,!1));let On=!1,Za=!1,po=!0,Vi=!1,Xa=!1,ja=null,Rn={box:null,offscreen:null,occluded:null},zi={box:null},Mo=null,oo=null,_i=null,Zd=0,Qc=0,_l=0;vn.textFeatureIndex?Zd=vn.textFeatureIndex:Tr.useRuntimeCollisionCircles&&(Zd=Tr.featureIndex),vn.verticalTextFeatureIndex&&(Qc=vn.verticalTextFeatureIndex);const ud=z.elevationFeatures?z.elevationFeatures[Tr.elevationFeatureIndex]:void 0,hd=bo=>{bo.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const Do=this.transform.elevation;bo.elevation=ss?Ea:Ea+i.bV.getAtTileOffset(bo.tileID,new i.P(bo.tileAnchorX,bo.tileAnchorY),Do,ud),bo.elevation+=Tr.zOffset},Mc=vn.textBox;if(Mc){hd(Mc);const bo=bi=>{let Ho=i.bL.horizontal;if(z.allowVerticalPlacement&&!bi&&this.prevPlacement){const fo=this.prevPlacement.placedOrientations[Ya];fo&&(this.placedOrientations[Ya]=fo,Ho=fo,this.markUsedOrientation(z,Ho,Tr))}return Ho},Do=(bi,Ho)=>{if(z.allowVerticalPlacement&&ui>0&&vn.verticalTextBox){for(const fo of z.writingModes)if(fo===i.bL.vertical?(Rn=Ho(),zi=Rn):Rn=bi(),Rn&&Rn.box&&Rn.box.length)break}else Rn=bi()};if(Xs){let bi=Xs;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ya]){const lo=this.prevPlacement.variableOffsets[Ya];bi.indexOf(lo.anchor)>0&&(bi=bi.filter(om=>om!==lo.anchor),bi.unshift(lo.anchor))}const Ho=(lo,om,Sb)=>{const Vm=z.getSymbolInstanceTextSize(Xe,Tr,this.transform.zoom,Oa),Cb=(lo.x2-lo.x1)*Vm+2*lo.padding,Cv=(lo.y2-lo.y1)*Vm+2*lo.padding,Op=Tr.hasIconTextFit&&!pt?om:null;Op&&hd(Op);let Uf={box:[],offscreen:!1,occluded:!1};const Mv=xt?2*bi.length:bi.length;for(let hx=0;hx=bi.length,Tr,Oa,z,Sb,Op,Xe,ot);if(Vf&&(Uf=Vf.placedGlyphBoxes,Uf&&Uf.box&&Uf.box.length)){On=!0,ja=Vf.shift;break}}return Uf};Do(()=>Ho(Mc,vn.iconBox,i.bL.horizontal),()=>{const lo=vn.verticalTextBox;return lo&&hd(lo),z.allowVerticalPlacement&&!(Rn&&Rn.box&&Rn.box.length)&&ui>0&&lo?Ho(lo,vn.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Rn&&(On=Rn.box,po=Rn.offscreen,Vi=Rn.occluded);const fo=bo(!(!Rn||!Rn.box));if(!On&&this.prevPlacement){const lo=this.prevPlacement.variableOffsets[Ya];lo&&(this.variableOffsets[Ya]=lo,this.markUsedJustification(z,lo.anchor,Tr,fo))}}else{const bi=(Ho,fo)=>{const lo=z.getSymbolInstanceTextSize(Xe,Tr,this.transform.zoom,Oa),om=this.collisionIndex.placeCollisionBox(z,lo,Ho,Me,Ce,br,new i.P(0,0),xt,pe,re,et.predicate);return om&&om.box&&om.box.length&&(this.markUsedOrientation(z,fo,Tr),this.placedOrientations[Ya]=fo),om};Do(()=>bi(Mc,i.bL.horizontal),()=>{const Ho=vn.verticalTextBox;return z.allowVerticalPlacement&&ui>0&&Ho?(hd(Ho),bi(Ho,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),bo(!!(Rn&&Rn.box&&Rn.box.length))}}if(Mo=Rn,On=Mo&&Mo.box&&Mo.box.length>0,po=Mo&&Mo.offscreen,Vi=Mo&&Mo.occluded,Tr.useRuntimeCollisionCircles){const bo=Tr.centerJustifiedTextSymbolIndex>=0?Tr.centerJustifiedTextSymbolIndex:Tr.verticalPlacedTextSymbolIndex,Do=z.text.placedSymbolArray.get(bo),bi=i.bM(z.textSizeData,Xe,Do),Ho=V.get("text-padding");oo=this.collisionIndex.placeCollisionCircles(z,xt,Do,bo,z.lineVertexArray,z.glyphOffsetArray,bi,re,ae,me,T,Ut,et.predicate,Tr.collisionCircleDiameter*bi/i.bY,Ho,this.retainedQueryData[z.bucketInstanceId].tileID),On=xt||oo.circles.length>0&&!oo.collisionDetected,po=po&&oo.offscreen,Vi=oo.occluded}if(vn.iconFeatureIndex&&(_l=vn.iconFeatureIndex),vn.iconBox){const bo=Do=>{hd(Do);const bi=Tr.hasIconTextFit&&ja?rl(ja.x,ja.y,Et,Ut,this.transform.angle):new i.P(0,0),Ho=z.getSymbolInstanceIconSize(ot,this.transform.zoom,Tr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,Ho,Do,Me,Ce,or,bi,pt,pe,re,et.predicate)};zi&&zi.box&&zi.box.length&&vn.verticalIconBox?(_i=bo(vn.verticalIconBox),Za=_i.box.length>0):(_i=bo(vn.iconBox),Za=_i.box.length>0),po=po&&_i.offscreen,Xa=_i.occluded}const mh=vt||Tr.numHorizontalGlyphVertices===0&&ui===0,im=jt||Tr.numIconVertices===0;if(mh||im?im?mh||(Za=Za&&On):On=Za&&On:Za=On=Za&&On,On&&Mo&&Mo.box&&this.collisionIndex.insertCollisionBox(Mo.box,V.get("text-ignore-placement"),z.bucketInstanceId,zi&&zi.box&&Qc?Qc:Zd,et.ID),Za&&_i&&this.collisionIndex.insertCollisionBox(_i.box,V.get("icon-ignore-placement"),z.bucketInstanceId,_l,et.ID),oo&&(On&&this.collisionIndex.insertCollisionCircles(oo.circles,V.get("text-ignore-placement"),z.bucketInstanceId,Zd,et.ID),T)){const bo=z.bucketInstanceId;let Do=this.collisionCircleArrays[bo];Do===void 0&&(Do=this.collisionCircleArrays[bo]=new iS);for(let bi=0;bi=0;--Oa){const vn=Tr[Oa];da(z.symbolInstances.get(vn),vn,z.collisionArrays[vn])}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 Tr=z.getSortedIndexesByZOffset();for(let Oa=0;Oa=0&&(h.text.placedSymbolArray.get(R).crossTileID=me>=0&&R!==me?0:re),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=me>=0&&z!==me?0:re),V>=0&&(h.text.placedSymbolArray.get(V).crossTileID=me>=0&&V!==me?0:re),X>=0&&(h.text.placedSymbolArray.get(X).crossTileID=me>=0&&X!==me?0:re)}markUsedOrientation(h,x,T){const D=x===i.bL.horizontal||x===i.bL.horizontalOnly?x:0,R=x===i.bL.vertical?x:0,{leftJustifiedTextSymbolIndex:z,centerJustifiedTextSymbolIndex:V,rightJustifiedTextSymbolIndex:X,verticalPlacedTextSymbolIndex:re}=T,ae=h.text.placedSymbolArray;z>=0&&(ae.get(z).placedOrientation=D),V>=0&&(ae.get(V).placedOrientation=D),X>=0&&(ae.get(X).placedOrientation=D),re>=0&&(ae.get(re).placedOrientation=R)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const x=this.prevPlacement;let T=!1;this.prevZoomAdjustment=x?x.zoomAdjustment(this.transform.zoom):0;const D=x?x.symbolFadeChange(h):1,R=x?x.opacities:{},z=x?x.variableOffsets:{},V=x?x.placedOrientations:{};for(const X in this.placements){const re=this.placements[X],ae=R[X];ae?(this.opacities[X]=new Cp(ae,D,re.text,re.icon,null,re.clipped),T=T||re.text!==ae.text.placed||re.icon!==ae.icon.placed):(this.opacities[X]=new Cp(null,D,re.text,re.icon,re.skipFade,re.clipped),T=T||re.text||re.icon)}for(const X in R){const re=R[X];if(!this.opacities[X]){const ae=new Cp(re,D,!1,!1);ae.isHidden()||(this.opacities[X]=ae,T=T||re.text.placed||re.icon.placed)}}for(const X in z)this.variableOffsets[X]||!this.opacities[X]||this.opacities[X].isHidden()||(this.variableOffsets[X]=z[X]);for(const X in V)this.placedOrientations[X]||!this.opacities[X]||this.opacities[X].isHidden()||(this.placedOrientations[X]=V[X]);T?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=x?x.lastPlacementChangeTime:h)}updateLayerOpacities(h,x,T,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const R=new Set;for(const z of x){const V=z.getBucket(h);V&&z.latestFeatureIndex&&h.fqid===V.layerIds[0]&&(this.updateBucketOpacities(V,R,z,z.collisionBoxArray,T,D,z.tileID,h.scope),V.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(V,z.tileID),V.elevationType==="road"&&V.updateRoadElevation(z.tileID.canonical),V.updateZOffset())}}updateBucketOpacities(h,x,T,D,R,z,V,X){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 re=h.layers[0].layout,ae=h.layers[0].paint,me=!!h.layers[0].dynamicFilter(),he=new Cp(null,0,!1,!1,!0),pe=re.get("text-allow-overlap"),Me=re.get("icon-allow-overlap"),Ce=re.get("text-variable-anchor"),$e=re.get("text-rotation-alignment")==="map",Be=re.get("text-pitch-alignment")==="map",Xe=ae.get("symbol-z-offset"),ot=re.get("symbol-elevation-reference")==="sea",et=!Xe.isConstant(),Ct=new Cp(null,0,pe&&(Me||!h.hasIconData()||re.get("icon-optional")),Me&&(pe||!h.hasTextData()||re.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const vt=(xt,pt,Et)=>{for(let Ht=0;Ht0||Ht>0,Xs=ts>0,ur=this.placedOrientations[Ut],Ws=ur===i.bL.vertical,Bs=ur===i.bL.horizontal||ur===i.bL.horizontalOnly;!As&&!Xs||es.isHidden()||jt++;let kr=!1;if((As||Xs)&&z)for(const br of h.activeReplacements){if(i.bZ(br,R,i.b_.Symbol,X)||br.min.x>ss||ss>br.max.x||br.min.y>ps||ps>br.max.y)continue;const or=i.b$(ss,ps,V.canonical,br.footprintTileId.canonical);if(kr=i.c0(or,br.footprint),kr)break}if(As){const br=kr?yy:Hd(es.text);vt(h.text,Et,Ws?yy:br),vt(h.text,Ht,Bs?yy:br);const or=es.text.isHidden(),{leftJustifiedTextSymbolIndex:mr,centerJustifiedTextSymbolIndex:$r,rightJustifiedTextSymbolIndex:jn,verticalPlacedTextSymbolIndex:da}=pt,Va=h.text.placedSymbolArray,Tr=or||Ws?1:0;mr>=0&&(Va.get(mr).hidden=Tr),$r>=0&&(Va.get($r).hidden=Tr),jn>=0&&(Va.get(jn).hidden=Tr),da>=0&&(Va.get(da).hidden=or||Bs?1:0);const Oa=this.variableOffsets[Ut];Oa&&this.markUsedJustification(h,Oa.anchor,pt,ur);const vn=this.placedOrientations[Ut];vn&&(this.markUsedJustification(h,"left",pt,vn),this.markUsedOrientation(h,vn,pt))}if(Xs){const br=kr?yy:Hd(es.icon),{placedIconSymbolIndex:or,verticalPlacedIconSymbolIndex:mr}=pt,$r=h.icon.placedSymbolArray,jn=es.icon.isHidden()?1:0;or>=0&&(vt(h.icon,ts,Ws?yy:br),$r.get(or).hidden=jn),mr>=0&&(vt(h.icon,pt.numVerticalIconVertices,Bs?yy:br),$r.get(mr).hidden=jn)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const br=h.collisionArrays[xt];if(br){let or=new i.P(0,0),mr=!0;if(br.textBox||br.verticalTextBox){if(Ce){const jn=this.variableOffsets[Ut];jn?(or=cd(jn.anchor,jn.width,jn.height,jn.textOffset,jn.textScale),$e&&or._rotate(Be?this.transform.angle:-this.transform.angle)):mr=!1}me&&(mr=!es.clipped),br.textBox&&Xg(h.textCollisionBox.collisionVertexArray,es.text.placed,!mr||Ws,Dt,ot,or.x,or.y),br.verticalTextBox&&Xg(h.textCollisionBox.collisionVertexArray,es.text.placed,!mr||Bs,Dt,ot,or.x,or.y)}const $r=mr&&!!(!Bs&&br.verticalIconBox);br.iconBox&&Xg(h.iconCollisionBox.collisionVertexArray,es.icon.placed,$r,Dt,ot,pt.hasIconTextFit?or.x:0,pt.hasIconTextFit?or.y:0),br.verticalIconBox&&Xg(h.iconCollisionBox.collisionVertexArray,es.icon.placed,!$r,Dt,ot,pt.hasIconTextFit?or.x:0,pt.hasIconTextFit?or.y:0)}}}if(h.fullyClipped=jt===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 xt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=xt.invProjMatrix,h.placementViewportMatrix=xt.viewportMatrix,h.collisionCircleArray=xt.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 Xg(C,h,x,T,D,R,z){C.emplaceBack(h?1:0,x?1:0,R||0,z||0,T,D?1:0),C.emplaceBack(h?1:0,x?1:0,R||0,z||0,T,D?1:0),C.emplaceBack(h?1:0,x?1:0,R||0,z||0,T,D?1:0),C.emplaceBack(h?1:0,x?1:0,R||0,z||0,T,D?1:0)}const DM=Math.pow(2,25),J_=Math.pow(2,24),oS=Math.pow(2,17),OM=Math.pow(2,16),lS=Math.pow(2,9),Vd=Math.pow(2,8),Af=Math.pow(2,1);function Hd(C){if(C.opacity===0&&!C.placed)return 0;if(C.opacity===1&&C.placed)return 4294967295;const h=C.placed?1:0,x=Math.floor(127*C.opacity);return x*DM+h*J_+x*oS+h*OM+x*lS+h*Vd+x*Af+h}const yy=0;class nv{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,x,T,D,R,z){const V=this._bucketParts;for(;this._currentTileIndexX.sortKey-re.sortKey));this._currentPartIndex{const X=i.o.now()-z;return!this._forceFullPlacement&&X>2};for(;this._currentPlacementIndex>=0;){const X=x[h[this._currentPlacementIndex]],re=this.placement.collisionIndex.transform.zoom;if(X.type==="symbol"&&X.visibility!=="none"&&(!X.minzoom||X.minzoom<=re)&&(!X.maxzoom||X.maxzoom>re)){const ae=X,me=ae.layout.get("symbol-z-elevate"),he=ae.layout.get("symbol-sort-key").constantOr(1)!==void 0,pe=ae.layout.get("symbol-z-order"),Me=pe==="viewport-y"||pe==="auto"&&!(pe!=="viewport-y"&&he),Ce=ae.layout.get("text-allow-overlap")||ae.layout.get("icon-allow-overlap")||ae.layout.get("text-ignore-placement")||ae.layout.get("icon-ignore-placement"),$e=Me&&Ce,Be=this._inProgressLayer=this._inProgressLayer||new nv(ae),Xe=i.B(X.source,X.scope);if(Be.continuePlacement(me||$e?D[Xe]:T[Xe],this.placement,this._showCollisionBoxes,X,V,R))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const em=512/i.al/2;class Ef{constructor(h,x,T){this.tileID=h,this.bucketInstanceId=T,this.index=new i.c4(x.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=h.canonical.x*i.al,R=h.canonical.y*i.al;for(let z=0;z$e-Be);for(const $e of Ce){const Be=this.crossTileIDs[$e];if(this.keys[$e]===ae&&!T.has(Be)){T.add(Be),re.crossTileID=Be;break}}}}}class Ol{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class RM{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(h){const x=Math.round((h-this.lng)/360);if(x!==0)for(const T in this.indexes){const D=this.indexes[T],R={};for(const z in D){const V=D[z];V.tileID=V.tileID.unwrapTo(V.tileID.wrap+x),R[V.tileID.key]=V}this.indexes[T]=R}this.lng=h}addBucket(h,x,T){if(this.indexes[h.overscaledZ]&&this.indexes[h.overscaledZ][h.key]){if(this.indexes[h.overscaledZ][h.key].bucketInstanceId===x.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(h.overscaledZ,this.indexes[h.overscaledZ][h.key])}for(let R=0;Rh.overscaledZ)for(const V in z){const X=z[V];X.tileID.isChildOf(h)&&X.findMatches(x.symbolInstances,h,D)}else{const V=z[h.scaledTo(Number(R)).key];V&&V.findMatches(x.symbolInstances,h,D)}}for(let R=0;R{x[T]=!0});for(const T in this.layerIndexes)x[T]||delete this.layerIndexes[T]}}const Mp=771;class En{constructor(h,x,T,D){this.blendFunction=h,this.blendColor=x.toNonPremultipliedRenderColor(null),this.mask=T,this.blendEquation=D}}En.Replace=[1,0,1,0],En.disabled=new En(En.Replace,i.ao.transparent,[!1,!1,!1,!1]),En.unblended=new En(En.Replace,i.ao.transparent,[!0,!0,!0,!0]),En.alphaBlended=new En([1,Mp,1,Mp],i.ao.transparent,[!0,!0,!0,!0]),En.alphaBlendedNonPremultiplied=new En([770,Mp,770,Mp],i.ao.transparent,[!0,!0,!0,!0]),En.multiply=new En([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),En.additive=new En([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Er{constructor(h,x,T){this.func=h,this.mask=x,this.range=T}}Er.ReadOnly=!1,Er.ReadWrite=!0,Er.disabled=new Er(519,Er.ReadOnly,[0,1]);const cS=7680;class ln{constructor(h,x,T,D,R,z){this.test=h,this.ref=x,this.mask=T,this.fail=D,this.depthFail=R,this.pass=z}}ln.disabled=new ln({func:519,mask:0},0,0,cS,cS,cS);const av=1029,dS=2305;class rn{constructor(h,x,T){this.enable=h,this.mode=x,this.frontFace=T}}function Tp(C,h){const x=i.ca(C,3);i.cc(C,h),i.cg(C,3,x)}function FM(C,h){const x=i.c7([]);return i.c8(x,x,-h),i.c9(x,x,-C),x}function uS(C,h){const x=[C[0],C[1],0],T=[h[0],h[1],0];if(i.ag(x)>=1e-15){const z=i.aw([],x);i.c5(T,z,i.bJ(T,z)),h[0]=T[0],h[1]=T[1]}const D=i.bI([],h,C);if(i.c6(D)<1e-15)return null;const R=Math.atan2(-D[1],D[0]);return FM(Math.atan2(Math.sqrt(C[0]*C[0]+C[1]*C[1]),-C[2]),R)}rn.disabled=new rn(!1,av,dS),rn.backCCW=new rn(!0,av,dS),rn.backCW=new rn(!0,av,2304),rn.frontCW=new rn(!0,1028,2304),rn.frontCCW=new rn(!0,1028,dS);class Wd{constructor(h,x){this.position=h,this.orientation=x}get position(){return this._position}set position(h){if(h){const x=h instanceof i.ae?h:new i.ae(h[0],h[1],h[2]);this._renderWorldCopies&&(x.x=i.bT(x.x,0,1)),this._position=x}else this._position=null}lookAtPoint(h,x,T){if(this.orientation=null,!this.position)return;const D=this.position,R=T||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(h)):0),z=i.ae.fromLngLat(h,R),V=[z.x-D.x,z.y-D.y,z.z-D.z];x||(x=[0,0,1]),x[2]=Math.abs(x[2]),this.orientation=uS(V,x)}setPitchBearing(h,x){this.orientation=FM(i.an(h),i.an(-x))}}class hS{constructor(h,x){this._transform=i.bA([]),this.orientation=x,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 x;h&&i.cg(this._transform,3,[(x=h)[0],x[1],x[2],1])}get orientation(){return this._orientation}set orientation(h){this._orientation=h||i.c7([]),h&&Tp(this._transform,this._orientation)}getPitchBearing(){const h=this.forward(),x=this.right();return{bearing:Math.atan2(-x[1],x[0]),pitch:Math.atan2(Math.sqrt(h[0]*h[0]+h[1]*h[1]),-h[2])}}setPitchBearing(h,x){this._orientation=FM(h,x),Tp(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,x){const T=new Float64Array(16);return i.bl(T,this.getWorldToCamera(h,x)),T}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(h,x,T){const D=this.position;i.c5(D,D,-h);const R=new Float64Array(16);return i.bq(R,[T,T,T]),i.br(R,R,D),R[10]*=x,R}getWorldToCamera(h,x){const T=new Float64Array(16),D=new Float64Array(4),R=this.position;return i.cb(D,this._orientation),i.c5(R,R,-h),i.cc(T,D),i.br(T,T,R),T[1]*=-1,T[5]*=-1,T[9]*=-1,T[13]*=-1,T[8]*=x,T[9]*=x,T[10]*=x,T[11]*=x,T}getCameraToClipPerspective(h,x,T,D){const R=new Float64Array(16);return i.cd(R,h,x,T,D),R}getCameraToClipOrthographic(h,x,T,D,R,z){const V=new Float64Array(16);return i.ce(V,h,x,T,D,R,z),V}getDistanceToElevation(h,x=!1){const T=h===0?0:i.cf(h,x?i.a$(this.position[1]):this.position[1]),D=this.forward();return(T-this.position[2])/D[2]}clone(){return new hS([...this.position],[...this.orientation])}}const gc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class mS{constructor(h=0,x=0,T=0,D=0){if(isNaN(h)||h<0||isNaN(x)||x<0||isNaN(T)||T<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=x,this.left=T,this.right=D}interpolate(h,x,T){return x.top!=null&&h.top!=null&&(this.top=i.ak(h.top,x.top,T)),x.bottom!=null&&h.bottom!=null&&(this.bottom=i.ak(h.bottom,x.bottom,T)),x.left!=null&&h.left!=null&&(this.left=i.ak(h.left,x.left,T)),x.right!=null&&h.right!=null&&(this.right=i.ak(h.right,x.right,T)),this}getCenter(h,x){const T=i.aA((this.left+h-this.right)/2,0,h),D=i.aA((this.top+x-this.bottom)/2,0,x);return new i.P(T,D)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new mS(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Bm=15;class zM{constructor(h,x,T,D,R,z,V){this.tileSize=512,this._renderWorldCopies=R===void 0||R,this._minZoom=h||0,this._maxZoom=x||22,this._minPitch=T??0,this._maxPitch=D??60,this.setProjection(z),this.setMaxBounds(V),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 mS,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new hS,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 zM(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&&(!x||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const T=this._elevation;x||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&T.exaggeration()&&this._centerAltitudeValidForExaggeration!==T.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*T.exaggeration(),this._centerAltitudeValidForExaggeration=T.exaggeration()):(this._centerAltitude=h||0,this._centerAltitudeValidForExaggeration=T.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,x=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],T=this.horizonLineFromTop();let D=0,R=0;for(let z=0;z{const $e=i.cY(he,me,pe,Me,Ce);X.has($e)||(R.push(new i.aQ(me,he,pe,Me,Ce)),X.add($e))};for(let me=0;mehe.canonical.z)continue;const pe=he.canonical,Me=he.overscaledZ,Ce=he.wrap,$e=1<0,ot=pe.y+1<$e,et=pe.y>0,Ct=he.wrap-(Xe?0:1),vt=he.wrap+(Be?0:1),jt=Xe?pe.x-1:$e-1,xt=Be?pe.x+1:0;if(z)T[0]<0?(re(Me,vt,pe.z,xt,pe.y),T[1]<0&&ot&&(re(Me,Ce,pe.z,pe.x,pe.y+1),re(Me,vt,pe.z,xt,pe.y+1)),T[1]>0&&et&&(re(Me,Ce,pe.z,pe.x,pe.y-1),re(Me,vt,pe.z,xt,pe.y-1))):T[0]>0?(re(Me,Ct,pe.z,jt,pe.y),T[1]<0&&ot&&(re(Me,Ce,pe.z,pe.x,pe.y+1),re(Me,Ct,pe.z,jt,pe.y+1)),T[1]>0&&et&&(re(Me,Ce,pe.z,pe.x,pe.y-1),re(Me,Ct,pe.z,jt,pe.y-1))):T[1]<0&&ot?re(Me,Ce,pe.z,pe.x,pe.y+1):et&&re(Me,Ce,pe.z,pe.x,pe.y-1);else{const pt=he.visibleQuadrants;1&pt&&(re(Me,Ct,pe.z,jt,pe.y),et&&(re(Me,Ce,pe.z,pe.x,pe.y-1),re(Me,Ct,pe.z,jt,pe.y-1))),2&pt&&(re(Me,vt,pe.z,xt,pe.y),et&&(re(Me,Ce,pe.z,pe.x,pe.y-1),re(Me,vt,pe.z,xt,pe.y-1))),4&pt&&(re(Me,Ct,pe.z,jt,pe.y),ot&&(re(Me,Ce,pe.z,pe.x,pe.y+1),re(Me,Ct,pe.z,jt,pe.y+1))),8&pt&&(re(Me,vt,pe.z,xt,pe.y),ot&&(re(Me,Ce,pe.z,pe.x,pe.y+1),re(Me,vt,pe.z,xt,pe.y+1)))}}const ae=[];for(const me of R)R.some(he=>me.isChildOf(he))||ae.push(me);if(R=ae.filter(me=>!h.some(he=>!!(me.overscaledZ{const Be=$e.canonical.x+.5-pe[0],Xe=$e.canonical.y+.5-pe[1];return Be*Be+Xe*Xe{const jt=i.cY(ot,Xe,et,Ct,vt);R.has(jt)||(D.push(new i.aQ(Xe,ot,et,Ct,vt)),R.add(jt))},V=h.reduce((Xe,ot)=>Math.max(Xe,ot.overscaledZ),T),X=1<{const et=Math.floor(Xe[0]),Ct=Math.floor(Xe[1]),vt=(Xe[0]-et)*i.al,jt=(Xe[1]-Ct)*i.al,xt=Math.floor(ot[0]),pt=Math.floor(ot[1]),Et=(ot[0]-xt)*i.al,Ht=(ot[1]-pt)*i.al;for(let Ut=-1;Ut<=1;Ut++){const ts=et+Ut;if(!(ts<0||ts>=X)){ae.x=vt-Ut*i.al,me.x=Et-(ts-xt)*i.al;for(let ss=-1;ss<=1;ss++){const ps=Ct+ss;ae.y=jt-ss*i.al,me.y=Ht-(ps-pt)*i.al,i.cZ(ae,me,re)&&z(V,0,T,ts,ps)}}}},pe=x.points,Me=pe[i.cv],Ce=pe[i.cw],$e=this._projectToGround(Me,pe[i.cx]),Be=this._projectToGround(Ce,pe[i.cy]);return he(Me,$e),he(Ce,Be),D}_projectToGround(h,x){return i.cz(i.cA(),h,x,h[2]/(h[2]-x[2]))}coveringTiles(h){let x=this.coveringZoomLevel(h);const T=x,D=this.elevation&&this.elevation.exaggeration(),R=D&&!h.isTerrainDEM,z=this.projection.name==="mercator";if(h.minzoom!==void 0&&xh.maxzoom&&(x=h.maxzoom);const V=this.locationCoordinate(this.center),X=this.center.lat,re=1<{const es=new i.ae(Dt.x+25e-6,Dt.y,Dt.z),As=new i.ae(Dt.x,Dt.y+25e-6,Dt.z),Xs=Dt.toLngLat(),ur=es.toLngLat(),Ws=As.toLngLat(),Bs=this.locationCoordinate(Xs),kr=this.locationCoordinate(ur),br=this.locationCoordinate(Ws),or=Math.hypot(kr.x-Bs.x,kr.y-Bs.y),mr=Math.hypot(br.x-Bs.x,br.y-Bs.y);return Math.sqrt(or*mr)*jt/25e-6},pt=Dt=>{const ls=Ct,es=vt;return{aabb:i.cF(this,re,0,0,0,Dt,es,ls,this.projection),zoom:0,x:0,y:0,minZ:es,maxZ:ls,wrap:Dt,fullyVisible:!1}},Et=[];let Ht=[];const Ut=x,ts=h.reparseOverscaled?T:x,ss=($e-this._centerAltitude)*Ce,ps=Dt=>{if(!this._elevation||!Dt.tileID||!z)return;const ls=this._elevation.getMinMaxForTile(Dt.tileID),es=Dt.aabb;ls?(es.min[2]=ls.min,es.max[2]=ls.max,es.center[2]=(es.min[2]+es.max[2])/2):(Dt.shouldSplit=Xt(Dt),Dt.shouldSplit||(es.min[2]=es.max[2]=es.center[2]=this._centerAltitude))},zs=(Dt,ls)=>{if(.707*ls{if(Dt.zoom=.9)return!0}else if(R&&(As=Dt.aabb.distanceZ(Be)*Ce),this.projection.isReprojectedInTileSpace&&T<=5){const mr=Math.pow(2,Dt.zoom),$r=xt(new i.ae((Dt.x+.5)/mr,(Dt.y+.5)/mr));Xs=$r>.85?1:$r}if(!z&&!me){const mr=Math.sqrt(ls*ls+es*es+As*As);let $r=(1<0;){const Dt=Et.pop(),ls=Dt.x,es=Dt.y;let As=Dt.fullyVisible;const Xs=()=>this.projection.name==="globe"&&(Dt.y===0||Dt.y===(1<>1),kr={aabb:z?Dt.aabb.quadrant(ur):i.cF(this,re,Dt.zoom+1,Ws,Bs,Dt.wrap,Dt.minZ,Dt.maxZ,this.projection),zoom:Dt.zoom+1,x:Ws,y:Bs,wrap:Dt.wrap,fullyVisible:As,tileID:void 0,shouldSplit:void 0,minZ:Dt.minZ,maxZ:Dt.maxZ};R&&!me&&(kr.tileID=new i.aQ(Dt.zoom+1===Ut?ts:Dt.zoom+1,Dt.wrap,Dt.zoom+1,Ws,Bs),ps(kr)),Et.push(kr)}else{const ur=Dt.zoom===Ut?ts:Dt.zoom;if(h.minzoom&&h.minzoom>ur)continue;let Ws=0;if(!As){let or=Xe?Dt.aabb.intersectsPrecise(pe):Dt.aabb.intersectsPreciseFlat(pe);if(or===0&&Xs()){const mr=new i.cD(Dt.zoom,ls,es);or=i.cE(this,re,mr,!0).intersectsPrecise(pe)}if(or===0)continue;if(h.calculateQuadrantVisibility)if(pe.containsPoint(Dt.aabb.center))Ws=15;else for(let mr=0;mr<4;mr++)Dt.aabb.quadrant(mr).intersects(pe)!==0&&(Ws|=1<{const As=[0,0,0,1],Xs=[i.al,i.al,0,1],ur=this.calculateFogTileMatrix(es.tileID.toUnwrapped());i.aC(As,As,ur),i.aC(Xs,Xs,ur);const Ws=i.cG([],As,Xs),Bs=i.cH([],As,Xs),kr=i.c$(Ws,Bs);if(kr===0)return!0;let br=!1;const or=this._elevation;if(or&&kr>Dt&&ls!==0){const mr=this.calculateProjMatrix(es.tileID.toUnwrapped());let $r;h.isTerrainDEM||($r=or.getMinMaxForTile(es.tileID)),$r||($r={min:vt,max:Ct});const jn=i.cI(this.rotation),da=[jn[0]*i.al,jn[1]*i.al,$r.max];i.af(da,da,mr),br=(1-da[1])*this.height*.5Dt.distanceSq-ls.distanceSq).map(Dt=>Dt.tileID)}resize(h,x){this.width=h,this.height=x,this.pixelsToGLUnits=[2/h,-2/x],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 x=i.aA(h.lat,-i.cJ,i.cJ),T=this.projection.project(h.lng,x);return new i.P(T.x*this.worldSize,T.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,x){let T,D;const R=this.centerPoint;if(this.projection.name==="globe"){const V=this.worldSize;T=(x.x-R.x)/V,D=(x.y-R.y)/V}else{const V=this.pointCoordinate(x),X=this.pointCoordinate(R);T=V.x-X.x,D=V.y-X.y}const z=this.locationCoordinate(h);this.setLocation(new i.ae(z.x-T,z.y-D))}setLocation(h){this.center=this.coordinateLocation(h),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(h,x){return this.projection.locationPoint(this,h,x)}locationPoint3D(h,x){return this.projection.locationPoint(this,h,x,!0)}pointLocation(h){return this.coordinateLocation(this.pointCoordinate(h))}pointLocation3D(h,x){return this.coordinateLocation(this.pointCoordinate3D(h,x))}locationCoordinate(h,x){const T=x?i.cf(x,h.lat):void 0,D=this.projection.project(h.lng,h.lat);return new i.ae(D.x,D.y,T)}coordinateLocation(h){return this.projection.unproject(h.x,h.y)}pointRayIntersection(h,x){const T=x??this._centerAltitude,D=[h.x,h.y,0,1],R=[h.x,h.y,1,1];i.aC(D,D,this.pixelMatrixInverse),i.aC(R,R,this.pixelMatrixInverse);const z=R[3];i.cK(D,D,1/D[3]),i.cK(R,R,1/z);const V=D[2],X=R[2];return{p0:D,p1:R,t:V===X?0:(T-V)/(X-V)}}screenPointToMercatorRay(h){const x=[h.x,h.y,0,1],T=[h.x,h.y,1,1];return i.aC(x,x,this.pixelMatrixInverse),i.aC(T,T,this.pixelMatrixInverse),i.cK(x,x,1/x[3]),i.cK(T,T,1/T[3]),x[2]=i.cf(x[2],this._center.lat)*this.worldSize,T[2]=i.cf(T[2],this._center.lat)*this.worldSize,i.cK(x,x,1/this.worldSize),i.cK(T,T,1/this.worldSize),new i.ax([x[0],x[1],x[2]],i.aw([],i.av([],T,x)))}rayIntersectionCoordinate(h){const{p0:x,p1:T,t:D}=h,R=i.cf(x[2],this._center.lat),z=i.cf(T[2],this._center.lat);return new i.ae(i.ak(x[0],T[0],D)/this.worldSize,i.ak(x[1],T[1],D)/this.worldSize,i.ak(R,z,D))}pointCoordinate(h,x=this._centerAltitude){return this.projection.pointCoordinate(this,h.x,h.y,x)}pointCoordinate3D(h,x){if(!this.elevation)return this.pointCoordinate(h,x);let T=this.projection.pointCoordinate3D(this,h.x,h.y);if(T)return new i.ae(T[0],T[1],T[2]);let D=0,R=this.horizonLineFromTop();if(h.y>R)return this.pointCoordinate(h,x);const z=.02*R,V=h.clone();for(let X=0;X<10&&R-D>z;X++){V.y=i.ak(D,R,.66);const re=this.projection.pointCoordinate3D(this,V.x,V.y);re?(R=V.y,T=re):D=V.y}return T?new i.ae(T[0],T[1],T[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 x=this.pointCoordinate(h);return x.y>=0&&x.y<=1}_coordinatePoint(h,x){const T=x&&this.elevation?this.elevation.getAtPointOrZero(h,this._centerAltitude):this._centerAltitude,D=[h.x*this.worldSize,h.y*this.worldSize,T+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:x}=this._edgeInsets,T=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,R=this.pointLocation3D(new i.P(x,h)),z=this.pointLocation3D(new i.P(D,h)),V=this.pointLocation3D(new i.P(D,T)),X=this.pointLocation3D(new i.P(x,T));let re=Math.min(R.lng,z.lng,V.lng,X.lng),ae=Math.max(R.lng,z.lng,V.lng,X.lng),me=Math.min(R.lat,z.lat,V.lat,X.lat),he=Math.max(R.lat,z.lat,V.lat,X.lat);const pe=Math.pow(2,-this.zoom)/16*270,Me=this.projection.name==="globe"?1:4,Ce=($e,Be,Xe,ot,et)=>{const Ct=($e+Xe)/2,vt=(Be+ot)/2,jt=new i.P(Ct,vt),{lng:xt,lat:pt}=this.pointLocation3D(jt),Et=Math.max(0,re-xt,me-pt,xt-ae,pt-he);re=Math.min(re,xt),ae=Math.max(ae,xt),me=Math.min(me,pt),he=Math.max(he,pt),(etpe)&&(Ce($e,Be,Ct,vt,et+1),Ce(Ct,vt,Xe,ot,et+1))};if(Ce(x,h,D,h,1),Ce(D,h,D,T,1),Ce(D,T,x,T,1),Ce(x,T,x,h,1),this.projection.name==="globe"){const[$e,Be]=i.cM(this);$e?(he=90,ae=180,re=-180):Be&&(me=-90,ae=180,re=-180)}return new i.aI(new i.aT(re,me),new i.aT(ae,he))}_getBoundsRectangular(h,x){const{top:T,left:D}=this._edgeInsets,R=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,V=new i.P(D,T),X=new i.P(z,T),re=new i.P(z,R),ae=new i.P(D,R);let me=this.pointCoordinate(V,h),he=this.pointCoordinate(X,h);const pe=this.pointCoordinate(re,x),Me=this.pointCoordinate(ae,x),Ce=($e,Be)=>(Be.y-$e.y)/(Be.x-$e.x);return me.y>1&&he.y>=0?me=new i.ae((1-Me.y)/Ce(Me,me)+Me.x,1):me.y<0&&he.y<=1&&(me=new i.ae(-Me.y/Ce(Me,me)+Me.x,0)),he.y>1&&me.y>=0?he=new i.ae((1-pe.y)/Ce(pe,he)+pe.x,1):he.y<0&&me.y<=1&&(he=new i.ae(-pe.y/Ce(pe,he)+pe.x,0)),new i.aI().extend(this.coordinateLocation(me)).extend(this.coordinateLocation(he)).extend(this.coordinateLocation(Me)).extend(this.coordinateLocation(pe))}_getBoundsRectangularTerrain(){const h=this.elevation;if(!h.visibleDemTiles.length||h.isUsingMockSource())return this._getBoundsRectangular(0,0);const x=h.visibleDemTiles.reduce((T,D)=>{if(D.dem){const R=D.dem.tree;T.min=Math.min(T.min,R.minimums[0]),T.max=Math.max(T.max,R.maximums[0])}return T},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(x.min*h.exaggeration(),x.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 x=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,T=this.height/2-x*(1-this._horizonShift);return h?Math.max(0,T):T}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.maxLngme&&(V=me-re),me-aepe&&(z=pe-X),pe-he{for(let Xt=0;Xt<16;Xt++)ts[Xt]=i.ak(ss[Xt],ps[Xt],zs)})(V,V,X,i.d0(this.pitch>=Bm?1:this.pitch/Bm))}else V=X;const re=i.cP([],X,z);let ae=i.cP([],V,z);if(this.projection.isReprojectedInTileSpace){const pt=this.locationCoordinate(this.center),Et=i.bA([]);i.br(Et,Et,[pt.x*this.worldSize,pt.y*this.worldSize,0]),i.aB(Et,Et,i.cQ(this)),i.br(Et,Et,[-pt.x*this.worldSize,-pt.y*this.worldSize,0]),i.aB(ae,ae,Et),i.aB(re,re,Et),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],ae,[this.worldSize,this.worldSize,this.worldSize/R,1]),this.projMatrix=ae,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),x){const pt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);pt[8]=2*-h.x/this.width,pt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],pt,z)}else this.expandedFarZProjMatrix=this.projMatrix;const me=i.bl([],V);this.frustumCorners=i.cT.fromInvProjectionMatrix(me,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!x);const he=new Float32Array(16);i.bA(he),i.cS(he,he,[1,-1,1]),i.cU(he,he,this._pitch),i.bB(he,he,this.angle);const pe=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(pe);const Me=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;pe[8]=2*-h.x/this.width,pe[9]=2*(h.y+Me)/this.height,this.skyboxMatrix=i.aB(he,pe,he);const Ce=this.point,$e=Ce.x,Be=Ce.y,Xe=this.width%2/2,ot=this.height%2/2,et=Math.cos(this.angle),Ct=Math.sin(this.angle),vt=$e-Math.round($e)+et*Xe+Ct*ot,jt=Be-Math.round(Be)+et*ot+Ct*Xe,xt=new Float64Array(ae);if(i.br(xt,xt,[vt>.5?vt-1:vt,jt>.5?jt-1:jt,0]),this.alignedProjMatrix=xt,ae=i.bC(),i.cS(ae,ae,[this.width/2,-this.height/2,1]),i.br(ae,ae,[1,-1,0]),this.labelPlaneMatrix=ae,ae=i.bC(),i.cS(ae,ae,[1,-1,1]),i.br(ae,ae,[-1,-1,0]),i.cS(ae,ae,[2/this.width,2/this.height,1]),this.glCoordMatrix=ae,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,re),this._calcFogMatrices(),this._distanceTileDataCache={},ae=i.bl(new Float64Array(16),this.pixelMatrix),!ae)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=ae,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const pt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(pt,pt,z),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=ae;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const h=this.cameraWorldSizeForFog,x=this.cameraPixelsPerMeter,T=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,R=[h,h,x];i.c5(R,R,D),i.c5(T,T,-1),i.cW(T,T,R);const z=i.bC();i.br(z,z,T),i.cS(z,z,R),this.mercatorFogMatrix=z,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(h,x,D)}_computeCameraPosition(h){const x=(h=h||this.pixelsPerMeter)/this.pixelsPerMeter,T=this._camera.forward(),D=this.point,R=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*x-h/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-T[0]*R,D.y/this.worldSize-T[1]*R,h/this.worldSize*this._centerAltitude-T[2]*R]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(h){const x=this._maxCameraBoundsDistance()*Math.cos(this._pitch),T=this._camera.position[2],D=h[2];let R=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(R=Math.min((x-T)/D,1)),this._camera.position=i.bH([],this._camera.position,h,R),this._updateStateFromCamera()}_updateStateFromCamera(){const h=this._camera.position,x=this._camera.forward(),{pitch:T,bearing:D}=this._camera.getPitchBearing(),R=i.cf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,z=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.an(this._maxPitch)),V=Math.max((h[2]-R)/Math.cos(T),z),X=this._zoomFromMercatorZ(V);i.bH(h,h,x,V),this._pitch=i.aA(T,i.an(this.minPitch),i.an(this.maxPitch)),this.angle=i.bT(D,-Math.PI,Math.PI),this._setZoom(i.aA(X,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 x=0,T=i.cL,D=0,R=1/0;for(;T-x>1e-6&&T>x;){const z=x+.5*(T-x),V=this.tileSize*Math.pow(2,z),X=this.getCameraToCenterDistance(this.projection,z,V),re=this.scaleZoom(X/(Math.max(0,h)*this.tileSize)),ae=Math.abs(z-re);aere||he.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,x){const T=i.ag(i.av([],this._camera.position,h)),D=this._zoomFromMercatorZ(T)+x;return T-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const h=function([x,T,D],R){const z=[x,T,D,1];i.aC(z,z,R);const V=z[3]=Math.max(z[3],1e-6);return z[0]/=V,z[1]/=V,z[2]/=V,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,x=this.zoom,T=this.worldSize){const D=i.cO(h,x,this.width,this.height,1024),R=h.pixelSpaceConversion(this.center.lat,T,D);let z=.5/Math.tan(.5*this._fov)*this.height*R;return this.isOrthographic&&(z=i.ak(1,z,i.d0(this.pitch>=Bm?1:this.pitch/Bm))),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 Qg=(C,h)=>{if(h>0&&C.terrain&&i.w("Cutoff is currently disabled on terrain"),h<=0||C.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const x=C.transform,T=Math.max(Math.abs(x._zoom-(C.minCutoffZoom-1)),1),D=x.isLODDisabled(!1)?i.ah(60,45,x.pitch):i.ah(30,15,x.pitch),R=x._farZ-x._nearZ,z=h*x.height,V=((1-(X=D))*x.cameraToCenterDistance+X*(x._farZ+z))*T;var X;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[x._nearZ,x._farZ,(V-x._nearZ)/R,(V-z-x._nearZ)/R]}}},tm=2048;class eb{constructor(h,x){this.aabb=h,this.lastCascade=x}}class jce{add(h,x){const T=this.receivers[h.key];T!==void 0?(T.aabb.min[0]=Math.min(T.aabb.min[0],x.min[0]),T.aabb.min[1]=Math.min(T.aabb.min[1],x.min[1]),T.aabb.min[2]=Math.min(T.aabb.min[2],x.min[2]),T.aabb.max[0]=Math.max(T.aabb.max[0],x.max[0]),T.aabb.max[1]=Math.max(T.aabb.max[1],x.max[1]),T.aabb.max[2]=Math.max(T.aabb.max[2],x.max[2])):this.receivers[h.key]=new eb(x,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,x,T){const D=i.d9.fromPoints(h.points);let R=0;for(const z in this.receivers){const V=this.receivers[z];if(!V||!D.intersectsAabb(V.aabb))continue;V.aabb.min=D.closestPoint(V.aabb.min),V.aabb.max=D.closestPoint(V.aabb.max);const X=V.aabb.getCorners();for(let re=0;re1||he[1]<-1||he[1]>1){ae=!1;break}}if(V.lastCascade=re,R=Math.max(R,re),ae)break}}return R+1}}class iv{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new jce,this._depthMode=new Er(h.context.gl.LEQUAL,Er.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,x){const T=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!x||!x.properties)return;const D=x.properties.get("shadow-intensity");if(!x.shadowsEnabled()||D<=0||(this._shadowLayerCount=T.style.order.reduce((Me,Ce)=>{const $e=T.style._mergedLayers[Ce];return Me+($e.hasShadowPass()&&!$e.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const R=T.context,z=tm,V=tm;if(this._cascades.length===0||tm!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Me=0;Me<2;++Me){const Ce=T._shadowMapDebug,$e=R.gl,Be=R.createFramebuffer(z,V,Ce?1:0,"texture"),Xe=new i.T(R,{width:z,height:V,data:null},$e.DEPTH_COMPONENT16);if(Be.depthAttachment.set(Xe.texture),Ce){const ot=new i.T(R,{width:z,height:V,data:null},$e.RGBA8);Be.colorAttachment0.set(ot.texture)}this._cascades.push({framebuffer:Be,texture:Xe,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=sb(x);let X=0;if(h.elevation){const Me=h.elevation,Ce=[1e4,-1e4];Me.visibleDemTiles.filter($e=>$e.dem).forEach($e=>{const Be=$e.dem.tree;Ce[0]=Math.min(Ce[0],Be.minimums[0]),Ce[1]=Math.max(Ce[1],Be.maximums[0])}),Ce[0]!==1e4&&(X=(Ce[1]-Ce[0])*Me.exaggeration())}const re=1.5*h.cameraToCenterDistance,ae=3*re,me=new Float64Array(16);for(let Me=0;Me=0)return{};const R=function(X,re,ae){const me=ae/(1<0&&(i.d8(R[1],R[1],[D[0]*z,0,0]),i.d8(R[2],R[2],[D[0]*z,0,0])),D[1]<0?(i.d8(R[0],R[0],[0,D[1]*z,0]),i.d8(R[1],R[1],[0,D[1]*z,0])):D[1]>0&&(i.d8(R[2],R[2],[0,D[1]*z,0]),i.d8(R[3],R[3],[0,D[1]*z,0]));const V={};return V.vertices=R,V.planes=[tb(R[1],R[0],R[4]),tb(R[2],R[1],R[5]),tb(R[3],R[2],R[6]),tb(R[0],R[3],R[7])],V}addShadowReceiver(h,x,T){this._receivers.add(h,i.d9.fromTileIdAndHeight(h,x,T))}getMaxCascadeForTile(h){const x=this._receivers.get(h);return x&&x.lastCascade?x.lastCascade:0}}function tb(C,h,x){const T=i.av([],x,h),D=i.av([],C,h),R=i.bI([],T,D),z=i.ag(R);return z===0?[0,0,1,0]:(i.c5(R,R,1/z),[R[0],R[1],R[2],-i.bJ(R,h)])}function sb(C){const h=C.properties.get("direction"),x=i.d4(h.x,h.y,h.z);x[2]=i.aA(x[2],0,75);const T=i.d6([x[0],x[1],x[2]]);return i.d5(T.x,T.y,T.z)}function Pf(C,h,x){const T=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),R=h.properties.get("intensity"),z=h.properties.get("direction"),V=[z.x,z.y,z.z],X=x.properties.get("color-use-theme")==="none",re=x.properties.get("color"),ae=x.properties.get("intensity"),me=Math.max(i.bJ([0,0,1],V),0),he=[0,0,0];i.c5(he,re.toPremultipliedRenderColor(X?null:C.getLut(h.scope)).toArray01Linear().slice(0,3),ae);const pe=[0,0,0];return i.c5(pe,D.toPremultipliedRenderColor(T?null:C.getLut(x.scope)).toArray01Linear().slice(0,3),me*R),i.db([he[0]>0?he[0]/(he[0]+pe[0]):0,he[1]>0?he[1]/(he[1]+pe[1]):0,he[2]>0?he[2]/(he[2]+pe[2]):0])}function Jg(C,h,x,T,D,R){const z=C.zoom,V=C.scale,X=C.worldSize,re=1/X,ae=C.aspect,me=Math.sqrt(1+ae*ae)*Math.tan(.5*C.fovX),he=me*me,pe=T-x,Me=T+x;let Ce,$e;he>pe/Me?(Ce=T,$e=T*me):(Ce=.5*Me*(1+he),$e=.5*Math.sqrt(pe*pe+2*(T*T+x*x)*he+Me*Me*he*he));const Be=C.projection.pixelsPerMeter(C.center.lat,X),Xe=C._camera.getCameraToWorldMercator(),ot=[0,0,-Ce*re];i.af(ot,ot,Xe);let et=$e*re;const Ct=C._edgeInsets;if(!(Ct.left===0&&Ct.top===0&&Ct.right===0&&Ct.bottom===0||Ct.left===Ct.right&&Ct.top===Ct.bottom)){const As=C._camera.getWorldToCamera(C.worldSize,C.projection.zAxisUnit==="meters"?Be:1),Xs=C._camera.getCameraToClipPerspective(C._fov,C.width/C.height,x,T);Xs[8]=2*-C.centerOffset.x/C.width,Xs[9]=2*C.centerOffset.y/C.height;const ur=new Float64Array(16);i.cP(ur,Xs,As);const Ws=new Float64Array(16);i.bl(Ws,ur);const Bs=i.cB.fromInvProjectionMatrix(Ws,X,z,!0);for(const kr of Bs.points){const br=((vt=kr)[0]/=V,vt[1]/=V,vt[2]=i.cf(vt[2],C._center.lat),vt);et=Math.max(et,i.c6(i.da([],ot,br)))}}var vt;et*=D/(D-1);const jt=Math.acos(h[2]),xt=Math.atan2(-h[0],-h[1]),pt=new hS;pt.position=ot,pt.setPitchBearing(jt,xt);const Et=pt.getWorldToCamera(X,Be),Ht=et*X,Ut=Math.min(C._mercatorZfromZoom(17)*X*-2,-2*Ht),ts=pt.getCameraToClipOrthographic(-Ht,Ht,-Ht,Ht,Ut,(Ht+R*Be)/h[2]),ss=new Float64Array(16);i.aB(ss,ts,Et);const ps=i.d5(Math.floor(1e6*ot[0])/1e6*X,Math.floor(1e6*ot[1])/1e6*X,0),zs=.5*D,Xt=[0,0,0];i.af(Xt,ps,ss),i.c5(Xt,Xt,zs);const Dt=[Math.floor(Xt[0]),Math.floor(Xt[1]),Math.floor(Xt[2])],ls=[0,0,0];i.av(ls,Xt,Dt),i.c5(ls,ls,-1/zs);const es=new Float64Array(16);return i.bA(es),i.br(es,es,ls),i.aB(ss,es,ss),[ss,Ht]}class kce extends i.E{constructor(h){super(),this.requestManager=h,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(h,x){return i.dc(this.requestManager.transformRequest(x,i.R.Model).url).then(T=>{if(!T)return;const D=i.dd(T),R=new i.de(h,x,void 0,void 0,D);return R.computeBoundsAndApplyParent(),R}).catch(T=>{if(T&&T.status===404)return null;this.fire(new i.y(new Error(`Could not load model ${h} from ${x}: ${T.message}`)))})}load(h,x,T={forceReload:!1}){this.models[x]||(this.models[x]={});const D=Object.keys(h),R=[],z=[];for(const V of D){const X=h[V];this.hasURLBeenRequested(X)&&!T.forceReload||(this.modelByURL[X]={modelId:V,scope:x},R.push(this.loadModel(V,X)),z.push(V)),this.models[x][V]||(this.models[x][V]={model:null,numReferences:1})}this.numModelsLoading[x]=(this.numModelsLoading[x]||0)+z.length,Promise.allSettled(R).then(V=>{for(let X=0;X{this.fire(new i.y(new Error(`Could not load models: ${V.message}`)))})}isLoaded(){for(const h in this.numModelsLoading)if(this.numModelsLoading[h]>0)return!1;return!0}hasModel(h,x,T={exactIdMatch:!1}){return!!(T.exactIdMatch?this.getModel(h,x):this.getModelByURL(this.modelUris[x][h]))}getModel(h,x){return this.models[x]||(this.models[x]={}),this.models[x][h]?this.models[x][h].model:void 0}getModelByURL(h){if(!h)return null;const x=this.modelByURL[h];return x?this.models[x.scope][x.modelId].model:null}hasModelBeenAdded(h,x){return this.models[x]&&this.models[x][h]!==void 0}getModelURIs(h){return this.modelUris[h]||{}}addModel(h,x,T){this.models[T]||(this.models[T]={}),this.modelUris[T]||(this.modelUris[T]={});const D=this.requestManager.normalizeModelURL(x);if((this.hasModel(h,T,{exactIdMatch:!0})||this.hasModelBeenAdded(h,T))&&this.modelUris[T][h]===D)this.models[T][h].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:R,modelId:z}=this.modelByURL[D];this.models[R][z].numReferences++}else this.modelUris[T][h]=D,this.load({[h]:this.modelUris[T][h]},T)}addModelURLs(h,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const T=this.modelUris[x];for(const D in h)T[D]=this.requestManager.normalizeModelURL(h[D])}reloadModels(h){this.load(this.modelUris[h],h,{forceReload:!0})}addModelsFromBucket(h,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const T={};for(const D of h)this.hasModel(D,x,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[x][D].numReferences++:this.modelUris[x][D]&&!this.hasURLBeenRequested(D)?T[D]=this.modelUris[x][D]:!this.hasURLBeenRequested(D)&&i.df(D,!1)&&(this.modelUris[x][D]=this.requestManager.normalizeModelURL(D),T[D]=this.modelUris[x][D]);this.load(T,x)}hasURLBeenRequested(h){return this.modelByURL[h]!==void 0}removeModel(h,x,T=!1,D=!1){if(this.models[x]&&this.models[x][h]&&(this.models[x][h].numReferences--,this.models[x][h].numReferences===0||D)){const R=this.modelUris[x][h];T||delete this.modelUris[x][h],delete this.modelByURL[R];const z=this.models[x][h].model;if(!z)return;delete this.models[x][h],z.destroy()}}destroy(){for(const h of Object.keys(this.models))for(const x of Object.keys(this.models[h])){const T=this.models[h][x].model;delete this.models[h][x],T&&T.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,x){this.models[x]||(this.models[x]={});for(const T in this.models[x])this.models[x][T].model&&this.models[x][T].model.upload(h.context)}}const BM=i.a6.colorTheme,Nce=new i.a9({data:new i.aa(BM.data)});function WL(C){if(!C.metadata||!C.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:x,top:T,width:D,height:R}=C.metadata.content_area,z=x*h,V=T*h;return[z,V,z+D*h,V+R*h]}function GL(C){if(C)return C.map(([h,x])=>[h*i.o.devicePixelRatio,x*i.o.devicePixelRatio])}class $M{constructor(h,x,T){this.id=h,this.scope=x,this.sourceCache=T,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 x=this.sourceCache.getVisibleCoordinates();if(x.length===0)return h;const T=this.sourceCache.getSource();if(!(T instanceof Zc))return h;const D=x.map(z=>this.sourceCache.getTile(z)),R=T.getImages(D,Array.from(this.pendingRequests));for(const[z,V]of R)h.set(i.I.from({name:z,iconsetId:this.id}),V),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const ex=(C,h)=>tt(C,h&&h.filter(x=>x.identifier!=="source.canvas")),KL=i.aH(ya,["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"]),ZL=i.aH(ya,["setCenter","setZoom","setBearing","setPitch"]),pS=new Set(["background","sky","slot","custom"]),tx={version:8,layers:[],sources:{}},rb={duration:300,delay:0};class sm extends i.E{constructor(h,x={}){super(),this.map=h,this.scope=x.scope||"",this.globalId=null,this.fragments=[],this.importDepth=x.importDepth||0,this.importsCache=x.importsCache||new Map,this.resolvedImports=x.resolvedImports||new Set,this.transition=Object.assign({},rb),this._buildingIndex=new G_(this),this.crossTileSymbolIndex=new zm,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=x.styleChanges||new je,this._hasDataDrivenEmissive=!1,this.dispatcher=x.dispatcher?x.dispatcher:new i.D(i.dh(),this),x.imageManager?this.imageManager=x.imageManager:(this.imageManager=new He(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=x.glyphManager?x.glyphManager:new i.di(h._requestManager,x.localFontFamily?i.dj.all:x.localIdeographFontFamily?i.dj.ideographs:i.dj.none,x.localFontFamily||x.localIdeographFontFamily),x.modelManager?this.modelManager=x.modelManager:(this.modelManager=new kce(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=x.configOptions?x.configOptions:new Map,this._configDependentLayers=x.configDependentLayers?x.configDependentLayers:new Set,this._indoorDependentLayers=x.indoorDependentLayers?x.indoorDependentLayers:new Set,this._config=x.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:x.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=x.initialConfig,this.dispatcher.broadcast("setReferrer",i.dk());const T=this;this._rtlTextPluginCallback=sm.registerForPluginStateChange(D=>{T.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(R,z)=>{if(i.dl(R),z&&z.every(V=>V))for(const V in T._sourceCaches){const X=T._sourceCaches[V],re=X.getSource().type;re!=="vector"&&re!=="geojson"||X.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const R=this.getOwnSource(D.sourceId);if(R&&R.vectorLayerIds)for(const z in this._layers){const V=this._layers[z];V.source===R.id&&this._validateLayer(V)}})}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 x=i.dm(h);if(!x.startsWith("http"))try{return new URL(x,location.href).toString()}catch{return x}return x}return`json://${i.dn(JSON.stringify(h))}`}_diffStyle(h,x,T){this.globalId=this._getGlobalId(h);const D=(R,z)=>{try{z(null,this.setState(R,T))}catch(V){z(V,!1)}};if(typeof h=="string"){const R=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(R,i.R.Style);i.m(z,(V,X)=>{V?this.fire(new i.y(V)):X&&D(X,x)})}else typeof h=="object"&&D(h,x)}loadURL(h,x={}){this.fire(new i.z("dataloading",{dataType:"style"}));const T=typeof x.validate=="boolean"?x.validate:!i.h(h);this.globalId=this._getGlobalId(h),h=this.map._requestManager.normalizeStyleURL(h,x.accessToken),this.resolvedImports.add(h);const D=this.importsCache.get(h);if(D)return this._load(D,T);const R=this.map._requestManager.transformRequest(h,i.R.Style);this._request=i.m(R,(z,V)=>{if(this._request=null,z)this.fire(new i.y(z));else if(V)return this.importsCache.set(h,V),this._load(V,T)})}loadJSON(h,x={}){this.fire(new i.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(h),this._request=i.o.frame(()=>{this._request=null,this._load(h,x.validate!==!1)})}loadEmpty(){this.fire(new i.z("dataloading",{dataType:"style"})),this._load(tx,!1)}_loadImports(h,x,T){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const D=[];for(const R of h){const z=this._createFragmentStyle(R),V=new Promise(ae=>{z.once("style.import.load",ae),z.once("error",ae)}).then(()=>this.mergeAll());if(D.push(V),this.resolvedImports.has(R.url)){z.loadEmpty();continue}const X=R.data||this.importsCache.get(R.url);X?(z.loadJSON(X,{validate:x}),this._isInternalStyle(X)&&(z.globalId=null)):R.url?z.loadURL(R.url,{validate:x}):z.loadEmpty();const re={style:z,id:R.id,config:R.config};if(T){const ae=this.fragments.findIndex(({id:me})=>me===T);this.fragments=this.fragments.slice(0,ae).concat(re).concat(this.fragments.slice(ae))}else this.fragments.push(re)}return Promise.allSettled(D)}getImportGlobalIds(h=this,x=new Set){for(const T of h.fragments)T.style.globalId&&x.add(T.style.globalId),this.getImportGlobalIds(T.style,x);return[...x.values()]}_createFragmentStyle(h){const x=this.scope?i.B(h.id,this.scope):h.id;let T;const D=this._initialConfig&&this._initialConfig[x];(h.config||D)&&(T=Object.assign({},h.config,D));const R=new sm(this.map,{scope:x,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:T,configOptions:this.options,colorThemeOverride:h["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return R.setEventedParent(this.map,{style:R}),R}_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,x){if(this._isInternalStyle(h)){const R=Object.assign({},tx,{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(R,x)}if(this.updateConfig(this._config,h.schema),x&&ex(this,Gr(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const T=()=>{for(const X in h.sources)this.addSource(X,h.sources[X],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const X in h.iconsets)this.addIconset(X,h.iconsets[X]);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 R=my(this.stylesheet.layers);if(this._order=R.map(X=>X.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 X=this.stylesheet.lights[0];this.light=new Ot(X.properties,X.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ot(this.stylesheet.light)),this._layers={};for(const X of R){const re=i.du(X,this.scope,this._styleColorTheme.lut,this.options);re.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(re.fqid),re.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(re.fqid),this._hasAppearances=this._hasAppearances||re.getAppearances().length!==0,re.setEventedParent(this,{layer:{id:re.id}}),this._layers[re.id]=re;const ae=this.getOwnLayerSourceCache(re),me=!!this.directionalLight&&this.directionalLight.shadowsEnabled();ae&&re.canCastShadows()&&me&&(ae.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 V=this.isRootStyle();h.imports?this._loadImports(h.imports,x).then(()=>{this._reloadImports(),this.fire(new i.z(V?"style.load":"style.import.load"))}).catch(X=>{this.fire(new i.y(new Error("Failed to load imports",X))),this.fire(new i.z(V?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(V?"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 R=this._evaluateColorThemeData(D);this._loadColorTheme(R).then(()=>{T()}).catch(z=>{i.w(`Couldn't load color theme from the stylesheet: ${z}`),T()})}else this._styleColorTheme.lut=null,T()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(h=>h.style.hasAppearances())}mergeAll(){let h,x,T,D,R,z,V,X,re,ae;const me={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(he=>{if(he.stylesheet){if(he.light!=null&&(h=he.light),he.stylesheet.lights)for(const pe of he.stylesheet.lights)pe.type==="ambient"&&he.ambientLight!=null&&(x=he.ambientLight),pe.type==="directional"&&he.directionalLight!=null&&(T=he.directionalLight);D=this._prioritizeTerrain(D,he.terrain,he.stylesheet.terrain),he.stylesheet.fog&&he.fog!=null&&(R=he.fog),he.stylesheet.snow&&he.snow!=null&&(z=he.snow),he.stylesheet.rain&&he.rain!=null&&(V=he.rain),he.stylesheet.camera!=null&&(ae=he.stylesheet.camera),he.stylesheet.projection!=null&&(X=he.stylesheet.projection),he.stylesheet.transition!=null&&(re=he.stylesheet.transition),me[he.scope]=he._styleColorTheme}}),this.light=h,this.ambientLight=x,this.directionalLight=T,this.fog=R,this.snow=z,this.rain=V,this._styleColorThemeForScope=me,D===null?delete this.terrain:this.terrain=D,this.camera=ae||{"camera-projection":"perspective"},this.projection=X||{name:"mercator"},this.transition=Object.assign({},rb,re),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(h){const x=T=>{for(const D of T.fragments)x(D.style);h(T)};x(this)}_prioritizeTerrain(h,x,T){const D=h&&h.drapeRenderMode===0;return T===null?x&&x.drapeRenderMode===0?x:D?h:null:x!=null&&(!h||D||x&&x.drapeRenderMode===1)?x:h}mergeTerrain(){let h;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(x=>{h=this._prioritizeTerrain(h,x.terrain,x.stylesheet.terrain)}),h===null?delete this.terrain:this.terrain=h}mergeProjection(){let h;this.forEachFragmentStyle(x=>{x.stylesheet.projection!=null&&(h=x.stylesheet.projection)}),this.projection=h||{name:"mercator"}}mergeSources(){const h={},x={},T={};this.forEachFragmentStyle(D=>{for(const R in D._sourceCaches){const z=i.B(R,D.scope);h[z]=D._sourceCaches[R]}for(const R in D._otherSourceCaches){const z=i.B(R,D.scope);x[z]=D._otherSourceCaches[R]}for(const R in D._symbolSourceCaches){const z=i.B(R,D.scope);T[z]=D._symbolSourceCaches[R]}}),this._mergedSourceCaches=h,this._mergedOtherSourceCaches=x,this._mergedSymbolSourceCaches=T}mergeIndoor(){this.forEachFragmentStyle(h=>{if(h.stylesheet&&h.stylesheet.indoor)for(const x of Object.values(h.stylesheet.indoor)){const T=x,D=i.B(T.sourceId,h.scope);this._mergedIndoor[D]=new Set(T.sourceLayers||[])}})}mergeLayers(){const h={},x=[],T={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(z=>{for(const V of z._order){const X=z._layers[V];if(X.type==="slot"){const re=i.dq(V);if(h[re])continue;h[re]=[]}X.slot&&h[X.slot]?h[X.slot].push(X):x.push(X)}}),this._mergedOrder=[];let D=-1;const R=(z=[])=>{for(const V of z)if(V.type==="slot"){const X=i.dq(V.id);h[X]&&R(h[X]),this._mergedSlots.push(X)}else{const X=i.B(V.id,V.scope);this._mergedOrder.push(X),T[X]=V,V.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),V.type==="circle"&&(this._hasCircleLayers=!0),V.type==="symbol"&&(this._hasSymbolLayers=!0),V.type==="clip"&&(this._clipLayerPresent=!0)}};if(R(x),this._has3DLayers){const z={};for(let V=0;Vz[V]-z[X])}this._mergedLayers=T,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(x,T,D,R){const z=Object.assign({},T);for(const X of Object.keys(BM))z[X]===void 0&&(z[X]=BM[X].default);const V=new i.a8(Nce,x,new Map(D));return V.setTransitionOrValue(z,D),V.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 x=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((T,D)=>{const R="data:image/png;base64,";if(!h||h.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void T();let z=h;z.startsWith(R)||(z=R+z);const V=i.I.from("mapbox-reserved-lut"),X=new Image;X.src=z,X.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},X.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==x)return void T();this._styleColorTheme.lutLoading=!1;const{width:re,height:ae,data:me}=i.o.getImageData(X);if(ae>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(re!==ae*ae)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(V)&&this.removeImage(V),this.addImage(V,{data:new i.q({width:re,height:ae},me),pixelRatio:1,sdf:!1,usvg:!1,version:0});const he=this.imageManager.getImage(V,this.scope);he?(this._styleColorTheme.lut={image:he.data,data:h},T()):D(new Error("Missing LUT image."))}})}getLut(h){const x=this._styleColorThemeForScope[h];return x?x.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(x,T,D){let R,z,V;const X=i.o.devicePixelRatio>1?"@2x":"";let re=i.m(T.transformRequest(T.normalizeSpriteURL(x,X,".json"),i.R.SpriteJSON),(he,pe)=>{re=null,V||(V=he,R=pe,me())}),ae=i.n(T.transformRequest(T.normalizeSpriteURL(x,X,".png"),i.R.SpriteImage),(he,pe)=>{ae=null,V||(V=he,z=pe,me())});function me(){if(V)D(V);else if(R&&z){const he=i.o.getImageData(z),pe={};for(const Me in R){const{width:Ce,height:$e,x:Be,y:Xe,sdf:ot,pixelRatio:et,stretchX:Ct,stretchY:vt,content:jt}=R[Me],xt=new i.q({width:Ce,height:$e});i.q.copy(he,xt,{x:Be,y:Xe},{x:0,y:0},{width:Ce,height:$e},null),pe[Me]={data:xt,pixelRatio:et!==void 0?et:1,sdf:ot!==void 0&&ot,stretchX:Ct,stretchY:vt,content:jt,usvg:!1,version:0}}D(null,pe)}}return{cancel(){re&&(re.cancel(),re=null),ae&&(ae.cancel(),ae=null)}}}(h,this.map._requestManager,(x,T)=>{if(this._spriteRequest=null,x)this.fire(new i.y(x));else if(T){const D=new Map;for(const R in T)D.set(i.I.from(R),T[R]);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,x){if(x.type==="sprite")return void this._loadSprite(x.url);const T=this.getOwnSourceCache(x.source);if(!T)return void this.fire(new i.y(new Error(`Source "${x.source}" as specified by iconset "${h}" does not exist and cannot be used as an iconset source`)));const D=T.getSource();if(D.type!=="raster-array")return void this.fire(new i.y(new Error(`Source "${x.source}" as specified by iconset "${h}" is not a "raster-array" source and cannot be used as an iconset source`)));D.partial=!1;const R=new $M(h,this.scope,T);this.imageManager.addImageProvider(R,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 x=this.map._spriteFormat==="auto";var T,D;this._spriteRequest=(D=(R,z)=>{if(this._spriteRequest=null,R)x?this._loadSprite(h):this.fire(new i.y(R));else if(z){const V=new Map;for(const X in z)V.set(i.I.from(X),z[X]);this.addImages(V)}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((T=this.map._requestManager).transformRequest(T.normalizeIconsetURL(h),i.R.Iconset),(R,z)=>{if(R)return void D(R);const V={},X=i.dg(new i.bt(z));for(const re of X.icons){const ae={version:1,pixelRatio:i.o.devicePixelRatio,content:WL(re),stretchX:re.metadata?GL(re.metadata.stretch_x_areas):void 0,stretchY:re.metadata?GL(re.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:re};V[re.name]=ae}D(null,V)}))}_validateLayer(h){const x=this.getOwnSource(h.source);if(!x)return;const T=h.sourceLayer;T&&(x.type==="geojson"||x.vectorLayerIds&&x.vectorLayerIds.indexOf(T)===-1)&&this.fire(new i.y(new Error(`Source layer "${T}" does not exist on source "${x.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,x)=>{const T=this.fragments[x];return T&&T.style&&(h.data=T.style.serialize()),h})}_serializeSources(){const h={};for(const x in this._sourceCaches){const T=this._sourceCaches[x].getSource();h[T.id]||(h[T.id]=T.serialize())}return h}_serializeLayers(h){const x=[];for(const T of h){const D=this._layers[T];D&&D.type!=="custom"&&x.push(D.serialize())}return x}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 x=this._mergedLayers[h];if(x._transitionablePaint&&x._transitionablePaint._values){const T=x._transitionablePaint._values["line-emissive-strength"];if(T&&T.value&&T.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 x=this.getOwnLayer(h);if(x)return x;this.fire(new i.y(new Error(`The layer '${h}' does not exist in the map's style.`)))}_checkSource(h){const x=this.getOwnSource(h);if(x)return x;this.fire(new i.y(new Error(`The source '${h}' does not exist in the map's style.`)))}precompilePrograms(h,x){const T=this.map.painter;if(T)for(let D=h.minzoom||0;D<(h.maxzoom||25.5);D++){const R=h.getProgramIds();if(R)for(const z of R){const V=h.getDefaultProgramParams(z,x.zoom,this._styleColorTheme.lut);V&&(T.style=this,this.fog&&(T._fogVisible=!0,V.overrideFog=!0,T.getOrCreateProgram(z,V)),T._fogVisible=!1,V.overrideFog=!1,T.getOrCreateProgram(z,V),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(V.overrideRtt=!0,T.getOrCreateProgram(z,V)))}}}update(h){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(h),this.directionalLight&&this.directionalLight.recalculate(h);const x=this.calculateLightsBrightness();h.brightness=x||0,x!==this._brightness&&(this._brightness=x,this.dispatcher.broadcast("setBrightness",x)),h.worldview!==this._worldview&&(this._worldview=h.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const T=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const V=this._changes.getLayerUpdatesByScope();for(const X in V){const{updatedIds:re,removedIds:ae}=V[X];(re||ae)&&(this._updateWorkerLayers(X,re,ae),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 R={};for(const V in this._mergedSourceCaches){const X=this._mergedSourceCaches[V];R[V]=X.used,X.used=!1,X.tileCoverLift=0}for(const V of this._mergedOrder){const X=this._mergedLayers[V];if(X.visibility!=="none"&&X.recalculate(h,this._availableImages),!X.isHidden(h.zoom)){const re=this.getLayerSourceCache(X);re&&(re.used=!0,re.tileCoverLift=Math.max(re.tileCoverLift,X.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(X,h)}):this.precompilePrograms(X,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const V of z)V.sourceCache.used=!0;for(const V in R){const X=this._mergedSourceCaches[V];R[V]!==X.used&&X.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:X.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),T&&this.fire(new i.z("data",{dataType:"style"}))}updateImageProviders(){const h=this.imageManager.getPendingImageProviders();for(const x of h){const T=x.resolvePendingRequests(),D=this.getFragmentStyle(x.scope);D&&D.addImages(T)}}_updateTilesForChangedImages(){const h={};for(const x in this._mergedSourceCaches){const T=this._mergedSourceCaches[x].getSource().scope;h[T]=h[T]||this._changes.getUpdatedImages(T),h[T].length!==0&&this._mergedSourceCaches[x].reloadTilesForDependencies(["icons","patterns"],h[T])}for(const x in h)this._changes.resetUpdatedImages(x)}_updateWorkerLayers(h,x,T){const D=this.getFragmentStyle(h);D&&this.dispatcher.broadcast("updateLayers",{layers:x?D._serializeLayers(x):[],scope:h,removedIds:T||[],options:D.options})}setState(h,x){if(this._checkLoaded(),ex(this,Gr(h)))return!1;(h=i.dp(h)).layers=my(h.layers);const T=function(z,V){if(!z)return[{command:ya.setStyle,args:[V]}];let X=[];try{if(!i.by(z.version,V.version))return[{command:ya.setStyle,args:[V]}];if(i.by(z.center,V.center)||X.push({command:ya.setCenter,args:[V.center]}),i.by(z.zoom,V.zoom)||X.push({command:ya.setZoom,args:[V.zoom]}),i.by(z.bearing,V.bearing)||X.push({command:ya.setBearing,args:[V.bearing]}),i.by(z.pitch,V.pitch)||X.push({command:ya.setPitch,args:[V.pitch]}),i.by(z.sprite,V.sprite)||X.push({command:ya.setSprite,args:[V.sprite]}),i.by(z.glyphs,V.glyphs)||X.push({command:ya.setGlyphs,args:[V.glyphs]}),i.by(z.imports,V.imports)||function(pe=[],Me=[],Ce){Me=Me||[];const $e=(pe=pe||[]).map(py),Be=Me.map(py),Xe=pe.reduce(fy,{}),ot=Me.reduce(fy,{}),et=$e.slice();let Ct,vt,jt,xt;for(Ct=0,vt=0;Ct<$e.length;Ct++)jt=$e[Ct],ot.hasOwnProperty(jt)?vt++:(Ce.push({command:ya.removeImport,args:[jt]}),et.splice(et.indexOf(jt,vt),1));for(Ct=0,vt=0;Ct{pe.source&&re[pe.source]?X.push({command:ya.removeLayer,args:[pe.id]}):me.push(pe)});let he=z.terrain;he&&re[he.source]&&(X.push({command:ya.setTerrain,args:[void 0]}),he=void 0),X=X.concat(ae),i.by(he,V.terrain)||X.push({command:ya.setTerrain,args:[V.terrain]}),function(pe,Me,Ce){Me=Me||[];const $e=(pe=pe||[]).map(py),Be=Me.map(py),Xe=pe.reduce(fy,{}),ot=Me.reduce(fy,{}),et=$e.slice(),Ct=Object.create(null);let vt,jt,xt,pt,Et,Ht,Ut;for(vt=0,jt=0;vt<$e.length;vt++)xt=$e[vt],ot.hasOwnProperty(xt)?jt++:(Ce.push({command:ya.removeLayer,args:[xt]}),et.splice(et.indexOf(xt,jt),1));for(vt=0,jt=0;vt!(z.command in ZL));if(T.length===0)return!1;const D=T.filter(z=>!(z.command in KL));if(D.length>0)throw new Error(`Unimplemented: ${D.map(z=>z.command).join(", ")}.`);const R=[];return T.forEach(z=>{R.push(this[z.command](...z.args))}),x&&Promise.all(R).then(x).catch(x),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[x,T]of h.entries()){if(this.getImage(x))return this.fire(new i.y(new Error(`An image with the name "${x.name}" already exists.`)));this.imageManager.addImage(x,this.scope,T),this._changes.updateImage(x,this.scope)}return this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this}addImage(h,x){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,x),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this)}updateImage(h,x,T=!1){this.imageManager.updateImage(h,this.scope,x),T&&(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,x,T={}){return this._checkLoaded(),this._validate(Se,`models.${h}`,x,null,T)||(this.modelManager.addModel(h,x,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,x,T={}){if(this._checkLoaded(),this.getOwnSource(h)!==void 0)throw new Error(`There is already a source with ID "${h}".`);if(!x.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(x).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(x.type)>=0&&this._validate(Dn,`sources.${h}`,x,null,T))return;this.map&&this.map._collectResourceTiming&&(x.collectResourceTiming=!0);const D=xl(h,x,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const R=z=>{const V=(z?"symbol:":"other:")+D.id,X=i.B(V,this.scope),re=this._sourceCaches[V]=new ul(X,D,z);(z?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=re,re.onAdd(this.map)};R(!1),x.type!=="vector"&&x.type!=="geojson"||R(!0),D.onAdd&&D.onAdd(this.map),T.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(h){this._checkLoaded();const x=this.getOwnSource(h);if(!x)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(([R,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 T=this.getOwnSourceCaches(h);for(const D of T){const R=i.dq(D.id);delete this._sourceCaches[R],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(),x.setEventedParent(null),x.onRemove&&x.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(h,x){this._checkLoaded(),this.getOwnSource(h).setData(x),this._changes.setDirty()}getOwnSource(h){const x=this.getOwnSourceCache(h);return x&&x.getSource()}getOwnSources(){const h=[];for(const x in this._otherSourceCaches){const T=this.getOwnSourceCache(x);T&&h.push(T.getSource())}return h}areTilesLoaded(){const h=this._mergedSourceCaches;for(const x in h){const T=h[x]._tiles;for(const D in T){const R=T[D];if(R.state!=="loaded"&&R.state!=="errored")return!1}}return!0}setLights(h){if(this._checkLoaded(),!h)return delete this.ambientLight,void delete this.directionalLight;const x=this._getTransitionParameters();for(const R of h){if(this._validate(An,"lights",R))return;switch(R.type){case"ambient":if(this.ambientLight){const z=this.ambientLight;z.set(R),z.updateTransitions(x)}else this.ambientLight=new xa(R,zo||(zo=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(R),z.updateTransitions(x)}else this.directionalLight=new xa(R,Ua||(Ua=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 T=Object.assign(x,{worldview:this.map.getWorldview()}),D=new i.ac(this.z||0,T);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,x=this.ambientLight;if(!h||!x)return;const T=he=>.2126*(he[0]<=.03928?he[0]/12.92:Math.pow((he[0]+.055)/1.055,2.4))+.7152*(he[1]<=.03928?he[1]/12.92:Math.pow((he[1]+.055)/1.055,2.4))+.0722*(he[2]<=.03928?he[2]/12.92:Math.pow((he[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),R=h.properties.get("intensity"),z=h.properties.get("direction"),V=1-i.d4(z.x,z.y,z.z)[2]/90,X=T(D)*R*V,re=x.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),ae=x.properties.get("intensity"),me=T(re)*ae;return Number(((X+me)/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 x=i.ds(h),T=this.fragments.find(({id:R})=>R===x);if(!T)return;const D=i.dq(h);return T.style.getFragmentStyle(D)}{const x=this.fragments.find(({id:T})=>T===h);return x?x.style:void 0}}setFeaturesetSelectors(h){if(!h)return;const x={},T=(D,R="")=>`${D}::${R}`;this._featuresetSelectors={};for(const D in h){const R=this._featuresetSelectors[D]=[];for(const z of h[D].selectors){if(z.featureNamespace){const X=this.getOwnLayer(z.layer);if(!X){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const re=T(X.source,X.sourceLayer);if(re in x&&x[re]!==z.featureNamespace){i.w(`"featureNamespace ${z.featureNamespace} of featureset ${D}'s selector is not associated to the same source, skip this selector`);continue}x[re]=z.featureNamespace}let V;if(z.properties)for(const X in z.properties){const re=i.U(z.properties[X]);re.result==="success"&&(V=V||{},V[X]=re.value)}R.push({layerId:z.layer,namespace:z.featureNamespace,properties:V,uniqueFeatureID:z._uniqueFeatureID})}}}getFeaturesetDescriptors(h){const x=this.getFragmentStyle(h);if(!x||!x.stylesheet.featuresets)return[];const T=[];for(const D in x.stylesheet.featuresets)T.push({featuresetId:D,importId:x.scope?x.scope:void 0});return T}getFeaturesetLayers(h,x){const T=this.getFragmentStyle(x),D=T.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 R=[];for(const z of D[h].selectors){const V=T.getOwnLayer(z.layer);V&&R.push(V)}return R}getConfigProperty(h,x){const T=this.getFragmentStyle(h);if(!T)return null;const D=i.B(x,T.scope),R=T.options.get(D),z=R?R.value||R.default:null;return z?z.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(h,x){const T=i.B(h,x);return this._mergedIndoor[T]}setIndoorData(h,x){this.map.indoor.setIndoorData(x)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(h,x,T){const D=this.getFragmentStyle(h);if(!D)return;const R=D.stylesheet.schema;if(!R||!R[x])return;const z=i.U(T);if(z.result!=="success")return void ex(this,z.value);const V=z.value.expression,X=i.B(x,D.scope),re=D.options.get(X);if(!re)return;let ae;const{minValue:me,maxValue:he,stepValue:pe,type:Me,values:Ce}=R[x],$e=i.U(R[x].default);$e.result==="success"&&(ae=$e.value.expression),ae?(this.options.set(X,Object.assign({},re,{value:V,default:ae,minValue:me,maxValue:he,stepValue:pe,type:Me,values:Ce})),this.updateConfigDependencies(x)):this.fire(new i.y(new Error(`No schema defined for the config option "${x}" in the "${h}" fragment.`)))}getConfig(h){const x=this.getFragmentStyle(h);if(!x)return null;const T=x.stylesheet.schema;if(!T)return null;const D={};for(const R in T){const z=i.B(R,x.scope),V=x.options.get(z),X=V?V.value||V.default:null;D[R]=X?X.serialize():null}return D}setConfig(h,x){const T=this.getFragmentStyle(h);T&&(T.updateConfig(x,T.stylesheet.schema),this.updateConfigDependencies())}getSchema(h){const x=this.getFragmentStyle(h);return x?x.stylesheet.schema:null}setSchema(h,x){const T=this.getFragmentStyle(h);T&&(T.stylesheet.schema=x,T.updateConfig(T._config,x),this.updateConfigDependencies())}updateConfig(h,x){if(this._config=h,h||x)if(x)for(const T in x){let D,R;const z=i.U(x[T].default);if(z.result==="success"&&(D=z.value.expression),h&&h[T]!==void 0){const he=i.U(h[T]);he.result==="success"&&(R=he.value.expression)}const{minValue:V,maxValue:X,stepValue:re,type:ae,values:me}=x[T];if(D){const he=i.B(T,this.scope);this.options.set(he,{default:D,value:R,minValue:V,maxValue:X,stepValue:re,type:ae,values:me})}else this.fire(new i.y(new Error(`No schema defined for config option "${T}".`)))}else this.fire(new i.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(h,x=()=>!0){for(const T of h){const D=this.getLayer(T);D&&x(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(h){this._updateLayers(this._configDependentLayers,x=>!h||x.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(x=>{const T=x._styleColorTheme.colorThemeOverride?x._styleColorTheme.colorThemeOverride:x._styleColorTheme.colorTheme;if(T){const D=x._evaluateColorThemeData(T);(!x._styleColorTheme.lut&&D!==""||x._styleColorTheme.lut&&D!==x._styleColorTheme.lut.data)&&x.setColorTheme(T)}}),this._changes.setDirty()}addLayer(h,x,T={}){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 R;if(h.type==="custom"){if(ex(this,i.dt(h)))return;R=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(Dl,`layers.${D}`,h,{arrayIndex:-1},T))return;R=i.du(h,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(R),R.setEventedParent(this,{layer:{id:D}})}const z=i.B(R.source,R.scope);R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z);let V=this._order.length;if(x){const me=this._order.indexOf(x);if(me===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));R.slot===this._layers[x].slot?V=me:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(V,0,D),this._layerOrderChanged=!0,this._layers[D]=R;const X=this.getOwnLayerSourceCache(R),re=!!this.directionalLight&&this.directionalLight.shadowsEnabled();X&&R.canCastShadows()&&re&&(X.castsShadows=!0);const ae=this._changes.getRemovedLayer(R);if(ae&&R.source&&X&&R.type!=="custom"){this._changes.discardLayerRemoval(R);const me=i.B(R.source,R.scope);ae.type!==R.type?this._changes.updateSourceCache(me,"clear"):(this._changes.updateSourceCache(me,"reload"),X.pause())}this._updateLayer(R),R.onAdd&&R.onAdd(this.map),R.scope=this.scope,this.mergeLayers()}moveLayer(h,x){this._checkLoaded();const T=this._checkLayer(h);if(!T||h===x)return;const D=this._order.indexOf(h);this._order.splice(D,1);let R=this._order.length;if(x){const z=this._order.indexOf(x);if(z===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));T.slot===this._layers[x].slot?R=z:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(R,0,h),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(h){this._checkLoaded();const x=this._checkLayer(h);if(!x)return;x.setEventedParent(null);const T=this._order.indexOf(h);this._order.splice(T,1),delete this._layers[h],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(x.fqid),this._indoorDependentLayers.delete(x.fqid),this._changes.removeLayer(x);const D=this.getOwnLayerSourceCache(x);if(D&&D.castsShadows){let R=!1;for(const z in this._layers)if(this._layers[z].source===x.source&&this._layers[z].canCastShadows()){R=!0;break}D.castsShadows=R}x.onRemove&&x.onRemove(this.map),this.mergeLayers()}getOwnLayer(h){return this._layers[h]}hasLayer(h){return h in this._mergedLayers}hasLayerType(h){for(const x in this._layers)if(this._layers[x].type===h)return!0;return!1}setLayerZoomRange(h,x,T){this._checkLoaded();const D=this._checkLayer(h);D&&(D.minzoom===x&&D.maxzoom===T||(x!=null&&(D.minzoom=x),T!=null&&(D.maxzoom=T),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(h,x){this._checkLoaded();const T=this._checkLayer(h);T&&T.slot!==x&&(T.slot=x,this._updateLayer(T))}setFilter(h,x,T={}){this._checkLoaded();const D=this._checkLayer(h);if(D&&!i.by(D.filter,x))return x==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(Lo,`layers.${D.id}.filter`,x,{layerType:D.type},T)||(D.filter=i.dp(x),this._updateLayer(D)))}getFilter(h){const x=this._checkLayer(h);if(x)return i.dp(x.filter)}setLayoutProperty(h,x,T,D={}){this._checkLoaded();const R=this._checkLayer(h);if(R&&!i.by(R.getLayoutProperty(x),T)){if(T!=null&&(!D||D.validate!==!1)&&ex(R,it.call(Gr,{key:`layers.${h}.layout.${x}`,layerType:R.type,objectKey:x,value:T,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;R.setLayoutProperty(x,T),R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(R.fqid),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(R.fqid),this._updateLayer(R)}}setLayerProperty(h,x,T,D={}){this._checkLoaded();const R=this._checkLayer(h);R&&(x==="appearances"?(R.setAppearances(T),this._changes.setDirty()):R.isPaintProperty(x)?this.setPaintProperty(h,x,T,D):this.setLayoutProperty(h,x,T,D))}getLayoutProperty(h,x){const T=this._checkLayer(h);if(T)return T.getLayoutProperty(x)}setPaintProperty(h,x,T,D={}){this._checkLoaded();const R=this._checkLayer(h);if(!R||i.by(R.getPaintProperty(x),T)||T!=null&&(!D||D.validate!==!1)&&ex(R,Kc.call(Gr,{key:`layers.${h}.paint.${x}`,layerType:R.type,objectKey:x,value:T,styleSpec:i.a6})))return;const z=R.setPaintProperty(x,T);R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(R.fqid),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(R.fqid),z&&this._updateLayer(R),this._changes.updatePaintProperties(R)}getPaintProperty(h,x){const T=this._checkLayer(h);if(T)return T.getPaintProperty(x)}setFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:X,importId:re}=h.target,ae=this.getFragmentStyle(re),me=ae.getFeaturesetLayers(X);for(const{source:he,sourceLayer:pe}of me)ae.setFeatureState({id:h.id,source:he,sourceLayer:pe},x)}else if("layerId"in h.target){const{layerId:X}=h.target,re=this.getLayer(X);this.setFeatureState({id:h.id,source:re.source,sourceLayer:re.sourceLayer},x)}return}const T=h.source,D=h.sourceLayer,R=this._checkSource(T);if(!R)return;const z=R.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 V=this.getOwnSourceCaches(T);for(const X of V)X.setFeatureState(D,h.id,x)}removeFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:X,importId:re}=h.target,ae=this.getFragmentStyle(re),me=ae.getFeaturesetLayers(X);for(const{source:he,sourceLayer:pe}of me)ae.removeFeatureState({id:h.id,source:he,sourceLayer:pe},x)}else if("layerId"in h.target){const{layerId:X}=h.target,re=this.getLayer(X);this.removeFeatureState({id:h.id,source:re.source,sourceLayer:re.sourceLayer},x)}return}const T=h.source,D=this._checkSource(T);if(!D)return;const R=D.type,z=R==="vector"?h.sourceLayer:void 0;if(R==="vector"&&!z)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(x&&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 V=this.getOwnSourceCaches(T);for(const X of V)X.removeFeatureState(z,h.id,x)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let R;if("featuresetId"in h.target){const{featuresetId:z,importId:V}=h.target,X=this.getFragmentStyle(V),re=X.getFeaturesetLayers(z);for(const{source:ae,sourceLayer:me}of re){const he=X.getFeatureState({id:h.id,source:ae,sourceLayer:me});if(he&&!R)R=he;else if(!i.by(R,he))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,V=this.getLayer(z);R=this.getFeatureState({id:h.id,source:V.source,sourceLayer:V.sourceLayer})}return R}const x=h.source,T=h.sourceLayer,D=this._checkSource(x);if(D){if(D.type!=="vector"||T)return h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(x)[0].getFeatureState(T,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(),x=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:x,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)},T=>T!==void 0)}_updateFilteredLayers(h){for(const x of Object.values(this._mergedLayers))h(x)&&this._updateLayer(x)}_updateLayer(h){this._changes.updateLayer(h);const x=this.getLayerSourceCache(h),T=i.B(h.source,h.scope),D=this._changes.getUpdatedSourceCaches();h.source&&!D[T]&&x&&x.getSource().type!=="raster"&&(this._changes.updateSourceCache(T,"reload"),x.pause()),h.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){const x=V=>this._mergedLayers[V].is3D(!!this.terrain),T=this.order,D={},R=[];for(let V=T.length-1;V>=0;V--){const X=T[V];if(x(X)){D[X]=V;for(const re of h){const ae=re[X];if(ae)for(const me of ae)R.push(me)}}}R.sort((V,X)=>X.intersectionZ-V.intersectionZ);const z=[];for(let V=T.length-1;V>=0;V--){const X=T[V];if(x(X))for(let re=R.length-1;re>=0;re--){const ae=R[re].feature;if(ae.layer&&D[ae.layer.id]{if(pS.has(ae.type))return;const me=this.getOwnLayerSourceCache(ae),he=R[me.id]=R[me.id]||{sourceCache:me,layers:{},has3DLayers:!1};ae.is3D(!!this.terrain)&&(he.has3DLayers=!0),he.layers[ae.fqid]=he.layers[ae.fqid]||{styleLayer:ae,targets:[]},he.layers[ae.fqid].targets.push({filter:D})};if(x&&x.layers){if(!Array.isArray(x.layers))return this.fire(new i.y(new Error("parameters.layers must be an Array."))),[];for(const ae of x.layers){const me=this._layers[ae];if(!me)return this.fire(new i.y(new Error(`The layer '${ae}' does not exist in the map's style and cannot be queried for features.`))),[];z(me)}}else for(const ae in this._layers)z(this._layers[ae]);const V=this._queryRenderedFeatures(h,R,T),X=this._flattenAndSortRenderedFeatures(V),re=[];for(const ae of X)i.dw(ae.layer.id)===this.scope&&re.push(ae);return re}queryRenderedFeatureset(h,x,T){let D;x&&!Array.isArray(x)&&x.filter&&(this._validate(Lo,"queryRenderedFeatures.filter",x.filter,null,x),D=i.b6(x.filter));const R="mock",z=[];if(x&&x.target)z.push(Object.assign({},x,{targetId:R,filter:D}));else{const ae=this.getFeaturesetDescriptors();for(const me of ae)z.push({targetId:R,filter:D,target:me});for(const{style:me}of this.fragments){const he=me.getFeaturesetDescriptors();for(const pe of he)z.push({targetId:R,filter:D,target:pe})}}const V=this.queryRenderedTargets(h,z,T),X=[],re=new Set;for(const ae of V)for(const me of ae.variants[R])Kg(me,ae,re)||X.push(new i.dx(ae,me));return X}queryRenderedTargets(h,x,T){const D={},R=(V,X,re,ae)=>{const me=D[X.id]=D[X.id]||{sourceCache:X,layers:{},has3DLayers:!1};if(me.layers[V.fqid]=me.layers[V.fqid]||{styleLayer:V,targets:[]},V.is3D(!!this.terrain)&&(me.has3DLayers=!0),!ae)return re.uniqueFeatureID=!1,void me.layers[V.fqid].targets.push(re);me.layers[V.fqid].targets.push(Object.assign({},re,{namespace:ae.namespace,properties:ae.properties,uniqueFeatureID:ae.uniqueFeatureID}))};for(const V of x)if("featuresetId"in V.target){const{featuresetId:X,importId:re}=V.target,ae=this.getFragmentStyle(re);if(!ae||!ae._featuresetSelectors)continue;const me=ae._featuresetSelectors[X];if(!me){this.fire(new i.y(new Error(`The featureset '${X}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const he of me){const pe=ae.getOwnLayer(he.layerId);pe&&!pS.has(pe.type)&&R(pe,ae.getOwnLayerSourceCache(pe),V,he)}}else if("layerId"in V.target){const{layerId:X}=V.target,re=this.getLayer(X);if(!re||pS.has(re.type))continue;R(re,this.getLayerSourceCache(re),V)}const z=this._queryRenderedFeatures(h,D,T);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,x,T){const D=[],R=!!this.map._showQueryGeometry,z=Zi.createFromScreenPoints(h,T);for(const V in x){const X=Q0(z,x[V],this._availableImages,T,R);Object.keys(X).length&&D.push(X)}if(this.placement)for(const V in x){if(!x[V].sourceCache._onlySymbols)continue;const X=J0(z.screenGeometry,x[V],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(X).length&&D.push(X)}return D}querySourceFeatures(h,x){const T=x&&x.filter;T&&this._validate(Lo,"querySourceFeatures.filter",T,null,x);let D=[];const R=this.getOwnSourceCaches(h);for(const z of R)D=D.concat(ev(z,x));return D}addSourceType(h,x,T){return sm.getSourceType(h)?T(new Error(`A source type called "${h}" already exists.`)):(sm.setSourceType(h,x),x.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:h,url:x.workerSourceURL},T):T(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(h,x,T={}){this._checkLoaded();const D=this.light.getLight();let R=!1;for(const V in h)if(!i.by(h[V],D[V])){R=!0;break}if(!R)return;const z=this._getTransitionParameters();this.light.setLight(h,x,T),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,x=1){if(this._checkLoaded(),!h)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),x===0&&delete this.terrain,h===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let T=h;const D=!("source"in h)||h.source==null;if(x===1){if(this.disableElevatedTerrain)return;if("source"in T&&typeof T.source=="object"){const V="terrain-dem-src";this.addSource(V,T.source),T=i.dp(T),T=Object.assign(T,{source:V})}const R=Object.assign({},T),z={};if(this.terrain&&D){R.source=this.terrain.get().source;const V=this.terrain?this.getFragmentStyle(this.terrain.scope):null;V&&(z.style=V.serialize())}if(this._validate(la,"terrain",R,z))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&x!==this.terrain.drapeRenderMode){if(!T)return;this._createTerrain(T,x),this.fire(new i.z("data",{dataType:"style"}))}else{const R=this.terrain,z=R.get();for(const V of Object.keys(i.a6.terrain))!T.hasOwnProperty(V)&&i.a6.terrain[V].default&&(T[V]=i.a6.terrain[V].default);for(const V in h)if(!i.by(h[V],z[V])){R.set(h,this.options),this.stylesheet.terrain=h;const X=this._getTransitionParameters({duration:0});R.updateTransitions(X),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const x=this.fog=new wn(h,this.map.transform,this.scope,this.options);this.stylesheet.fog=x.get();const T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}_createSnow(h){const x=this.snow=new Vo(h,this.map.transform,this.scope,this.options);this.stylesheet.snow=x.get();const T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}_createRain(h){const x=this.rain=new Ki(h,this.map.transform,this.scope,this.options);this.stylesheet.rain=x.get();const T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}_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 x=this.fog;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.fog=x.get();const T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}}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 x=this.snow;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.snow=x.get();const T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}}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 x=this.rain;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.rain=x.get();const T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}}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()},x=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!x)return this._styleColorTheme.lut=null,void h();const T=this._evaluateColorThemeData(x);this._loadColorTheme(T).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,x){const T=this.getFragmentStyle(h);T&&(T._styleColorTheme.colorThemeOverride=x,T._reloadColorTheme())}_getTransitionParameters(h){return{now:i.o.now(),transition:Object.assign(this.transition,h)}}updateDrapeFirstLayers(){if(!this.terrain)return;const h=[],x=[];for(const T of this._mergedOrder)this.isLayerDraped(this._mergedLayers[T])?h.push(T):x.push(T);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...h),this._drapedFirstOrder.push(...x)}_createTerrain(h,x){const T=this.terrain=new qt(h,x,this.scope,this.options,this.map.getWorldview());x===1&&(this.stylesheet.terrain=h),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const D=this._getTransitionParameters({duration:0});T.updateTransitions(D)}_force3DLayerUpdate(){for(const h in this._layers){const x=this._layers[h];x.type==="fill-extrusion"&&this._updateLayer(x)}}_forceSymbolLayerUpdate(){for(const h in this._layers){const x=this._layers[h];x.type==="symbol"&&this._updateLayer(x)}}_validate(h,x,T,D,R={}){if(R&&R.validate===!1)return!1;const z=Object.assign({},this.serialize());return ex(this,h.call(Gr,Object.assign({key:x,style:z,value:T,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 x=this.getSourceCaches(h);for(const T of x)T.clearTiles()}clearSources(){for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles()}clearLayers(){for(const h in this._mergedLayers){const x=this._mergedLayers[h];x._clear&&x._clear()}}reloadSource(h){const x=this.getSourceCaches(h);for(const T of x)T.resume(),T.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 x;this.directionalLight&&(x=sb(this.directionalLight));const T=new Set,D=new Set;for(const R in this._mergedLayers){const z=this._mergedLayers[R];z.type==="building"&&T.add(z.source),z.hasElevation()&&!D.has(z.source)&&D.add(z.source)}for(const R in this._mergedSourceCaches){const z=this._mergedSourceCaches[R],V=D.has(z._source.id);T.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,x,V)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const x=this._sourceCaches[h];x.resume(),x.reload()}}_updatePlacement(h,x,T,D,R,z,V=!1){let X=!1,re=!1;const ae={},me={};for(const Ce of this._mergedOrder){const $e=this._mergedLayers[Ce];if($e.type!=="symbol")continue;const Be=i.B($e.source,$e.scope);let Xe=ae[Be];if(!Xe){const et=this.getLayerSourceCache($e);if(!et)continue;const Ct=et.getRenderableIds(!0).map(vt=>et.getTileByID(vt));me[Be]=Ct.slice(),Xe=ae[Be]=Ct.sort((vt,jt)=>jt.tileID.overscaledZ-vt.tileID.overscaledZ||(vt.tileID.isLessThan(jt.tileID)?-1:1))}const ot=this.crossTileSymbolIndex.addLayer($e,Xe,x.center.lng,x.projection);X=X||ot}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),V=V||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const he=!!(this.placement&&!x.equals(this.placement.transform)),pe=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),Me=(he||pe||X||this.placement&&this.placement.isStale())&&D===0;if((V||!this.pauseablePlacement||Me||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),x.zoom))&&(this.pauseablePlacement=new sc(x,this._mergedOrder,V||D===0,T,D,R,this.placement,this.fog&&x.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,ae,me,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),re=!0),X&&this.pauseablePlacement.placement.setStale()),re||X){this._buildingIndex.onNewFrame(x.zoom);for(let Ce=0;CeR===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(!x)return T.push(h),this._loadImports([h],!0);const D=T.findIndex(({id:R})=>R===x);return D===-1&&this.fire(new i.y(new Error(`Import with id "${x}" does not exist on this map.`))),this.stylesheet.imports=T.slice(0,D).concat(h).concat(T.slice(D)),this._loadImports([h],!0,x)}updateImport(h,x){this._checkLoaded();const T=this.stylesheet.imports||[],D=this.getImportIndex(h);return D===-1?this:typeof x=="string"?(this.setImportUrl(h,x),this):(x.url&&x.url!==T[D].url&&this.setImportUrl(h,x.url),i.by(x.config,T[D].config)||this.setImportConfig(h,x.config,x.data.schema),i.by(x.data,T[D].data)||this.setImportData(h,x.data),this)}moveImport(h,x){this._checkLoaded();let T=this.stylesheet.imports||[];const D=this.getImportIndex(h);if(D===-1)return this;const R=this.getImportIndex(x);if(R===-1)return this;const z=T[D],V=this.fragments[D];return T=T.filter(({id:X})=>X!==h),this.fragments=this.fragments.filter(({id:X})=>X!==h),this.stylesheet.imports=T.slice(0,R).concat(z).concat(T.slice(R)),this.fragments=this.fragments.slice(0,R).concat(V).concat(this.fragments.slice(R)),this.mergeLayers(),this}setImportUrl(h,x){this._checkLoaded();const T=this.stylesheet.imports||[],D=this.getImportIndex(h);if(D===-1)return this;T[D].url=x;const R=this.fragments[D];return R.style=this._createFragmentStyle(T[D]),R.style.on("style.import.load",()=>this.mergeAll()),R.style.loadURL(x),this}setImportData(h,x){this._checkLoaded();const T=this.getImportIndex(h),D=this.stylesheet.imports||[];return T===-1?this:x?(this.fragments[T].style.setState(x),this._reloadImports(),this):(delete D[T].data,this.setImportUrl(h,D[T].url))}setImportConfig(h,x,T){this._checkLoaded();const D=this.getImportIndex(h),R=this.stylesheet.imports||[];if(D===-1)return this;x?R[D].config=x:delete R[D].config;const z=this.fragments[D];T&&z.style.stylesheet&&(z.style.stylesheet.schema=T);const V=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=x,z.style.updateConfig(x,V),this.updateConfigDependencies(),this}removeImport(h){this._checkLoaded();const x=this.stylesheet.imports||[],T=this.getImportIndex(h);T!==-1&&(x.splice(T,1),this.fragments[T].style._remove(),this.fragments.splice(T,1),this._reloadImports())}getImportIndex(h){const x=(this.stylesheet.imports||[]).findIndex(T=>T.id===h);return x===-1&&this.fire(new i.y(new Error(`Import '${h}' does not exist in the map's style and cannot be updated.`))),x}getLayer(h){return this._mergedLayers[h]}getSources(){const h=[];for(const x in this._mergedOtherSourceCaches){const T=this._mergedOtherSourceCaches[x];T&&h.push(T.getSource())}return h}getSource(h,x){const T=this.getSourceCache(h,x);return T&&T.getSource()}getLayerSource(h){const x=this.getLayerSourceCache(h);return x&&x.getSource()}getSourceCache(h,x){const T=i.B(h,x);return this._mergedOtherSourceCaches[T]}getLayerSourceCache(h){const x=i.B(h.source,h.scope);return h.type==="symbol"?this._mergedSymbolSourceCaches[x]:this._mergedOtherSourceCaches[x]}getSourceCaches(h){if(h==null)return Object.values(this._mergedSourceCaches);const x=[];return this._mergedOtherSourceCaches[h]&&x.push(this._mergedOtherSourceCaches[h]),this._mergedSymbolSourceCaches[h]&&x.push(this._mergedSymbolSourceCaches[h]),x}updateSourceCaches(){const h=this._changes.getUpdatedSourceCaches();for(const x in h){const T=h[x];T==="reload"?this.reloadSource(x):T==="clear"&&this.clearSource(x)}}updateLayers(h){const x=this._changes.getUpdatedPaintProperties();for(const T of x){const D=this.getLayer(T);D&&D.updateTransitions(h)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(h){this.stylesheet.glyphs=h,this.glyphManager.setURL(h)}getImages(h,x,T){this.imageManager.getImages(x.images,x.scope,T),this._updateTilesForChangedImages();const D=z=>{if(z){const V=x.images.map(X=>i.I.toString(X));z.setDependencies(x.tileID.key,x.type,V)}},R=i.B(x.source,x.scope);D(this._mergedOtherSourceCaches[R]),D(this._mergedSymbolSourceCaches[R]),x.images.some(z=>z.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(h,x,T){this.imageManager.rasterizeImages(x,T)}getGlyphs(h,x,T){this.glyphManager.getGlyphs(x.stacks,T)}getResource(h,x,T){return i.dz(x,T)}getOwnSourceCache(h){return this._otherSourceCaches[h]}getOwnLayerSourceCache(h){return h.type==="symbol"?this._symbolSourceCaches[h.source]:this._otherSourceCaches[h.source]}getOwnSourceCaches(h){const x=[];return this._otherSourceCaches[h]&&x.push(this._otherSourceCaches[h]),this._symbolSourceCaches[h]&&x.push(this._symbolSourceCaches[h]),x}_isSourceCacheLoaded(h){const x=this.getOwnSourceCaches(h);return x.length===0?(this.fire(new i.y(new Error(`There is no source with ID '${h}'`))),!1):x.every(T=>T.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(h,x){if(!this._clipLayerPresent&&h.type!=="fill-extrusion"&&h.type!=="building")return!1;const T=h.type==="fill-extrusion"&&(h.sourceLayer==="building"||h.sourceLayer==="procedural_buildings"),D=h.type==="building";if(h.is3D(!!this.terrain)){if(T||D||x&&x.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)}}sm.getSourceType=function(C){return Zh[C]},sm.setSourceType=function(C,h){Zh[C]=h},sm.registerForPluginStateChange=i.dA;class YL 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[x,T]of Object.entries(h.buildings))if(this._buildings[x])for(const D of T.floorIds)this._buildings[x].floors[D]||(this._buildings[x].floors[D]=T.floors[D]);else this._buildings[x]=T;for(const x of h.activeFloors)this._activeFloors.add(x);this._updateIndoorSelector()}getIndoorTileOptions(h,x){const T=this._style.getIndoorSourceLayers(h,x);return T&&this._indoorState?{sourceLayers:T,indoorState:this._indoorState}:null}_updateUI(h,x,T){const D=function(R,z,V,X){let re=null,ae=Number.MAX_SAFE_INTEGER;if(X<16)return null;for(const[me,he]of Object.entries(R)){const pe=he.center;if(pe){const Me=z.distanceTo(i.aT.convert(pe));Me({id:z,name:T.floors[z].name,zIndex:T.floors[z].zIndex})).sort((z,V)=>V.zIndex-z.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:D,activeFloorsVisible:this._activeFloorsVisible,floors:R}))}_updateActiveFloors(){const h=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:h,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var ov=` #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`,lv=` #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;}`,qM=` #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`,fS="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;}",ch=` #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`,gS=`#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`,Gs=`#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`,UM=`#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`,xS=`#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;}`,yS=`#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`,VM=`#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 nb=/#include\s+"([^"]+)"/g,Ap=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,HM=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,vy=new Set(["ifdef","ifndef","elif","if","defined"]),_y=new Set;rx(ov,_y),rx(qM,_y),rx(lv,_y);const sx={"_prelude_fog.vertex.glsl":gS,"_prelude_terrain.vertex.glsl":ch,"_prelude_shadow.vertex.glsl":yS,"_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":Gs,"_prelude_shadow.fragment.glsl":VM,"_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":UM,"_prelude_raster_particle.glsl":xS},vS={};wa("",ch),wa(Gs,gS),wa(VM,yS),wa(UM,""),wa(xS,"");const XL=wa(lv,qM),_S=ov,Sce=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",_S,XL.fragmentSource].join(` `),QL=["precision highp float;",_S,XL.vertexSource].join(` `);var WM={background:wa(`#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:wa(`#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:wa(`#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:wa(`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:wa(`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:wa(`#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:wa("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:wa(`#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:wa(`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:wa("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:wa("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:wa("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:wa(`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:wa(`#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:wa(`#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:wa(`#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:wa(`#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:wa(`#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:wa(`#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:wa(`#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:wa(`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:wa(`#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:wa(`#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:wa(`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:wa(`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:wa(`#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:wa(`#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:wa(`#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:wa(`#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:wa(`#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:wa("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:wa("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:wa(`#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:wa(`#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:wa(`#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:wa("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:wa(`#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 }`,fS),skyboxGradient:wa(`#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 }`,fS),skyboxCapture:wa(` 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:wa(`#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:wa(`#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:wa(`#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:wa(`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:wa(`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:wa("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:wa("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:wa("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:wa("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 rx(C,h){const x=C.split(` `);for(let T of x){if(T=T.trimStart(),T[0]!=="#"||!T.includes("if")||T.startsWith("#endif"))continue;const D=T.match(HM);if(D)for(const R of D)vy.has(R)||h.add(R)}}function wa(C,h){const x=new Set,T=[],D=[];C=C.replace(nb,(z,V)=>(D.push(V),"")),h=h.replace(nb,(z,V)=>(T.push(V),""));let R=new Set(_y);rx(C,R),rx(h,R);for(const z of[...T,...D])vS[z]||(vS[z]=new Set,rx(sx[z],vS[z])),R=new Set([...R,...vS[z]]);return{fragmentSource:C=C.replace(Ap,(z,V,X,re,ae)=>(x.add(ae),V==="define"?` #ifndef HAS_UNIFORM_u_${ae} in ${X} ${re} ${ae}; #else uniform ${X} ${re} u_${ae}; #endif `:V==="initialize"?` #ifdef HAS_UNIFORM_u_${ae} ${X} ${re} ${ae} = u_${ae}; #endif `:V==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${ae} in ${X} ${re} ${ae}; #endif `:V==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace(Ap,(z,V,X,re,ae)=>{const me=`MATERIAL_ATTRIBUTE_OFFSET_${ae}`,he=re==="float"?"vec2":re,pe=`GET_ATTRIBUTE_${he}(a_${ae}, materialInfo, ${me})`,Me=ae.match(/color/)?"color":he;return V==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${ae} in ${X} ${re} a_${ae}; #endif `:x.has(ae)?V==="define"?` #ifndef HAS_UNIFORM_u_${ae} uniform lowp float u_${ae}_t; #if !defined(${me}) in ${X} ${he} a_${ae}; #endif out ${X} ${re} ${ae}; #else uniform ${X} ${re} u_${ae}; #endif `:V==="initialize"?Me==="vec4"?` #ifndef HAS_UNIFORM_u_${ae} ${ae} = a_${ae}; #else ${X} ${re} ${ae} = u_${ae}; #endif `:` #if !defined(HAS_UNIFORM_u_${ae}) #ifdef ${me} ${ae} = unpack_mix_${Me}(${pe}, u_${ae}_t); #else ${ae} = unpack_mix_${Me}(a_${ae}, u_${ae}_t); #endif #else ${X} ${re} ${ae} = u_${ae}; #endif `:V==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${ae} in ${X} ${re} a_${ae}; out ${X} ${re} ${ae}; #endif `:V==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${ae} ${ae} = a_${ae}; #endif `:void 0:V==="define"?` #ifndef HAS_UNIFORM_u_${ae} uniform lowp float u_${ae}_t; #if !defined(${me}) in ${X} ${he} a_${ae}; #endif #else uniform ${X} ${re} u_${ae}; #endif `:V==="define-instanced"?Me==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${ae}0; in vec4 a_${ae}1; in vec4 a_${ae}2; in vec4 a_${ae}3; #else uniform ${X} ${re} u_${ae}; #endif `:` #ifdef INSTANCED_ARRAYS in ${X} ${he} a_${ae}; #else uniform ${X} ${re} u_${ae}; #endif `:V==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${ae} ${X} ${re} ${ae} = a_${ae}; #endif `:Me==="vec4"?` #ifndef HAS_UNIFORM_u_${ae} #ifdef ${me} ${X} ${re} ${ae} = ${pe}; #else ${X} ${re} ${ae} = a_${ae}; #endif #else ${X} ${re} ${ae} = u_${ae}; #endif `:` #ifndef HAS_UNIFORM_u_${ae} #ifdef ${me} ${X} ${re} ${ae} = unpack_mix_${Me}(${pe}, u_${ae}_t); #else ${X} ${re} ${ae} = unpack_mix_${Me}(a_${ae}, u_${ae}_t); #endif #else ${X} ${re} ${ae} = u_${ae}; #endif `}),usedDefines:R,vertexIncludes:T,fragmentIncludes:D}}class Cce{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(h,x,T,D,R,z,V,X){this.context=h;let re=this.boundPaintVertexBuffers.length!==D.length;for(let me=0;!re&&me{const Ct=ot.paint.get("hillshade-shadow-color"),vt=ot.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",jt=ot.paint.get("hillshade-highlight-color"),xt=ot.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",pt=ot.paint.get("hillshade-accent-color"),Et=ot.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Ht=ot.paint.get("hillshade-emissive-strength");let Ut=i.an(ot.paint.get("hillshade-illumination-direction"));if(ot.paint.get("hillshade-illumination-anchor")==="viewport")Ut-=Be.transform.angle;else if(Be.style&&Be.style.enable3dLights()&&Be.style.directionalLight){const ss=Be.style.directionalLight.properties.get("direction"),ps=i.d4(ss.x,ss.y,ss.z);Ut=i.an(ps[1])}const ts=!Be.options.moving;return{u_matrix:et||Be.transform.calculateProjMatrix(Xe.tileID.toUnwrapped(),ts),u_image:0,u_latrange:Mce(0,Xe.tileID),u_light:[ot.paint.get("hillshade-exaggeration"),Ut],u_shadow:Ct.toPremultipliedRenderColor(vt?null:ot.lut),u_highlight:jt.toPremultipliedRenderColor(xt?null:ot.lut),u_emissive_strength:Ht,u_accent:pt.toPremultipliedRenderColor(Et?null:ot.lut)}})(C,x,T,C.terrain?h.projMatrix:null);C.uploadCommonUniforms(V,he,h.toUnwrapped());const{tileBoundsBuffer:Me,tileBoundsIndexBuffer:Ce,tileBoundsSegments:$e}=C.getTileBoundsBuffers(x);he.draw(C,X.TRIANGLES,D,R,z,rn.disabled,pe,T.id,Me,Ce,$e)}function GM(C,h,x){if(!h.needsDEMTextureUpload)return;const T=C.context,D=T.gl;T.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||C.getTileTexture(x.stride);const R=x.getPixels();h.demTexture?h.demTexture.update(R,{premultiply:!1}):h.demTexture=new i.T(T,R,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function Ace(C,h,x){const T=C.context,D=T.gl;if(!h.dem)return;const R=h.dem;if(T.activeTexture.set(D.TEXTURE1),GM(C,h,R),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const z=R.dim;T.activeTexture.set(D.TEXTURE0);let V=h.hillshadeFBO;if(!V){const he=new i.T(T,{width:z,height:z,data:null},D.RGBA8);he.bind(D.LINEAR,D.CLAMP_TO_EDGE),V=h.hillshadeFBO=T.createFramebuffer(z,z,1,"renderbuffer"),V.colorAttachment0.set(he.texture)}T.bindFramebuffer.set(V.framebuffer),T.viewport.set([0,0,z,z]);const{tileBoundsBuffer:X,tileBoundsIndexBuffer:re,tileBoundsSegments:ae}=C.getMercatorTileBoundsBuffers(),me=[];C.linearFloatFilteringSupported()&&me.push("TERRAIN_DEM_FLOAT_FORMAT"),C.terrain&&C.terrain.renderingToTexture&&C.emissiveMode==="mrt-fallback"&&me.push("USE_MRT1"),C.getOrCreateProgram("hillshadePrepare",{defines:me}).draw(C,D.TRIANGLES,Er.disabled,ln.disabled,En.unblended,rn.disabled,((he,pe)=>{const Me=pe.stride,Ce=i.bC();return i.ce(Ce,0,i.al,-i.al,0,0,1),i.br(Ce,Ce,[0,-i.al,0]),{u_matrix:Ce,u_image:1,u_dimension:[Me,Me],u_zoom:he.overscaledZ}})(h.tileID,R),x.id,X,re,ae),h.needsHillshadePrepare=!1}class Qi{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 Ece extends Qi{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const x=this.current;(h.r!==x.r||h.g!==x.g||h.b!==x.b||h.a!==x.a||this.dirty)&&(this.gl.clearColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class JL extends Qi{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class KM extends Qi{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class bS extends Qi{getDefault(){return[!0,!0,!0,!0]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.colorMask(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class ZM extends Qi{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class by extends Qi{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class cv extends Qi{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(h){const x=this.current;(h.func!==x.func||h.ref!==x.ref||h.mask!==x.mask||this.dirty)&&(this.gl.stencilFunc(h.func,h.ref,h.mask),this.current=h,this.dirty=!1)}}class ab extends Qi{getDefault(){const h=this.gl;return[h.KEEP,h.KEEP,h.KEEP]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||this.dirty)&&(this.gl.stencilOp(h[0],h[1],h[2]),this.current=h,this.dirty=!1)}}class dv extends Qi{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.STENCIL_TEST):x.disable(x.STENCIL_TEST),this.current=h,this.dirty=!1}}class eD extends Qi{getDefault(){return[0,1]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||this.dirty)&&(this.gl.depthRange(h[0],h[1]),this.current=h,this.dirty=!1)}}class YM extends Qi{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.DEPTH_TEST):x.disable(x.DEPTH_TEST),this.current=h,this.dirty=!1}}class tD extends Qi{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class uv extends Qi{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.BLEND):x.disable(x.BLEND),this.current=h,this.dirty=!1}}class wS extends Qi{getDefault(){const h=this.gl;return[h.ONE,h.ZERO,h.ONE,h.ZERO]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.blendFuncSeparate(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class jS extends Qi{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const x=this.current;(h.r!==x.r||h.g!==x.g||h.b!==x.b||h.a!==x.a||this.dirty)&&(this.gl.blendColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class XM extends Qi{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 kS extends Qi{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.CULL_FACE):x.disable(x.CULL_FACE),this.current=h,this.dirty=!1}}class ib extends Qi{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class sD extends Qi{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let rD=class extends Qi{getDefault(){return null}set(C){(C!==this.current||this.dirty)&&(this.gl.useProgram(C),this.current=C,this.dirty=!1)}};class nD extends Qi{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class hv extends Qi{getDefault(){const h=this.gl;return[0,0,h.drawingBufferWidth,h.drawingBufferHeight]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.viewport(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class aD extends Qi{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindFramebuffer(x.FRAMEBUFFER,h),this.current=h,this.dirty=!1}}class Pce extends Qi{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindRenderbuffer(x.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class Ice extends Qi{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindTexture(x.TEXTURE_2D,h),this.current=h,this.dirty=!1}}class Lce extends Qi{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindBuffer(x.ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class QM extends Qi{getDefault(){return null}set(h){const x=this.gl;x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class JM extends Qi{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class eT extends Qi{getDefault(){return 4}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_ALIGNMENT,h),this.current=h,this.dirty=!1}}class tT extends Qi{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),this.current=h,this.dirty=!1}}class iD extends Qi{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_FLIP_Y_WEBGL,h),this.current=h,this.dirty=!1}}class NS extends Qi{constructor(h,x){super(h),this.context=h,this.parent=x}getDefault(){return null}}class SS extends NS{constructor(h,x,T=0){super(h,x),this.attachmentPoint=h.gl.COLOR_ATTACHMENT0+T}setDirty(){this.dirty=!0}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferTexture2D(x.FRAMEBUFFER,this.attachmentPoint,x.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class mv extends NS{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferRenderbuffer(x.FRAMEBUFFER,this.attachment(),x.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class ob extends NS{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferTexture2D(x.FRAMEBUFFER,this.attachment(),x.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class oD extends mv{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const dh=(C,h,x,T)=>({u_matrix:C,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:x,u_emissive_texture_available:T}),CS=(C,h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e)=>({u_proj_matrix:Float32Array.from(C),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(T),u_merc_matrix:x,u_zoom_transition:D,u_merc_center:R,u_image0:0,u_image1:1,u_frustum_tl:z,u_frustum_tr:V,u_frustum_br:X,u_frustum_bl:re,u_globe_pos:ae,u_globe_radius:me,u_viewport:he,u_grid_matrix:$e?Float32Array.from($e):new Float32Array(9),u_skirt_height:pe,u_far_z_cutoff:Me,u_emissive_texture_available:Ce});function lb(C,h){return C!=null&&h!=null&&!(!C.hasData()||!h.hasData())&&C.demTexture!=null&&h.demTexture!=null&&C.tileID.key!==h.tileID.key}const If=new class{constructor(){this.operations={}}newMorphing(C,h,x,T,D){if(C in this.operations){const R=this.operations[C];R.to.tileID.key!==x.tileID.key&&(R.queued=x)}else this.operations[C]={startTime:T,phase:0,duration:D,from:h,to:x,queued:null}}getMorphValuesForProxy(C){if(!(C in this.operations))return null;const h=this.operations[C];return{from:h.from,to:h.to,phase:h.phase}}update(C){for(const h in this.operations){const x=this.operations[h];for(x.phase=(C-x.startTime)/x.duration;x.phase>=1||!this._validOp(x);)if(!this._nextOp(x,C)){delete this.operations[h];break}}}_nextOp(C,h){return!!C.queued&&(C.from=C.to,C.to=C.queued,C.queued=null,C.phase=0,C.startTime=h,!0)}_validOp(C){return C.from.hasData()&&C.to.hasData()}},MS={0:null,1:"TERRAIN_VERTEX_MORPHING"};function TS(C,h,x){if(h===0)return 0;const T=h<1&&x===514?.25/h:1;return 6*Math.pow(1.5,22-C)*Math.max(h,1)*T}function sT(C,h){const x=1<({u_matrix:C});function db(C,h,x,T,D){if(D>0){const R=i.o.now(),z=(R-C.timeAdded)/D,V=h?(R-h.timeAdded)/D:-1,X=x.getSource(),re=T.coveringZoomLevel({tileSize:X.tileSize,roundZoom:X.roundZoom}),ae=!h||Math.abs(h.tileID.overscaledZ-re)>Math.abs(C.tileID.overscaledZ-re),me=ae&&C.refreshedUponExpiration?1:i.aA(ae?z:1-V,0,1);return h?{opacity:1,mix:1-me,isFading:z<1}:{opacity:me,mix:0,isFading:z<1}}return{opacity:1,mix:0,isFading:!1}}class AS extends ul{constructor(h){const x=xl("mock-dem",{type:"raster-dem",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("mock-dem",x,!1),x.setEventedParent(this),this._sourceLoaded=!0}_loadTile(h,x){h.state="loaded",x(null)}}class rT extends ul{constructor(h){const x=xl("proxy",{type:"geojson",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("proxy",x,!1),x.setEventedParent(this),this.map=this.getSource().map=h,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(h,x,T){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((R,z)=>{if(R[z.key]="",!this._tiles[z.key]){const V=new Xh(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);V.state="loaded",this._tiles[z.key]=V}return R},{});for(const R in this._tiles)R in D||(this.freeFBO(R),this._tiles[R].unloadVectorData(),delete this._tiles[R])}freeFBO(h){const x=this.proxyCachedFBO[h];if(x!==void 0){const T=Object.values(x);this.renderCachePool.push(...T),delete this.proxyCachedFBO[h]}}deallocRenderCache(){this.renderCache.forEach(h=>h.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class nT extends i.aQ{constructor(h,x,T){super(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y),this.proxyTileKey=x,this.projMatrix=T}}class aT extends i.bV{constructor(h,x){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[T,D,R]=function(X){const re=new i.bd,ae=new i.b0,me=131;re.reserve(17161),ae.reserve(33800);const he=i.al/128,pe=i.al+he/2,Me=pe+he;for(let $e=-he;$epe||$e<0||$e>pe?24575:0,ot=i.aA(Math.round(Be),0,i.al),et=i.aA(Math.round($e),0,i.al);re.emplaceBack(ot+Xe,et)}const Ce=($e,Be)=>{const Xe=Be*me+$e;ae.emplaceBack(Xe+1,Xe,Xe+me),ae.emplaceBack(Xe+me,Xe+me+1,Xe+1)};for(let $e=1;$e<129;$e++)for(let Be=1;Be<129;Be++)Ce(Be,$e);return[0,129].forEach($e=>{for(let Be=0;Be<130;Be++)Ce(Be,$e),Ce($e,Be)}),[re,ae,32768]}(),z=h.context;this.gridBuffer=z.createVertexBuffer(T,i.bf.members),this.gridIndexBuffer=z.createIndexBuffer(D),this.gridSegments=i.bg.simpleSegment(0,0,T.length,D.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,T.length,R),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new rT(x.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 V=z.gl;this._overlapStencilMode=new ln({func:V.GEQUAL,mask:255},0,255,V.KEEP,V.KEEP,V.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=x,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new AS(x.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,x,T){if(h&&h.terrain){this._style!==h&&(this.style=h,this._evaluationZoom=void 0);const D=h.terrain.properties,R=h.terrain.drapeRenderMode===0,z=h.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const V=h.terrain&&h.terrain.scope,X=D.get("source"),re=R?this._mockSourceCache:h.getSourceCache(X,V);if(!re)return void i.w(`Couldn't find terrain source "${X}".`);if(this.sourceCache=re,this._attenuationRange=h.terrain.getAttenuationRange(),this._exaggeration=z?this.calculateExaggeration(x):D.get("exaggeration"),!x.projection.requiresDraping&&z&&this._exaggeration===0)return void this._disable();this.enabled=!0;const ae=()=>{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 me=this.getScaledDemTileSize();this.sourceCache.update(x,me,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,ae(),this._initializing=!0),ae(),x.updateElevation(!0,T),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(x),this._emptyDEMTextureDirty=!0,this._previousZoom=x.zoom}else this._disable()}calculateExaggeration(h){if(this._attenuationRange&&h.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(h.zoom);const x=this._previousCameraAltitude,T=h.getFreeCameraOptions().position.z/h.pixelsPerMeter*h.worldSize;this._previousCameraAltitude=T;const D=x!=null?T-x:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const R=h.zoom,z=this._style.terrain;if(!this._previousUpdateTimestamp)return z.getExaggeration(R);let V=R-this._previousZoom;const X=this._previousUpdateTimestamp;let re=R;this._evaluationZoom!=null&&(re=this._evaluationZoom,Math.abs(R-re)>.5&&(V=.5*(R-re+V)),V*D<0&&(re+=V)),this._evaluationZoom=re;const ae=z.getExaggeration(re),me=ae===z.getExaggeration(Math.max(0,re-.1));if(me&&Math.abs(ae-this._exaggeration)<.01)return ae;let he=Math.min(.1,.00375*(this._updateTimestamp-X));return(me||ae<.1||Math.abs(V)<1e-4)&&(he=Math.min(.2,4*he)),i.ak(this._exaggeration,ae,he)}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 x=this.proxySourceCache,T=this.painter.transform;this._initializing&&(this._initializing=T._centerAltitude===0&&this.getAtPointOrZero(i.ae.fromLngLat(T.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=x.getIds().map(X=>{const re=x.getTileByID(X).tileID;return re.projMatrix=T.calculateProjMatrix(re.toUnwrapped()),re});(function(X,re){const ae=re.transform.pointCoordinate(re.transform.getCameraPoint()),me=new i.P(ae.x,ae.y);X.sort((he,pe)=>{if(pe.overscaledZ-he.overscaledZ)return pe.overscaledZ-he.overscaledZ;const Me=new i.P(he.canonical.x+(1<{this.proxyToSource[X.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const X in z){const re=z[X];if(!re.used||(re!==this.sourceCache&&this.resetTileLookupCache(re.id),this._setupProxiedCoordsForOrtho(re,h[X],R),re.usedForTerrain))continue;const ae=h[X];re.getSource().reparseOverscaled&&this._assignTerrainTiles(ae)}this.proxiedCoords[x.id]=D.map(X=>new nT(X,X.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(R),this.renderingToTexture=!1;const V={};this._visibleDemTiles=[];for(const X of this.proxyCoords){const re=this.terrainTileForTile[X.key];if(!re)continue;const ae=re.tileID.key;ae in V||(this._visibleDemTiles.push(re),V[ae]=ae)}}_assignTerrainTiles(h){this._initializing||h.forEach(x=>{if(this.terrainTileForTile[x.key])return;const T=this._findTileCoveringTileID(x,this.sourceCache);T&&(this.terrainTileForTile[x.key]=T)})}_prepareDEMTextures(){const h=this.painter.context,x=h.gl;for(const T in this.terrainTileForTile){const D=this.terrainTileForTile[T],R=D.dem;!R||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(x.TEXTURE1),GM(this.painter,D,R))}}_prepareDemTileUniforms(h,x,T,D){if(!x||x.demTexture==null)return!1;const R=h.tileID.canonical,z=Math.pow(2,x.tileID.canonical.z-R.z),V=D||"";return T[`u_dem_tl${V}`]=[R.x*z%1,R.y*z%1],T[`u_dem_scale${V}`]=z,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let h=0;const x=this._visibleDemTiles.reduce((T,D)=>{if(!D.dem)return T;const R=D.dem.tree.minimums[0];return R>0&&h++,T+R},0);return h?x/h:0}_updateEmptyDEMTexture(){const h=this.painter.context,x=h.gl;h.activeTexture.set(x.TEXTURE2);const T=this._getLoadedAreaMinimum(),D=new i.dL({width:1,height:1},new Float32Array([T]));this._emptyDEMTextureDirty=!1;let R=this._emptyDEMTexture;return R?R.update(D,{premultiply:!1}):R=this._emptyDEMTexture=new i.T(h,D,x.R32F,{premultiply:!1}),R}setupElevationDraw(h,x,T){const D=this.painter.context,R=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 V=null,X=null,re=1;if(T&&T.morphing&&this._useVertexMorphing){const pe=T.morphing.srcDemTile,Me=T.morphing.dstDemTile;re=T.morphing.phase,pe&&Me&&(this._prepareDemTileUniforms(h,pe,z,"_prev")&&(X=pe),this._prepareDemTileUniforms(h,Me,z)&&(V=Me))}const ae=pe=>pe&&pe.demTexture&&this.painter.linearFloatFilteringSupported()?R.LINEAR:R.NEAREST;let me=null;var he;if(this.enabled?X&&V?(me=V.demTexture,D.activeTexture.set(R.TEXTURE4),X.demTexture.bind(ae(X),R.CLAMP_TO_EDGE),z.u_dem_lerp=re):(V=this.terrainTileForTile[h.tileID.key],me=this._prepareDemTileUniforms(h,V,z)?V.demTexture:this.emptyDEMTexture):me=this.emptyDEMTexture,D.activeTexture.set(R.TEXTURE2),me&&(z.u_dem_size=(he=me).size[0]===1?1:he.size[0]-2,me.bind(ae(V),R.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(T&&T.useDepthForOcclusion,x,z),T&&T.useMeterToDem&&V){const pe=(1<{if(Be===ss)return;const ps=[MS[ss],"PROJECTION_GLOBE_VIEW"];ot&&ps.push("CUSTOM_ANTIALIASING");const zs=re.isTileAffectedByFog(ts);$e=re.getOrCreateProgram("globeRaster",{defines:ps,overrideFog:zs}),Be=ss},Ct=re.colorModeForRenderPass(),vt=new Er(Ce.LEQUAL,Er.ReadWrite,re.depthRangeFor3D);If.update(pe);const jt=i.dF(Xe),xt=[i.aF(Xe.center.lng),i.aJ(Xe.center.lat)],pt=re.globeSharedBuffers,Et=[Xe.width*i.o.devicePixelRatio,Xe.height*i.o.devicePixelRatio],Ht=Float32Array.from(Xe.globeMatrix),Ut={useDenormalizedUpVectorScale:!0};{const ts=re.transform,ss=TS(ts.zoom,ae.exaggeration(),ae.sourceCache._source.tileSize);Be=-1;const ps=Ce.TRIANGLES;for(const zs of he){const Xt=me.getTile(zs),Dt=ln.disabled,ls=ae.prevTerrainTileForTile[zs.key],es=ae.terrainTileForTile[zs.key];lb(ls,es)&&If.newMorphing(zs.key,ls,es,pe,250),pv(re,Xt.emissiveTexture),Me.activeTexture.set(Ce.TEXTURE0),Xt.texture&&Xt.texture.bind(Ce.LINEAR,Ce.CLAMP_TO_EDGE);const As=If.getMorphValuesForProxy(zs.key),Xs=As?1:0;As&&Object.assign(Ut,{morphing:{srcDemTile:As.from,dstDemTile:As.to,phase:i.dD(As.phase)}});const ur=i.dG(zs.canonical),Ws=i.dH(ur.getCenter().lat),Bs=i.dI(zs.canonical,ur,Ws,ts.worldSize/ts._pixelsPerMercatorPixel),kr=i.bk(i.dJ(zs.canonical)),br=re.emissiveMode==="mrt-fallback"?1:0,or=CS(ts.expandedFarZProjMatrix,Ht,jt,kr,i.aj(ts.zoom),xt,ts.frustumCorners.TL,ts.frustumCorners.TR,ts.frustumCorners.BR,ts.frustumCorners.BL,ts.globeCenterInViewSpace,ts.globeRadius,Et,ss,ts._farZ,br,Bs);if(et(zs,Xs),$e&&(ae.setupElevationDraw(Xt,$e,Ut),re.uploadCommonUniforms(Me,$e,zs.toUnwrapped()),pt)){const[mr,$r,jn]=pt.getGridBuffers(Ws,ss!==0);$e.draw(re,ps,vt,Dt,Ct,rn.backCCW,or,"globe_raster",mr,$r,jn)}}}if(pt&&(re.renderDefaultNorthPole||re.renderDefaultSouthPole)){const ts=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ot&&ts.push("CUSTOM_ANTIALIASING"),$e=re.getOrCreateProgram("globeRaster",{defines:ts});for(const ss of he){const{x:ps,y:zs,z:Xt}=ss.canonical,Dt=zs===0,ls=zs===(1<mr.draw(re,Ce.TRIANGLES,vt,ln.disabled,Ct,rn.disabled,CS(Xe.expandedFarZProjMatrix,Bs,Bs,kr,0,xt,Xe.frustumCorners.TL,Xe.frustumCorners.TR,Xe.frustumCorners.BR,Xe.frustumCorners.BL,Xe.globeCenterInViewSpace,Xe.globeRadius,Et,0,Xe._farZ,br),"globe_pole_raster",$r,Xs,ur);ae.setupElevationDraw(Ws,$e,Ut),re.uploadCommonUniforms(Me,$e,ss.toUnwrapped()),Dt&&re.renderDefaultNorthPole&&or($e,es),ls&&re.renderDefaultSouthPole&&(Bs=i.cS(i.bC(),Bs,[1,-1,1]),or($e,As))}}}})(D,R,z,V,X);else{const re=D.context,ae=re.gl;let me,he;const pe=D.shadowRenderer,Me=Qg(D,D.longestCutoffRange),Ce=Ct=>{if(he===Ct)return;const vt=[];vt.push(MS[Ct]),Me.shouldRenderCutoff&&vt.push("RENDER_CUTOFF"),pe&&(vt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),pe.useNormalOffset&&vt.push("NORMAL_OFFSET")),me=D.getOrCreateProgram("terrainRaster",{defines:vt}),he=Ct},$e=D.colorModeForRenderPass(),Be=new Er(ae.LEQUAL,Er.ReadWrite,D.depthRangeFor3D);If.update(X);const Xe=D.transform,ot=TS(Xe.zoom,R.exaggeration(),R.sourceCache._source.tileSize);let et=[0,0,0];if(pe){const Ct=D.style.directionalLight,vt=D.style.ambientLight;Ct&&vt&&(et=Pf(D.style,Ct,vt))}{he=-1;const Ct=ae.TRIANGLES,[vt,jt]=[R.gridIndexBuffer,R.gridSegments];for(const xt of V){const pt=z.getTile(xt),Et=ln.disabled,Ht=R.prevTerrainTileForTile[xt.key],Ut=R.terrainTileForTile[xt.key];lb(Ht,Ut)&&If.newMorphing(xt.key,Ht,Ut,X,250),pv(D,pt.emissiveTexture),re.activeTexture.set(ae.TEXTURE0),pt.texture&&pt.texture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE);const ts=If.getMorphValuesForProxy(xt.key),ss=ts?1:0;let ps;ts&&(ps={morphing:{srcDemTile:ts.from,dstDemTile:ts.to,phase:i.dD(ts.phase)}});const zs=D.emissiveMode==="mrt-fallback"?1:0,Xt=dh(xt.projMatrix,sT(xt.canonical,Xe.renderWorldCopies)?ot/10:ot,et,zs);if(Ce(ss),!me)continue;R.setupElevationDraw(pt,me,ps);const Dt=xt.toUnwrapped();pe&&pe.setupShadows(Dt,me),D.uploadCommonUniforms(re,me,Dt,null,Me),me.draw(D,Ct,Be,Et,$e,rn.backCCW,Xt,"terrain_raster",R.gridBuffer,vt,jt)}}}}(x,this,this.proxySourceCache,h,this._updateTimestamp),this.renderingToTexture=!0,x.gpuTimingDeferredRenderEnd(),h.splice(0,h.length))}renderBatch(h){if(this._drapedRenderBatches.length===0)return h+1;this.renderingToTexture=!0;const x=this.painter,T=this.painter.context,D=this.proxySourceCache,R=this.proxiedCoords[D.id],z=this._drapedRenderBatches.shift(),V=x.style.order,X=[];this._updateFBOs(x.emissiveMode==="mrt-fallback");let re=0;for(const ae of R){const me=D.getTileByID(ae.proxyTileKey),he=D.proxyCachedFBO[ae.key]?D.proxyCachedFBO[ae.key][h]:void 0,pe=he!==void 0?D.renderCache[he]:this.pool[re++],Me=he!==void 0;if(me.texture=pe.tex,me.emissiveTexture=pe.emissiveTex,Me&&!pe.dirty){X.push(me.tileID);continue}T.bindFramebuffer.set(pe.fb.framebuffer);const Ce=T.gl;let $e;Ce.drawBuffers(x.emissiveMode==="mrt-fallback"?[Ce.COLOR_ATTACHMENT0,Ce.COLOR_ATTACHMENT1]:[Ce.COLOR_ATTACHMENT0]),this.renderedToTile=!1,pe.dirty&&(T.clear({color:i.ao.transparent,stencil:0}),pe.dirty=!1);for(let Be=z.start;Be<=z.end;++Be){const Xe=x.style._mergedLayers[V[Be]];if(Xe.isHidden(x.transform.zoom))continue;const ot=x.style.getLayerSourceCache(Xe),et=ot?this.proxyToSource[ae.key][ot.id]:[ae];if(!et)continue;const Ct=et;T.viewport.set([0,0,pe.fb.width,pe.fb.height]),$e!==(ot?ot.id:null)&&(this._setupStencil(pe,et,Xe,ot),$e=ot?ot.id:null),x.renderLayer(x,ot,Xe,Ct)}if(Ce.drawBuffers([Ce.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Be of this._pendingGroundEffectLayers){const Xe=x.style._mergedLayers[V[Be]];if(Xe.isHidden(x.transform.zoom))continue;const ot=x.style.getLayerSourceCache(Xe),et=ot?this.proxyToSource[ae.key][ot.id]:[ae];if(!et)continue;const Ct=et;T.viewport.set([0,0,pe.fb.width,pe.fb.height]),$e!==(ot?ot.id:null)&&(this._setupStencil(pe,et,Xe,ot),$e=ot?ot.id:null),x.renderLayer(x,ot,Xe,Ct)}this.renderedToTile?(pe.dirty=!0,X.push(me.tileID)):Me||--re,re===5&&(re=0,this.renderToBackBuffer(X))}return this.renderToBackBuffer(X),this.renderingToTexture=!1,T.bindFramebuffer.set(null),T.viewport.set([0,0,x.width,x.height]),z.end+1}postRender(){}isLayerOrderingCorrect(h){const x=h.order.length;let T=-1,D=x;for(let R=0;RT}getMinElevationBelowMSL(){let h=0;return this._visibleDemTiles.filter(x=>x.dem).forEach(x=>{h=Math.min(h,x.dem.tree.minimums[0])}),h===0?h:(h-30)*this._exaggeration}raycast(h,x,T){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(R=>R.dem).map(R=>{const z=R.tileID,V=1<(R.t!==null?R.t:Number.MAX_VALUE)-(z.t!==null?z.t:Number.MAX_VALUE));for(const R of D){if(R.t==null)return null;const z=R.tile.dem.tree.raycast(R.minx,R.miny,R.maxx,R.maxy,h,x,T);if(z!=null)return z}return null}_createFBO(){const h=this.painter.context,x=h.gl,T=this.drapeBufferSize;h.activeTexture.set(x.TEXTURE0);const D=new i.T(h,{width:T[0],height:T[1],data:null},x.RGBA8);D.bind(x.LINEAR,x.CLAMP_TO_EDGE);const R=h.createFramebuffer(T[0],T[1],1,null);let z;return R.colorAttachment0.set(D.texture),this._emissiveTexture&&(z=new i.T(h,{width:T[0],height:T[1],data:null},x.R8),z.bind(x.LINEAR,x.CLAMP_TO_EDGE),R.createColorAttachment(h,1),R.colorAttachment1.set(z.texture)),R.depthAttachment=new oD(h,R.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=h.createRenderbuffer(h.gl.DEPTH_STENCIL,T[0],T[1]),this._stencilRef=0,R.depthAttachment.set(this._sharedDepthStencil),h.clear({stencil:0})):R.depthAttachment.set(this._sharedDepthStencil),h.extTextureFilterAnisotropic&&x.texParameterf(x.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax),{fb:R,tex:D,emissiveTex:z,dirty:!1}}_updateFBOs(h){if(this._emissiveTexture!==h){for(const x of this.pool)this._updateFBO(x,h);for(const x of this.proxySourceCache.renderCache)this._updateFBO(x,h);this._emissiveTexture=h}}_updateFBO(h,x){const T=h.fb,D=this.painter.context,R=D.gl,z=this.drapeBufferSize;if(x){const V=new i.T(D,{width:z[0],height:z[1],data:null},R.R8);V.bind(R.LINEAR,R.CLAMP_TO_EDGE),h.emissiveTex=V,T.createColorAttachment(D,1),T.colorAttachment1.set(V.texture)}else h.emissiveTex=void 0,T.removeColorAttachment(D,1);h.dirty=!0}_initFBOPool(){for(;this.pool.length{const x=this._style._mergedLayers[h],T=x.isHidden(this.painter.transform.zoom);return x.type==="hillshade"||x.type==="custom"?!T&&x.shouldRedrape():!T&&x.hasTransition()})}_clearLineLayersFromRenderCache(){let h=!1;for(const T of this._style.getSources())if(T instanceof kp){h=!0;break}if(!h)return;const x={};for(let T=0;TX>V.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=T}_setupRenderCache(h){const x=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,x.renderCache.length>x.renderCachePool.length){const z=Object.values(x.proxyCachedFBO);x.proxyCachedFBO={};for(let V=0;V=0;z--){const V=T[z];if(x.getTileByID(V.key),x.proxyCachedFBO[V.key]!==void 0){const X=h[V.key],re=this.proxyToSource[V.key];let ae=0;for(const me in re){const he=re[me],pe=X[me];if(!pe||pe.length!==he.length||he.some((Me,Ce)=>Me!==pe[Ce]||D[me]&&D[me].hasOwnProperty(Me.key))){ae=-1;break}++ae}for(const me in x.proxyCachedFBO[V.key])x.renderCache[x.proxyCachedFBO[V.key][me]].dirty=ae<0||ae!==Object.values(X).length}}const R=[...this._drapedRenderBatches];R.sort((z,V)=>V.end-V.start-(z.end-z.start));for(const z of R)for(const V of T){if(x.proxyCachedFBO[V.key])continue;let X=x.renderCachePool.pop();X===void 0&&x.renderCache.length<50&&(X=x.renderCache.length,x.renderCache.push(this._createFBO())),X!==void 0&&(x.proxyCachedFBO[V.key]={},x.proxyCachedFBO[V.key][z.start]=X,x.renderCache[X].dirty=!0)}this._tilesDirty={}}_setupStencil(h,x,T,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const R=this.painter.context,z=R.gl;if(x.length<=1)return void(this._overlapStencilType=!1);let V;if(T.isTileClipped())V=x.length,this._overlapStencilMode.test={func:z.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(x[0].overscaledZ>x[x.length-1].overscaledZ))return void(this._overlapStencilType=!1);V=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+V>255&&(R.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=V,this._overlapStencilMode.ref=this._stencilRef,T.isTileClipped()&&this._renderTileClippingMasks(x,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):ln.disabled}_renderTileClippingMasks(h,x){const T=this.painter,D=this.painter.context,R=D.gl;T._tileClippingMaskIDs={},D.setColorMode(En.disabled),D.setDepthMode(Er.disabled);const z=T.getOrCreateProgram("clippingMask");for(const V of h){const X=T._tileClippingMaskIDs[V.key]=--x;z.draw(T,R.TRIANGLES,Er.disabled,new ln({func:R.ALWAYS,mask:0},X,255,R.KEEP,R.KEEP,R.REPLACE),En.disabled,rn.disabled,cb(V.projMatrix),"$clipping",T.tileExtentBuffer,T.quadTriangleIndexBuffer,T.tileExtentSegments)}}pointCoordinate(h){const x=this.painter.transform;if(h.x<0||h.x>x.width||h.y<0||h.y>x.height)return null;const T=[h.x,h.y,1,1];i.aC(T,T,x.pixelMatrixInverse),i.cK(T,T,1/T[3]),T[0]/=x.worldSize,T[1]/=x.worldSize;const D=x._camera.position,R=i.cf(1,x.center.lat),z=[D[0],D[1],D[2]/R,0],V=i.da([],T.slice(0,3),z);i.aw(V,V);const X=this.raycast(z,V,this._exaggeration);return X!==null&&X?(i.bH(z,z,V,X),z[3]=z[2],z[2]*=R,z):null}_setupProxiedCoordsForOrtho(h,x,T){if(h.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(h,x,T);this._findCoveringTileCache[h.id]=this._findCoveringTileCache[h.id]||{};const D=this.proxiedCoords[h.id]=[],R=this.proxyCoords;for(let X=0;Xae.overscaledZ-re.overscaledZ)}_setupProxiedCoordsForImageSource(h,x,T){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],R=this.proxyCoords,z=h.getSource(),V=z.tileID;if(!V)return;const X=new i.P(V.x,V.y)._div(1<(me.min.x=Math.min(me.min.x,he.x-X.x),me.min.y=Math.min(me.min.y,he.y-X.y),me.max.x=Math.max(me.max.x,he.x-X.x),me.max.y=Math.max(me.max.y,he.y-X.y),me),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),ae=(me,he)=>{const pe=me.wrap+me.canonical.x/(1<$e+re.max.x||Me+CeBe+re.max.y};for(let me=0;mez.key===x.tileID.key);if(R)return R}if(x.tileID.key!==h.key){const R=h.canonical.z-x.tileID.canonical.z;let z,V,X;D=i.bC();const re=x.tileID.wrap-h.wrap<0?(z=i.al>>R,V=z*((x.tileID.canonical.x<=me){const he=h.canonical.z-me;x.getSource().reparseOverscaled?(V=Math.max(h.canonical.z+2,x.transform.tileZoom),z=new i.aQ(V,h.wrap,me,h.canonical.x>>he,h.canonical.y>>he)):he!==0&&(V=me,z=new i.aQ(V,h.wrap,me,h.canonical.x>>he,h.canonical.y>>he))}z.key!==h.key&&(re.push(z.key),T=x.getTile(z))}const ae=me=>{re.forEach(he=>{D[he]=me}),re.length=0};for(V-=1;V>=X&&(!T||!T.hasData());V--){T&&ae(T.tileID.key);const me=z.calculateScaledKey(V);if(T=x.getTileByID(me),T&&T.hasData())break;const he=D[me];if(he===null)break;he===void 0?re.push(me):T=x.getTileByID(he)}return ae(T?T.tileID.key:null),T&&T.hasData()?T:null}findDEMTileFor(h){return this.enabled?this._findTileCoveringTileID(h,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(h,x){let T=this._tilesDirty[h];T||(T=this._tilesDirty[h]={}),T[x.key]=!0}}function fv(C,h,x){const T=function(V,X,re){const ae=i.bJ(X,V),me=i.bJ(re,[.2126,.7152,.0722]),he=(Me,Ce,$e)=>(1-$e)*Me+$e*Ce,pe=he(1-.3*Math.min(me,1),1,Math.min(ae+1,1));return he(.92,1,Math.asin(i.aA(X[2],-1,1))/Math.PI+.5)*pe}(C,[0,0,1],h),D=[0,0,0];i.c5(D,x.slice(0,3),T);const R=[0,0,0];i.c5(R,h.slice(0,3),C[2]);const z=[0,0,0];return i.d8(z,D,R),i.db(z)}const Dce=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Oce=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class lD{static cacheKey(h,x,T,D){const R=[x];D&&R.push(D.cacheKey);for(const z of T)h.usedDefines.has(z)&&R.push(z);return R.join("/")}constructor(h,x,T,D,R,z){const V=h.gl;this.program=V.createProgram(),this.configuration=D,this.name=x,this.fixedDefines=[...z];const X=`#version 300 es ${(D?D.defines():[]).concat(z.map(Ce=>`#define ${Ce}`)).join(` `)}`,re=[X,Sce];for(const Ce of T.fragmentIncludes)re.push(sx[Ce]);re.push(T.fragmentSource);const ae=re.join(` `),me=[X,QL];for(const Ce of T.vertexIncludes)me.push(sx[Ce]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&T.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&me.push("uniform int u_instanceID;"),me.push(T.vertexSource);let he=me.join(` `);this.forceManualRenderingForInstanceIDShaders&&(he=he.replaceAll("gl_InstanceID","u_instanceID"));const pe=V.createShader(V.FRAGMENT_SHADER);if(V.isContextLost())return void(this.failedToCreate=!0);V.shaderSource(pe,ae),V.compileShader(pe),V.attachShader(this.program,pe);const Me=V.createShader(V.VERTEX_SHADER);V.isContextLost()?this.failedToCreate=!0:(V.shaderSource(Me,he),V.compileShader(Me),V.attachShader(this.program,Me),this.attributes={},V.linkProgram(this.program),V.deleteShader(Me),V.deleteShader(pe),this.fixedUniforms=R(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Ce=>({u_instanceID:new i.ch(Ce)}))(h)),(z.includes("TERRAIN")||x.includes("symbol")||x.includes("circle"))&&(this.terrainUniforms=(Ce=>({u_dem:new i.ch(Ce),u_dem_prev:new i.ch(Ce),u_dem_tl:new i.ck(Ce),u_dem_scale:new i.cj(Ce),u_dem_tl_prev:new i.ck(Ce),u_dem_scale_prev:new i.cj(Ce),u_dem_size:new i.cj(Ce),u_dem_lerp:new i.cj(Ce),u_exaggeration:new i.cj(Ce),u_depth:new i.ch(Ce),u_depth_size_inv:new i.ck(Ce),u_depth_range_unpack:new i.ck(Ce),u_occluder_half_size:new i.cj(Ce),u_occlusion_depth_offset:new i.cj(Ce),u_meter_to_dem:new i.cj(Ce),u_label_plane_matrix_inv:new i.cl(Ce)}))(h)),z.includes("GLOBE")&&(this.globeUniforms=(Ce=>({u_tile_tl_up:new i.ci(Ce),u_tile_tr_up:new i.ci(Ce),u_tile_br_up:new i.ci(Ce),u_tile_bl_up:new i.ci(Ce),u_tile_up_scale:new i.cj(Ce)}))(h)),z.includes("FOG")&&(this.fogUniforms=(Ce=>({u_fog_matrix:new i.cl(Ce),u_fog_range:new i.ck(Ce),u_fog_color:new i.d3(Ce),u_fog_horizon_blend:new i.cj(Ce),u_fog_vertical_limit:new i.ck(Ce),u_fog_temporal_offset:new i.cj(Ce),u_frustum_tl:new i.ci(Ce),u_frustum_tr:new i.ci(Ce),u_frustum_br:new i.ci(Ce),u_frustum_bl:new i.ci(Ce),u_globe_pos:new i.ci(Ce),u_globe_radius:new i.cj(Ce),u_globe_transition:new i.cj(Ce),u_is_globe:new i.ch(Ce),u_viewport:new i.ck(Ce)}))(h)),z.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Ce=>({u_cutoff_params:new i.d3(Ce)}))(h)),z.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Ce=>({u_lighting_ambient_color:new i.ci(Ce),u_lighting_directional_dir:new i.ci(Ce),u_lighting_directional_color:new i.ci(Ce),u_ground_radiance:new i.ci(Ce)}))(h)),z.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Ce=>({u_light_matrix_0:new i.cl(Ce),u_light_matrix_1:new i.cl(Ce),u_fade_range:new i.ck(Ce),u_shadow_normal_offset:new i.ci(Ce),u_shadow_intensity:new i.cj(Ce),u_shadow_texel_size:new i.cj(Ce),u_shadow_map_resolution:new i.cj(Ce),u_shadow_direction:new i.ci(Ce),u_shadow_bias:new i.ci(Ce),u_shadowmap_0:new i.ch(Ce),u_shadowmap_1:new i.ch(Ce)}))(h)))}getAttributeLocation(h,x){let T=this.attributes[x];return T===void 0&&(T=this.attributes[x]=h.getAttribLocation(this.program,x)),T}setTerrainUniformValues(h,x){if(!this.terrainUniforms)return;const T=this.terrainUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D]&&T[D].set(this.program,D,x[D])}}setGlobeUniformValues(h,x){if(!this.globeUniforms)return;const T=this.globeUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D]&&T[D].set(this.program,D,x[D])}}setFogUniformValues(h,x){if(!this.fogUniforms)return;const T=this.fogUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D].set(this.program,D,x[D])}}setCutoffUniformValues(h,x){if(!this.cutoffUniforms)return;const T=this.cutoffUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D].set(this.program,D,x[D])}}setLightsUniformValues(h,x){if(!this.lightsUniforms)return;const T=this.lightsUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D].set(this.program,D,x[D])}}setShadowUniformValues(h,x){if(this.failedToCreate||!this.shadowUniforms)return;const T=this.shadowUniforms;h.program.set(this.program);for(const D in x)T[D].set(this.program,D,x[D])}_drawDebugWireframe(h,x,T,D,R,z,V,X,re,ae){const me=h.options.wireframe;if(me.terrain===!1&&me.layers2D===!1&&me.layers3D===!1)return;const he=h.context;if(!(!(!me.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!me.layers2D||h._terrain&&h._terrain.renderingToTexture||!Dce.includes(this.name))||!(!me.layers3D||!Oce.includes(this.name))))return;const pe=he.gl,Me=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,R,he);if(!Me)return;const Ce=[...this.fixedDefines,"DEBUG_WIREFRAME"],$e=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Ce});he.program.set($e.program);const Be=(et,Ct,vt)=>{if(Ct[et]&&vt[et])for(const jt in Ct[et])vt[et][jt]&&vt[et][jt].set(vt.program,jt,Ct[et][jt].current)};re&&re.setUniforms($e.program,he,$e.binderUniforms,V,{zoom:X}),Be("fixedUniforms",this,$e),Be("terrainUniforms",this,$e),Be("globeUniforms",this,$e),Be("fogUniforms",this,$e),Be("lightsUniforms",this,$e),Be("shadowUniforms",this,$e),Me.bind(),he.setColorMode(new En([pe.ONE,pe.ONE_MINUS_SRC_ALPHA,pe.ZERO,pe.ONE],i.ao.transparent,[!0,!0,!0,!1])),he.setDepthMode(new Er(x.func===pe.LESS?pe.LEQUAL:x.func,Er.ReadOnly,x.range)),he.setStencilMode(ln.disabled);const Xe=3*z.primitiveLength*2,ot=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const et=ae||1;for(let Ct=0;Ct1?pe.drawElementsInstanced(pe.LINES,Xe,pe.UNSIGNED_SHORT,ot,ae):pe.drawElements(pe.LINES,Xe,pe.UNSIGNED_SHORT,ot);R.bind(),he.program.set(this.program),he.setDepthMode(x),he.setStencilMode(T),he.setColorMode(D)}checkUniforms(h,x,T){if(this.fixedDefines.includes(x)){for(const D of Object.keys(T))if(!T[D].initialized)throw new Error(`Program '${this.name}', from draw '${h}': uniform ${D} not set but required by ${x} being defined`)}}draw(h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e){const Be=h.context,Xe=Be.gl;if(this.failedToCreate)return;Be.program.set(this.program),Be.setDepthMode(T),Be.setStencilMode(D),Be.setColorMode(R),Be.setCullFace(z);for(const[xt,pt]of this.fixedUniformsEntries)pt.set(this.program,xt,V[xt]);Me&&Me.setUniforms(this.program,Be,this.binderUniforms,he,{zoom:pe});const ot={[Xe.POINTS]:1,[Xe.LINES]:2,[Xe.TRIANGLES]:3,[Xe.LINE_STRIP]:1}[x];this.checkUniforms(X,"RENDER_SHADOWS",this.shadowUniforms);const et=Ce||[],Ct=Me?Me.getPaintVertexBuffers():[],vt=x===Xe.TRIANGLES&&ae,jt=$e&&$e>0?1:void 0;for(const xt of me.get()){const pt=xt.vaos||(xt.vaos={});if((pt[X]||(pt[X]=new Cce)).bind(Be,this,re,Ct,ae,xt.vertexOffset,et,jt),this.forceManualRenderingForInstanceIDShaders){const Et=$e||1;for(let Ht=0;Ht1?Xe.drawElementsInstanced(x,xt.primitiveLength*ot,Xe.UNSIGNED_SHORT,xt.primitiveOffset*ot*2,$e):ae?Xe.drawElements(x,xt.primitiveLength*ot,Xe.UNSIGNED_SHORT,xt.primitiveOffset*ot*2):Xe.drawArrays(x,xt.vertexOffset,xt.vertexLength);vt&&this._drawDebugWireframe(h,T,D,R,ae,xt,he,pe,Me,$e)}}}function cD(C,h,x=0){const T=Math.pow(2,h.tileID.overscaledZ),D=h.tileSize*Math.pow(2,C.transform.tileZoom)/T,R=D*(h.tileID.canonical.x+h.tileID.wrap*T),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,C.transform.tileZoom),u_pixel_coord_upper:[R>>16,z>>16],u_pixel_coord_lower:[65535&R,65535&z],u_pattern_transition:x}}const ES={terrain:0,flat:1},Rce=i.bC(),PS=(C,h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e,Be)=>{const Xe=h.style.light,ot=Xe.properties.get("position"),et=[ot.x,ot.y,ot.z],Ct=i.dO();Xe.properties.get("anchor")==="viewport"&&(i.dP(Ct,-h.transform.angle),i.dQ(et,et,Ct));const vt=Xe.properties.get("color").toPremultipliedRenderColor(null),jt=h.transform,xt={u_matrix:C,u_lightpos:et,u_lightintensity:Xe.properties.get("intensity"),u_lightcolor:[vt.r,vt.g,vt.b],u_vertical_gradient:+x,u_opacity:T,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Rce,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:ES[re],u_base_type:ES[ae],u_ao:D,u_edge_radius:R,u_width_scale:z,u_flood_light_color:Me,u_vertical_scale:Ce,u_flood_light_intensity:$e,u_ground_shadow_factor:Be};return jt.projection.name==="globe"&&(xt.u_tile_id=[V.canonical.x,V.canonical.y,1<({u_matrix:C,u_edge_radius:h,u_width_scale:x,u_vertical_scale:T,u_height_type:ES[D],u_base_type:ES[R]}),dD=(C,h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e,Be)=>{const Xe=PS(C,h,x,T,D,R,z,V,re,ae,me,he,pe,Me,Ce,$e,1,[0,0,0]),ot={u_height_factor:-Math.pow(2,V.overscaledZ)/X.tileSize/8};return Object.assign(Xe,cD(h,X,Be),ot)},gv=(C,h,x,T,D,R,z,V,X,re,ae)=>({u_matrix:h,u_opacity:x,u_ao_pass:T?1:0,u_meter_to_tile:D,u_ao:R,u_flood_light_intensity:z,u_flood_light_color:V,u_attenuation:X,u_edge_radius:re,u_fb:0,u_fb_size:ae,u_dynamic_offset:1}),oT=(C,h,x)=>({u_matrix:C,u_emissive_strength:h,u_ground_shadow_factor:x}),lT=(C,h,x,T,D,R=0)=>Object.assign(oT(C,h,D),cD(x,T,R)),uD=(C,h,x,T)=>({u_matrix:C,u_world:x,u_emissive_strength:h,u_ground_shadow_factor:T}),cT=(C,h,x,T,D,R,z=0)=>Object.assign(lT(C,h,x,T,R,z),{u_world:D}),nx=(C,h)=>({u_matrix:C,u_ground_shadow_factor:h}),wy=(C,h,x,T,D)=>({u_matrix:C,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:x,u_height_scale:T,u_reset_depth:D}),IS=(C,h,x,T,D,R,z,V,X)=>({u_matrix:C,u_normal_matrix:h,u_opacity:x,u_faux_facade_ao_intensity:T,u_camera_pos:D,u_tile_to_meter:R,u_facade_emissive_chance:z,u_flood_light_color:V,u_flood_light_intensity:X}),hD=C=>({u_matrix:C}),ax=C=>({u_matrix:C}),dT=(C,h,x,T,D,R,z,V)=>{const X=i.al/R.tileSize;return{u_matrix:C,u_inv_rot_matrix:h,u_camera_to_center_distance:x.getCameraToCenterDistance(V),u_extrude_scale:[x.pixelsToGLUnits[0]/X,x.pixelsToGLUnits[1]/X],u_zoom_transition:T,u_tile_id:z,u_merc_center:D}},ub=(C,h,x=1)=>({u_matrix:C,u_color:h,u_overlay:0,u_overlay_scale:x}),mD=i.bC(),pD=(C,h,x,T,D,R,z)=>{const V=C.transform,X=V.projection.name==="globe",re=X?i.dR(V.zoom,h.canonical)*V._pixelsPerMercatorPixel:i.ay(x,1,R),ae={u_matrix:h.projMatrix,u_extrude_scale:re,u_intensity:z,u_inv_rot_matrix:mD,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(X){ae.u_inv_rot_matrix=T,ae.u_merc_center=D,ae.u_tile_id=[h.canonical.x,h.canonical.y,1<({u_matrix:C,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:T,u_grid_matrix:D,u_tl_parent:R,u_scale_parent:re,u_fade_t:ae.mix,u_opacity:ae.opacity*me.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:me.paint.get("raster-brightness-min"),u_brightness_high:me.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(me.paint.get("raster-saturation")),u_contrast_factor:i.dS(me.paint.get("raster-contrast")),u_spin_weights:gD(me.paint.get("raster-hue-rotate")),u_perspective_transform:he,u_raster_elevation:pe,u_zoom_transition:z,u_merc_center:V,u_cutoff_params:X,u_colorization_mix:LS(i.dU,Ce,Be),u_colorization_offset:DS(i.dU,$e,Be),u_color_ramp:Me,u_texture_offset:[ot/(Xe+2*ot),Xe/(Xe+2*ot)],u_texture_res:[Xe+2*ot,Xe+2*ot],u_emissive_strength:et});function gD(C){C*=Math.PI/180;const h=Math.sin(C),x=Math.cos(C);return[(2*x+1)/3,(-Math.sqrt(3)*h-x+1)/3,(Math.sqrt(3)*h-x+1)/3]}const Ep=.05,Fce=(C,h,x,T,D,R,z,V,X,re,ae,me)=>({u_matrix:C,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:T,u_grid_matrix:D,u_tl_parent:R,u_scale_parent:re,u_fade_t:ae.mix,u_opacity:ae.opacity,u_image0:0,u_image1:1,u_raster_elevation:me,u_zoom_transition:z,u_merc_center:V,u_cutoff_params:X}),zce=(C,h,x,T,D,R,z,V,X,re)=>({u_particle_texture:C,u_particle_texture_side_len:h,u_tile_offset:x,u_velocity:T,u_color_ramp:R,u_velocity_res:D,u_max_speed:z,u_uv_offset:V,u_data_scale:[255*X[0],255*X[1]],u_data_offset:re,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ep,Ep]}),xD=(C,h,x,T,D,R,z,V,X,re)=>({u_particle_texture:C,u_particle_texture_side_len:h,u_velocity:x,u_velocity_res:T,u_max_speed:D,u_speed_factor:R,u_reset_rate:z,u_rand_seed:Math.random(),u_uv_offset:V,u_data_scale:[255*X[0],255*X[1]],u_data_offset:re,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ep,Ep]}),yD=i.bC(),OS=(C,h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e,Be,Xe,ot,et,Ct,vt,jt)=>{const xt=D.transform,pt={u_is_size_zoom_constant:+(C==="constant"||C==="source"),u_is_size_feature_constant:+(C==="constant"||C==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:xt.getCameraToCenterDistance(Xe),u_rotate_symbol:+x,u_aspect_ratio:xt.width/xt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:R,u_label_plane_matrix:z,u_coord_matrix:V,u_is_text:+re,u_elevation_from_sea:X?1:0,u_pitch_with_map:+T,u_texsize:ae,u_texsize_icon:me,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:yD,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:yD,u_up_vector:[0,-1,0],u_color_adj_mat:Ct,u_icon_transition:vt||0,u_gamma_scale:T?D.transform.getCameraToCenterDistance(Xe)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:jt||1,u_ground_shadow_factor:ot,u_inv_matrix:i.bl(i.bC(),z),u_normal_scale:et,u_lutTexture:gc.LUT};return Xe.name==="globe"&&(pt.u_tile_id=[pe.canonical.x,pe.canonical.y,1<({u_matrix:C,u_emissive_strength:h,u_opacity:x,u_color:T}),ix=(C,h,x,T,D,R,z,V,X)=>Object.assign(function(re,ae,me,he,pe,Me){const{width:Ce,height:$e}=he.imageManager.getPixelSize(ae),Be=Math.pow(2,Me.tileID.overscaledZ),Xe=Me.tileSize*Math.pow(2,he.transform.tileZoom)/Be,ot=Xe*(Me.tileID.canonical.x+Me.tileID.wrap*Be),et=Xe*Me.tileID.canonical.y;return{u_image:0,u_pattern_tl:me.tl,u_pattern_br:me.br,u_texsize:[Ce,$e],u_pattern_size:me.displaySize,u_pattern_units_to_pixels:pe?[he.transform.width,-1*he.transform.height]:[1/i.ay(Me,1,he.transform.tileZoom),1/i.ay(Me,1,he.transform.tileZoom)],u_pixel_coord_upper:[ot>>16,et>>16],u_pixel_coord_lower:[65535&ot,65535&et]}}(0,R,z,T,V,X),{u_matrix:C,u_emissive_strength:h,u_opacity:x}),xv=new Float32Array(i.bA([])),jy=(C,h,x,T,D,R,z,V,X,re,ae,me,he,pe=[0,0,0],Me,Ce,$e)=>{const Be=D.style.light,Xe=Be.properties.get("position"),ot=[-Xe.x,-Xe.y,Xe.z],et=i.dO();Be.properties.get("anchor")==="viewport"&&(i.dP(et,-D.transform.angle),i.dQ(ot,ot,et));const Ct=ae.alphaMode==="MASK",vt=Be.properties.get("color").toNonPremultipliedRenderColor(null),jt=he.paint.get("model-ambient-occlusion-intensity"),xt=he.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return xt.a=he.paint.get("model-color-mix-intensity").constantOr(0),$e&&(xt.r=$e[0],xt.g=$e[1],xt.b=$e[2],xt.a=$e[3]),Ce&&(xt.r=Ce.color.r,xt.g=Ce.color.g,xt.b=Ce.color.b,xt.a=Ce.colorMix,me=Ce.emissionStrength,R*=Ce.opacity),{u_matrix:C,u_lighting_matrix:h,u_normal_matrix:x,u_node_matrix:T||xv,u_lightpos:ot,u_lightintensity:Be.properties.get("intensity"),u_lightcolor:[vt.r,vt.g,vt.b],u_camera_pos:pe,u_opacity:R,u_baseTextureIsAlpha:0,u_alphaMask:+Ct,u_alphaCutoff:ae.alphaCutoff,u_baseColorFactor:z.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:V.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:X,u_roughnessFactor:re,u_baseColorTexture:gc.BaseColor,u_metallicRoughnessTexture:gc.MetallicRoughness,u_normalTexture:gc.Normal,u_occlusionTexture:gc.Occlusion,u_emissionTexture:gc.Emission,u_lutTexture:gc.LUT,u_color_mix:xt.toArray01(),u_aoIntensity:jt,u_emissive_strength:me,u_occlusionTextureTransform:Me||[0,0,0,0]}},uT=(C,h=xv,x=xv)=>({u_matrix:C,u_instance:h,u_node_matrix:x}),RS={fillExtrusion:C=>({u_matrix:new i.cl(C),u_lightpos:new i.ci(C),u_lightintensity:new i.cj(C),u_lightcolor:new i.ci(C),u_vertical_gradient:new i.cj(C),u_opacity:new i.cj(C),u_edge_radius:new i.cj(C),u_width_scale:new i.cj(C),u_ao:new i.ck(C),u_height_type:new i.ch(C),u_base_type:new i.ch(C),u_tile_id:new i.ci(C),u_zoom_transition:new i.cj(C),u_inv_rot_matrix:new i.cl(C),u_merc_center:new i.ck(C),u_up_dir:new i.ci(C),u_height_lift:new i.cj(C),u_flood_light_color:new i.ci(C),u_vertical_scale:new i.cj(C),u_flood_light_intensity:new i.cj(C),u_ground_shadow_factor:new i.ci(C)}),fillExtrusionDepth:C=>({u_matrix:new i.cl(C),u_edge_radius:new i.cj(C),u_width_scale:new i.cj(C),u_vertical_scale:new i.cj(C),u_height_type:new i.ch(C),u_base_type:new i.ch(C)}),fillExtrusionPattern:C=>({u_matrix:new i.cl(C),u_lightpos:new i.ci(C),u_lightintensity:new i.cj(C),u_lightcolor:new i.ci(C),u_vertical_gradient:new i.cj(C),u_height_factor:new i.cj(C),u_edge_radius:new i.cj(C),u_width_scale:new i.cj(C),u_ao:new i.ck(C),u_height_type:new i.ch(C),u_base_type:new i.ch(C),u_tile_id:new i.ci(C),u_zoom_transition:new i.cj(C),u_inv_rot_matrix:new i.cl(C),u_merc_center:new i.ck(C),u_up_dir:new i.ci(C),u_height_lift:new i.cj(C),u_image:new i.ch(C),u_texsize:new i.ck(C),u_pixel_coord_upper:new i.ck(C),u_pixel_coord_lower:new i.ck(C),u_tile_units_to_pixels:new i.cj(C),u_opacity:new i.cj(C),u_pattern_transition:new i.cj(C)}),fillExtrusionGroundEffect:C=>({u_matrix:new i.cl(C),u_opacity:new i.cj(C),u_ao_pass:new i.cj(C),u_meter_to_tile:new i.cj(C),u_ao:new i.ck(C),u_flood_light_intensity:new i.cj(C),u_flood_light_color:new i.ci(C),u_attenuation:new i.cj(C),u_edge_radius:new i.cj(C),u_fb:new i.ch(C),u_fb_size:new i.cj(C),u_dynamic_offset:new i.cj(C)}),fill:C=>({u_matrix:new i.cl(C),u_emissive_strength:new i.cj(C),u_ground_shadow_factor:new i.ci(C)}),fillPattern:C=>({u_matrix:new i.cl(C),u_emissive_strength:new i.cj(C),u_image:new i.ch(C),u_texsize:new i.ck(C),u_pixel_coord_upper:new i.ck(C),u_pixel_coord_lower:new i.ck(C),u_tile_units_to_pixels:new i.cj(C),u_ground_shadow_factor:new i.ci(C),u_pattern_transition:new i.cj(C)}),fillOutline:C=>({u_matrix:new i.cl(C),u_emissive_strength:new i.cj(C),u_world:new i.ck(C),u_ground_shadow_factor:new i.ci(C)}),fillOutlinePattern:C=>({u_matrix:new i.cl(C),u_emissive_strength:new i.cj(C),u_world:new i.ck(C),u_image:new i.ch(C),u_texsize:new i.ck(C),u_pixel_coord_upper:new i.ck(C),u_pixel_coord_lower:new i.ck(C),u_tile_units_to_pixels:new i.cj(C),u_ground_shadow_factor:new i.ci(C),u_pattern_transition:new i.cj(C)}),building:C=>({u_matrix:new i.cl(C),u_normal_matrix:new i.cl(C),u_opacity:new i.cj(C),u_faux_facade_ao_intensity:new i.cj(C),u_camera_pos:new i.ci(C),u_tile_to_meter:new i.cj(C),u_facade_emissive_chance:new i.cj(C),u_flood_light_color:new i.ci(C),u_flood_light_intensity:new i.cj(C)}),buildingBloom:C=>({u_matrix:new i.cl(C)}),buildingDepth:C=>({u_matrix:new i.cl(C)}),elevatedStructuresDepth:C=>({u_matrix:new i.cl(C),u_depth_bias:new i.cj(C)}),elevatedStructures:C=>({u_matrix:new i.cl(C),u_ground_shadow_factor:new i.ci(C)}),elevatedStructuresDepthReconstruct:C=>({u_matrix:new i.cl(C),u_camera_pos:new i.ci(C),u_depth_bias:new i.cj(C),u_height_scale:new i.cj(C),u_reset_depth:new i.cj(C)}),circle:i.dY,collisionBox:C=>({u_matrix:new i.cl(C),u_inv_rot_matrix:new i.cl(C),u_camera_to_center_distance:new i.cj(C),u_extrude_scale:new i.ck(C),u_zoom_transition:new i.cj(C),u_merc_center:new i.ck(C),u_tile_id:new i.ci(C)}),collisionCircle:C=>({u_matrix:new i.cl(C),u_inv_matrix:new i.cl(C),u_camera_to_center_distance:new i.cj(C),u_viewport_size:new i.ck(C)}),debug:C=>({u_color:new i.dB(C),u_matrix:new i.cl(C),u_overlay:new i.ch(C),u_overlay_scale:new i.cj(C)}),clippingMask:C=>({u_matrix:new i.cl(C)}),heatmap:C=>({u_extrude_scale:new i.cj(C),u_intensity:new i.cj(C),u_matrix:new i.cl(C),u_inv_rot_matrix:new i.cl(C),u_merc_center:new i.ck(C),u_tile_id:new i.ci(C),u_zoom_transition:new i.cj(C),u_up_dir:new i.ci(C)}),heatmapTexture:C=>({u_image:new i.ch(C),u_color_ramp:new i.ch(C),u_opacity:new i.cj(C)}),hillshade:C=>({u_matrix:new i.cl(C),u_image:new i.ch(C),u_latrange:new i.ck(C),u_light:new i.ck(C),u_shadow:new i.dB(C),u_highlight:new i.dB(C),u_emissive_strength:new i.cj(C),u_accent:new i.dB(C)}),hillshadePrepare:C=>({u_matrix:new i.cl(C),u_image:new i.ch(C),u_dimension:new i.ck(C),u_zoom:new i.cj(C)}),line:i.dX,linePattern:i.dW,raster:C=>({u_matrix:new i.cl(C),u_normalize_matrix:new i.cl(C),u_globe_matrix:new i.cl(C),u_merc_matrix:new i.cl(C),u_grid_matrix:new i.dC(C),u_tl_parent:new i.ck(C),u_scale_parent:new i.cj(C),u_fade_t:new i.cj(C),u_opacity:new i.cj(C),u_image0:new i.ch(C),u_image1:new i.ch(C),u_brightness_low:new i.cj(C),u_brightness_high:new i.cj(C),u_saturation_factor:new i.cj(C),u_contrast_factor:new i.cj(C),u_spin_weights:new i.ci(C),u_perspective_transform:new i.ck(C),u_raster_elevation:new i.cj(C),u_zoom_transition:new i.cj(C),u_merc_center:new i.ck(C),u_cutoff_params:new i.d3(C),u_colorization_mix:new i.d3(C),u_colorization_offset:new i.cj(C),u_color_ramp:new i.ch(C),u_texture_offset:new i.ck(C),u_texture_res:new i.ck(C),u_emissive_strength:new i.cj(C)}),rasterParticle:C=>({u_matrix:new i.cl(C),u_normalize_matrix:new i.cl(C),u_globe_matrix:new i.cl(C),u_merc_matrix:new i.cl(C),u_grid_matrix:new i.dC(C),u_tl_parent:new i.ck(C),u_scale_parent:new i.cj(C),u_fade_t:new i.cj(C),u_opacity:new i.cj(C),u_image0:new i.ch(C),u_image1:new i.ch(C),u_raster_elevation:new i.cj(C),u_zoom_transition:new i.cj(C),u_merc_center:new i.ck(C),u_cutoff_params:new i.d3(C)}),rasterParticleTexture:C=>({u_texture:new i.ch(C),u_opacity:new i.cj(C)}),rasterParticleDraw:C=>({u_particle_texture:new i.ch(C),u_particle_texture_side_len:new i.cj(C),u_tile_offset:new i.ck(C),u_velocity:new i.ch(C),u_color_ramp:new i.ch(C),u_velocity_res:new i.ck(C),u_max_speed:new i.cj(C),u_uv_offset:new i.ck(C),u_data_scale:new i.ck(C),u_data_offset:new i.cj(C),u_particle_pos_scale:new i.cj(C),u_particle_pos_offset:new i.ck(C)}),rasterParticleUpdate:C=>({u_particle_texture:new i.ch(C),u_particle_texture_side_len:new i.cj(C),u_velocity:new i.ch(C),u_velocity_res:new i.ck(C),u_max_speed:new i.cj(C),u_speed_factor:new i.cj(C),u_reset_rate:new i.cj(C),u_rand_seed:new i.cj(C),u_uv_offset:new i.ck(C),u_data_scale:new i.ck(C),u_data_offset:new i.cj(C),u_particle_pos_scale:new i.cj(C),u_particle_pos_offset:new i.ck(C)}),symbol:C=>({u_is_size_zoom_constant:new i.ch(C),u_is_size_feature_constant:new i.ch(C),u_size_t:new i.cj(C),u_size:new i.cj(C),u_camera_to_center_distance:new i.cj(C),u_rotate_symbol:new i.ch(C),u_aspect_ratio:new i.cj(C),u_fade_change:new i.cj(C),u_matrix:new i.cl(C),u_label_plane_matrix:new i.cl(C),u_coord_matrix:new i.cl(C),u_is_text:new i.ch(C),u_elevation_from_sea:new i.ch(C),u_pitch_with_map:new i.ch(C),u_texsize:new i.ck(C),u_texsize_icon:new i.ck(C),u_texture:new i.ch(C),u_texture_icon:new i.ch(C),u_gamma_scale:new i.cj(C),u_device_pixel_ratio:new i.cj(C),u_tile_id:new i.ci(C),u_zoom_transition:new i.cj(C),u_inv_rot_matrix:new i.cl(C),u_merc_center:new i.ck(C),u_camera_forward:new i.ci(C),u_tile_matrix:new i.cl(C),u_up_vector:new i.ci(C),u_ecef_origin:new i.ci(C),u_is_halo:new i.ch(C),u_icon_transition:new i.cj(C),u_color_adj_mat:new i.cl(C),u_scale_factor:new i.cj(C),u_ground_shadow_factor:new i.ci(C),u_inv_matrix:new i.cl(C),u_normal_scale:new i.cj(C),u_lutTexture:new i.ch(C)}),background:C=>({u_matrix:new i.cl(C),u_emissive_strength:new i.cj(C),u_opacity:new i.cj(C),u_color:new i.dB(C)}),backgroundPattern:C=>({u_matrix:new i.cl(C),u_emissive_strength:new i.cj(C),u_opacity:new i.cj(C),u_image:new i.ch(C),u_pattern_tl:new i.ck(C),u_pattern_br:new i.ck(C),u_texsize:new i.ck(C),u_pattern_size:new i.ck(C),u_pixel_coord_upper:new i.ck(C),u_pixel_coord_lower:new i.ck(C),u_pattern_units_to_pixels:new i.ck(C)}),terrainRaster:C=>({u_matrix:new i.cl(C),u_image0:new i.ch(C),u_image1:new i.ch(C),u_skirt_height:new i.cj(C),u_ground_shadow_factor:new i.ci(C),u_emissive_texture_available:new i.cj(C)}),skybox:C=>({u_matrix:new i.cl(C),u_sun_direction:new i.ci(C),u_cubemap:new i.ch(C),u_opacity:new i.cj(C),u_temporal_offset:new i.cj(C)}),skyboxGradient:C=>({u_matrix:new i.cl(C),u_color_ramp:new i.ch(C),u_center_direction:new i.ci(C),u_radius:new i.cj(C),u_opacity:new i.cj(C),u_temporal_offset:new i.cj(C)}),skyboxCapture:C=>({u_matrix_3f:new i.dC(C),u_sun_direction:new i.ci(C),u_sun_intensity:new i.cj(C),u_color_tint_r:new i.d3(C),u_color_tint_m:new i.d3(C),u_luminance:new i.cj(C)}),globeRaster:C=>({u_proj_matrix:new i.cl(C),u_globe_matrix:new i.cl(C),u_normalize_matrix:new i.cl(C),u_merc_matrix:new i.cl(C),u_zoom_transition:new i.cj(C),u_merc_center:new i.ck(C),u_image0:new i.ch(C),u_image1:new i.ch(C),u_grid_matrix:new i.dC(C),u_skirt_height:new i.cj(C),u_far_z_cutoff:new i.cj(C),u_frustum_tl:new i.ci(C),u_frustum_tr:new i.ci(C),u_frustum_br:new i.ci(C),u_frustum_bl:new i.ci(C),u_globe_pos:new i.ci(C),u_globe_radius:new i.cj(C),u_viewport:new i.ck(C),u_emissive_texture_available:new i.cj(C)}),globeAtmosphere:C=>({u_frustum_tl:new i.ci(C),u_frustum_tr:new i.ci(C),u_frustum_br:new i.ci(C),u_frustum_bl:new i.ci(C),u_horizon:new i.cj(C),u_transition:new i.cj(C),u_fadeout_range:new i.cj(C),u_atmosphere_fog_color:new i.d3(C),u_high_color:new i.d3(C),u_space_color:new i.d3(C),u_temporal_offset:new i.cj(C),u_horizon_angle:new i.cj(C)}),model:C=>({u_matrix:new i.cl(C),u_lighting_matrix:new i.cl(C),u_normal_matrix:new i.cl(C),u_node_matrix:new i.cl(C),u_lightpos:new i.ci(C),u_lightintensity:new i.cj(C),u_lightcolor:new i.ci(C),u_camera_pos:new i.ci(C),u_opacity:new i.cj(C),u_baseColorFactor:new i.d3(C),u_emissiveFactor:new i.d3(C),u_metallicFactor:new i.cj(C),u_roughnessFactor:new i.cj(C),u_baseTextureIsAlpha:new i.ch(C),u_alphaMask:new i.ch(C),u_alphaCutoff:new i.cj(C),u_baseColorTexture:new i.ch(C),u_metallicRoughnessTexture:new i.ch(C),u_normalTexture:new i.ch(C),u_occlusionTexture:new i.ch(C),u_emissionTexture:new i.ch(C),u_lutTexture:new i.ch(C),u_color_mix:new i.d3(C),u_aoIntensity:new i.cj(C),u_emissive_strength:new i.cj(C),u_occlusionTextureTransform:new i.d3(C)}),modelDepth:C=>({u_matrix:new i.cl(C),u_instance:new i.cl(C),u_node_matrix:new i.cl(C)}),groundShadow:C=>({u_matrix:new i.cl(C),u_ground_shadow_factor:new i.ci(C)}),stars:C=>({u_matrix:new i.cl(C),u_up:new i.ci(C),u_right:new i.ci(C),u_intensity_multiplier:new i.cj(C)}),snowParticle:C=>({u_modelview:new i.cl(C),u_projection:new i.cl(C),u_time:new i.cj(C),u_cam_pos:new i.ci(C),u_velocityConeAperture:new i.cj(C),u_velocity:new i.cj(C),u_horizontalOscillationRadius:new i.cj(C),u_horizontalOscillationRate:new i.cj(C),u_boxSize:new i.cj(C),u_billboardSize:new i.cj(C),u_simpleShapeParameters:new i.ck(C),u_screenSize:new i.ck(C),u_thinningCenterPos:new i.ck(C),u_thinningShape:new i.ci(C),u_thinningAffectedRatio:new i.cj(C),u_thinningParticleOffset:new i.cj(C),u_particleColor:new i.d3(C),u_direction:new i.ci(C)}),rainParticle:C=>({u_modelview:new i.cl(C),u_projection:new i.cl(C),u_time:new i.cj(C),u_cam_pos:new i.ci(C),u_texScreen:new i.ch(C),u_velocityConeAperture:new i.cj(C),u_velocity:new i.cj(C),u_boxSize:new i.cj(C),u_rainDropletSize:new i.ck(C),u_distortionStrength:new i.cj(C),u_rainDirection:new i.ci(C),u_color:new i.d3(C),u_screenSize:new i.ck(C),u_thinningCenterPos:new i.ck(C),u_thinningShape:new i.ci(C),u_thinningAffectedRatio:new i.cj(C),u_thinningParticleOffset:new i.cj(C),u_shapeDirectionalPower:new i.cj(C),u_shapeNormalPower:new i.cj(C),u_mode:new i.cj(C)}),vignette:C=>({u_vignetteShape:new i.ci(C),u_vignetteColor:new i.d3(C)}),occlusion:C=>({u_matrix:new i.cl(C),u_anchorPos:new i.ci(C),u_screenSizePx:new i.ck(C),u_occluderSizePx:new i.ck(C),u_color:new i.d3(C)})};class $m{constructor(h,x,T,D){this.id=$m.uniqueIdxCounter,$m.uniqueIdxCounter++,this.context=h;const R=h.gl;this.buffer=R.createBuffer(),this.dynamicDraw=!!T,this.context.unbindVAO(),h.bindElementBuffer.set(this.buffer),R.bufferData(R.ELEMENT_ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?R.DYNAMIC_DRAW:R.STATIC_DRAW),this.dynamicDraw||D||x.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){this.id=$m.uniqueIdxCounter,$m.uniqueIdxCounter++;const x=this.context.gl;this.context.unbindVAO(),this.bind(),x.bufferSubData(x.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}$m.uniqueIdxCounter=0;const hT={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class vD{constructor(h,x,T,D,R,z){this.length=x.length,this.attributes=T,this.itemSize=x.bytesPerElement,this.dynamicDraw=D,this.instanceCount=z,this.context=h;const V=h.gl;this.buffer=V.createBuffer(),h.bindVertexBuffer.set(this.buffer),V.bufferData(V.ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?V.DYNAMIC_DRAW:V.STATIC_DRAW),this.dynamicDraw||R||x.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){const x=this.context.gl;this.bind(),x.bufferSubData(x.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,x){for(let T=0;T0&&h.vertexAttribDivisor(R,T)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class _D{constructor(h,x,T,D,R){this.context=h,this.width=x,this.height=T;const z=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new SS(h,z,0)),D>1&&(this.colorAttachment1=new SS(h,z,1)),R&&(this.depthAttachmentType=R,this.depthAttachment=R==="renderbuffer"?new mv(h,z):new ob(h,z))}createColorAttachment(h,x){x===0?this.colorAttachment0=new SS(h,this.framebuffer,0):x===1&&(this.colorAttachment1=new SS(h,this.framebuffer,1))}removeColorAttachment(h,x){const T=this.context.gl;let D;x===0?(D=this.colorAttachment0.get(),this.colorAttachment0=void 0):x===1&&(D=this.colorAttachment1.get(),this.colorAttachment1=void 0),D&&T.deleteTexture(D)}destroy(){const h=this.context.gl;if(this.colorAttachment0){const x=this.colorAttachment0.get();x&&h.deleteTexture(x)}if(this.colorAttachment1){const x=this.colorAttachment1.get();x&&h.deleteTexture(x)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const x=this.depthAttachment.get();x&&h.deleteRenderbuffer(x)}else{const x=this.depthAttachment.get();x&&h.deleteTexture(x)}h.deleteFramebuffer(this.framebuffer)}}class yv{constructor(h,x){this.gl=h,this.clearColor=new Ece(this),this.clearDepth=new JL(this),this.clearStencil=new KM(this),this.colorMask=new bS(this),this.depthMask=new ZM(this),this.stencilMask=new by(this),this.stencilFunc=new cv(this),this.stencilOp=new ab(this),this.stencilTest=new dv(this),this.depthRange=new eD(this),this.depthTest=new YM(this),this.depthFunc=new tD(this),this.blend=new uv(this),this.blendFunc=new wS(this),this.blendColor=new jS(this),this.blendEquation=new XM(this),this.cullFace=new kS(this),this.cullFaceSide=new ib(this),this.frontFace=new sD(this),this.program=new rD(this),this.activeTexture=new nD(this),this.viewport=new hv(this),this.bindFramebuffer=new aD(this),this.bindRenderbuffer=new Pce(this),this.bindTexture=new Ice(this),this.bindVertexBuffer=new Lce(this),this.bindElementBuffer=new QM(this),this.bindVertexArrayOES=new JM(this),this.pixelStoreUnpack=new eT(this),this.pixelStoreUnpackPremultiplyAlpha=new tT(this),this.pixelStoreUnpackFlipY=new iD(this),this.options=x?Object.assign({},x):{},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=x&&!!x.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,x,T){return new $m(this,h,x,T)}createVertexBuffer(h,x,T,D,R){return new vD(this,h,x,T,D,R)}createRenderbuffer(h,x,T){const D=this.gl,R=D.createRenderbuffer();return this.bindRenderbuffer.set(R),D.renderbufferStorage(D.RENDERBUFFER,h,x,T),this.bindRenderbuffer.set(null),R}createFramebuffer(h,x,T,D){return new _D(this,h,x,T,D)}clear({color:h,depth:x,stencil:T,colorMask:D}){const R=this.gl;let z=0;h&&(z|=R.COLOR_BUFFER_BIT,this.clearColor.set(h.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),x!==void 0&&(z|=R.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(x),this.depthMask.set(!0)),T!==void 0&&(z|=R.STENCIL_BUFFER_BIT,this.clearStencil.set(T),this.stencilMask.set(255)),R.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,En.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 ky;function vr(C,h,x,T,D,R,z){const V=C.context,X=V.gl,re=C.transform,ae=[i.aF(re.center.lng),i.aJ(re.center.lat)],me=x.layout.get("symbol-placement"),he=x.layout.get("text-variable-anchor"),pe=x.layout.get("icon-rotation-alignment")==="map",Me=x.layout.get("text-rotation-alignment")==="map",Ce=me!=="point",$e=[];let Be=0,Xe=0;for(let pt=0;pt0){const or=i.bC(),mr=Ws;i.cP(or,Ut.placementInvProjMatrix,re.glCoordMatrix),i.cP(or,or,Ut.placementViewportMatrix),$e.push({circleArray:kr,circleOffset:Xe,transform:mr,invTransform:or,projection:Ut.getProjection()}),Be+=kr.length/4,Xe=Be}if(!Bs)continue;C.terrain&&C.terrain.setupElevationDraw(Ht,ur);const br=As?[Et.canonical.x,Et.canonical.y,1<=0&&(pe[ot.associatedIconIndex]={x:Ut,y:ts,z:ss,angle:ls})}else Fm(vt,me)}if(re){he.clear();const Xe=C.icon.placedSymbolArray;for(let ot=0;ot{let ja=[0,0,0];if(Xa){const Rn=C.style.directionalLight,zi=C.style.ambientLight;Rn&&zi&&(ja=Pf(C.style,Rn,zi))}return ja},Oa=Xa=>{pt.depthOcclusionForSymbolsAndCircles&&(x.hasOcclusionOpacityProperties||C.terrain)&&(Xa.push("DEPTH_D24"),Xa.push("DEPTH_OCCLUSION"))},vn=Xa=>{x.lut&&!vt&&(x.lut.texture||(x.lut.texture=new i.d$(C.context,x.lut.image,[x.lut.image.height,x.lut.image.height,x.lut.image.height],jt.gl.RGBA8)),jt.activeTexture.set(jt.gl.TEXTURE0+gc.LUT),x.lut.texture&&x.lut.texture.bind(jt.gl.LINEAR,jt.gl.CLAMP_TO_EDGE),Xa.push("APPLY_LUT_ON_GPU"))},Ya=()=>{const Xa=Et&&x.layout.get("symbol-placement")!=="point",ja=[];Oa(ja),vn(ja);const Rn=Xa||jn,zi=Bs.elevationType==="road",Mo=C.shadowRenderer,oo=zi&&Ut&&!!Mo&&Mo.enabled,_i=Tr(oo),Zd=zi&&Ut&&!C.terrain?Xt:zs,Qc=x.paint.get("icon-image-cross-fade");C.terrainRenderModeElevated()&&Ut&&ja.push("PITCH_WITH_MAP_TERRAIN"),kr&&(ja.push("PROJECTION_GLOBE_VIEW"),Rn&&ja.push("PROJECTED_POS_ON_VIEWPORT")),Qc>0&&Bs.hasAnySecondaryIcon&&ja.push("ICON_TRANSITION"),!Bs.icon.zOffsetVertexBuffer||zi&&C.terrain||ja.push("Z_OFFSET"),Be===0&&Xe===0&&ot===0&&et===1||ja.push("COLOR_ADJUSTMENT"),Bs.sdfIcons&&ja.push("RENDER_SDF"),oo&&ja.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),zi&&Ut&&!C.terrain&&Bs.icon.orientationVertexBuffer&&ja.push("ELEVATED_ROADS");const _l=Bs.icon.programConfigurations.get(x.id),ud=C.getOrCreateProgram("symbol",{config:_l,defines:ja}),hd=Ws.imageAtlasTexture?Ws.imageAtlasTexture.size:[0,0],Mc=Bs.iconSizeData,mh=i.bK(Mc,pt.zoom),im=Ut||!pt.isOrthographic,_u=Hs(or,Ws.tileID.canonical,Ut,Et,pt,Bs.getProjection(),mr),bo=on(or,Ws.tileID.canonical,Ut,Et,pt,Bs.getProjection(),mr),Do=C.translatePosMatrix(bo,Ws,V,re,!0),bi=C.translatePosMatrix(or,Ws,V,re),Ho=Rn?mb:_u,fo=Et&&!Ut&&!Xa;let lo=Xs;!es&&!pt.mercatorFromTransition||Et||(lo=Lf(pt));const om=kr?lo:Xs,Sb=x.getColorAdjustmentMatrix(Be,Xe,ot,et),Vm=OS(Mc.kind,mh,fo,Ut,C,bi,Ho,Do,Ct,!1,hd,[0,0],0,ur,br,Dt,da,om,Bs.getProjection(),_i,Va,Sb,Qc,null),Cb=Ws.imageAtlasTexture?Ws.imageAtlasTexture:null,Cv=x.layout.get("icon-size").constantOr(0)!==1||Bs.iconsNeedLinear,Op=Bs.sdfIcons||C.options.rotating||C.options.zooming||Cv||im?xt.LINEAR:xt.NEAREST,Uf=Bs.sdfIcons&&x.paint.get("icon-halo-width").constantOr(1)!==0,Mv=C.terrain&&Ut&&Xa?i.bl(i.bC(),_u):mb;if(Xa&&Bs.icon){const hx=i.bV.getAtTileOffsetFunc(ur,pt.center.lat,pt.worldSize,Bs.getProjection()),Vf=an(or,Ws.tileID.canonical,Ut,Et,pt,Bs.getProjection(),mr),Hm=x.layout.get("icon-size-scale-range"),Hf=i.aA(C.scaleFactor,Hm[0],Hm[1]);Tf(Bs,or,C,!1,Vf,bo,Ut,Ce,hx,ur,Hf)}return{program:ud,buffers:Bs.icon,uniformValues:Vm,atlasTexture:Cb,atlasTextureIcon:null,atlasInterpolation:Op,atlasInterpolationIcon:null,isSDF:Bs.sdfIcons,hasHalo:Uf,depthMode:Zd,tile:Ws,renderWithShadows:oo,labelPlaneMatrixInv:Mv}},ui=()=>{const Xa=Ht&&x.layout.get("symbol-placement")!=="point",ja=[],Rn=Xa||ls||jn,zi=Bs.elevationType==="road",Mo=C.shadowRenderer,oo=zi&&ts&&!!Mo&&Mo.enabled,_i=Tr(oo),Zd=zi&&ts&&!C.terrain?Xt:zs;C.terrainRenderModeElevated()&&ts&&ja.push("PITCH_WITH_MAP_TERRAIN"),kr&&(ja.push("PROJECTION_GLOBE_VIEW"),Rn&&ja.push("PROJECTED_POS_ON_VIEWPORT")),!Bs.text.zOffsetVertexBuffer||zi&&C.terrain||ja.push("Z_OFFSET"),Bs.iconsInText&&ja.push("RENDER_TEXT_AND_SYMBOL"),ja.push("RENDER_SDF"),oo&&ja.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),zi&&ts&&!C.terrain&&Bs.text.orientationVertexBuffer&&ja.push("ELEVATED_ROADS"),Oa(ja);const Qc=Bs.text.programConfigurations.get(x.id),_l=C.getOrCreateProgram("symbol",{config:Qc,defines:ja});let ud,hd=[0,0],Mc=null;const mh=Bs.textSizeData;Bs.iconsInText&&(hd=Ws.imageAtlasTexture?Ws.imageAtlasTexture.size:[0,0],Mc=Ws.imageAtlasTexture?Ws.imageAtlasTexture:null,ud=ts||!pt.isOrthographic||C.options.rotating||C.options.zooming||mh.kind==="composite"||mh.kind==="camera"?xt.LINEAR:xt.NEAREST);const im=Ws.glyphAtlasTexture?Ws.glyphAtlasTexture.size:[0,0],_u=x.layout.get("text-size-scale-range"),bo=i.aA(C.scaleFactor,_u[0],_u[1]),Do=i.bK(mh,pt.zoom,bo),bi=Hs(or,Ws.tileID.canonical,ts,Ht,pt,Bs.getProjection(),mr),Ho=on(or,Ws.tileID.canonical,ts,Ht,pt,Bs.getProjection(),mr),fo=C.translatePosMatrix(Ho,Ws,X,ae,!0),lo=C.translatePosMatrix(or,Ws,X,ae),om=Rn?mb:bi,Sb=Ht&&!ts&&!Xa;let Vm=Xs;!es&&!pt.mercatorFromTransition||Ht||(Vm=Lf(pt));const Cb=OS(mh.kind,Do,Sb,ts,C,lo,om,fo,Ct,!0,im,hd,0,ur,br,Dt,da,kr?Vm:Xs,Bs.getProjection(),_i,Va,null,null,bo),Cv=Ws.glyphAtlasTexture?Ws.glyphAtlasTexture:null,Op=xt.LINEAR,Uf=x.paint.get("text-halo-width").constantOr(1)!==0,Mv=C.terrain&&ts&&Xa?i.bl(i.bC(),bi):mb;if(Xa&&Bs.text){const hx=i.bV.getAtTileOffsetFunc(ur,pt.center.lat,pt.worldSize,Bs.getProjection()),Vf=an(or,Ws.tileID.canonical,ts,Ht,pt,Bs.getProjection(),mr);Tf(Bs,or,C,!0,Vf,Ho,ts,$e,hx,ur,bo)}return{program:_l,buffers:Bs.text,uniformValues:Cb,atlasTexture:Cv,atlasTextureIcon:Mc,atlasInterpolation:Op,atlasInterpolationIcon:ud,isSDF:!0,hasHalo:Uf,depthMode:Zd,tile:Ws,renderWithShadows:oo,labelPlaneMatrixInv:Mv}},ni=Bs.icon.segments.get().length,Ea=Bs.text.segments.get().length,On=ni&&!z.onlyText?Ya():null,Za=Ea&&!z.onlyIcons?ui():null,po=x.paint.get("icon-opacity").constantOr(1),Vi=x.paint.get("text-opacity").constantOr(1);if(ss&&Bs.canOverlap){ps=!0;const Xa=po&&!z.onlyText?Bs.icon.segments.get():[],ja=Vi&&!z.onlyIcons?Bs.text.segments.get():[];for(const Rn of Xa)As.push({segments:new i.bg([Rn]),sortKey:Rn.sortKey,state:On});for(const Rn of ja)As.push({segments:new i.bg([Rn]),sortKey:Rn.sortKey,state:Za})}else z.onlyText||As.push({segments:po?Bs.icon.segments:new i.bg([]),sortKey:0,state:On}),z.onlyIcons||As.push({segments:Vi?Bs.text.segments:new i.bg([]),sortKey:0,state:Za})}ps&&As.sort((ur,Ws)=>ur.sortKey-Ws.sortKey);for(const ur of As){const Ws=ur.state;if(Ws)if(C.terrain?C.terrain.setupElevationDraw(Ws.tile,Ws.program,{useDepthForOcclusion:pt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Ws.labelPlaneMatrixInv}):C.setupDepthForOcclusion(pt.depthOcclusionForSymbolsAndCircles,Ws.program),jt.activeTexture.set(xt.TEXTURE0),Ws.atlasTexture&&Ws.atlasTexture.bind(Ws.atlasInterpolation,xt.CLAMP_TO_EDGE,!0),Ws.atlasTextureIcon&&(jt.activeTexture.set(xt.TEXTURE1),Ws.atlasTextureIcon&&Ws.atlasTextureIcon.bind(Ws.atlasInterpolationIcon,xt.CLAMP_TO_EDGE,!0)),Ws.renderWithShadows&&C.shadowRenderer.setupShadows(Ws.tile.tileID.toUnwrapped(),Ws.program,"vector-tile"),C.uploadCommonLightUniforms(C.context,Ws.program),Ws.hasHalo){const Bs=Ws.uniformValues;Bs.u_is_halo=1,mT(Ws.buffers,ur.segments,x,C,Ws.program,Ws.depthMode,D,R,Bs,2),Bs.u_is_halo=0}else{if(Ws.isSDF){const Bs=Ws.uniformValues;Ws.hasHalo&&(Bs.u_is_halo=1,mT(Ws.buffers,ur.segments,x,C,Ws.program,Ws.depthMode,D,R,Bs,1)),Bs.u_is_halo=0}mT(Ws.buffers,ur.segments,x,C,Ws.program,Ws.depthMode,D,R,Ws.uniformValues,1)}}}function mT(C,h,x,T,D,R,z,V,X,re){const ae=[C.dynamicLayoutVertexBuffer,C.opacityVertexBuffer,C.iconTransitioningVertexBuffer,C.globeExtVertexBuffer,C.zOffsetVertexBuffer,C.orientationVertexBuffer];D.draw(T,T.context.gl.TRIANGLES,R,z,V,rn.disabled,X,x.id,C.layoutVertexBuffer,C.indexBuffer,h,x.paint,T.transform.zoom,C.programConfigurations.get(x.id),ae,re)}function bD(C,h){const x=1<=Bm?1:pe.pitch/Bm))),2*Me}(C.transform),re=C.transform.getFreeCameraOptions().position,ae="elevatedStructuresDepthReconstruct",me=C.getOrCreateProgram(ae,{defines:["DEPTH_RECONSTRUCTION"]}),he=C.getOrCreateProgram(ae);for(const pe of T){const Me=h.getTile(pe),Ce=Me.getBucket(x);if(!Ce)continue;const $e=Ce.elevatedStructures;if(!$e)continue;const Be=Ce.elevationBufferData.heightRange,Xe=bD(pe.toUnwrapped(),re),ot=C.translatePosMatrix(pe.projMatrix,Me,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor"));let et,Ct,vt,jt;if(D==="initialize"){if(!Be||Be.min>=1||$e.depthSegments.segments[0].primitiveLength===0)continue;et=wy(ot,Xe,X,1,0),Ct=z,vt=$e.depthSegments,jt=me}else if(D==="reset"){if(!Be||Be.min>=0||$e.maskSegments.segments[0].primitiveLength===0)continue;et=wy(ot,Xe,0,0,1),Ct=V,vt=$e.maskSegments,jt=me}else if(D==="geometry"){if($e.depthSegments.segments[0].primitiveLength===0)continue;et=wy(ot,Xe,X,1,0),Ct=z,vt=$e.depthSegments,jt=he}jt.draw(C,R.TRIANGLES,Ct,ln.disabled,En.disabled,rn.disabled,et,x.id,$e.vertexBuffer,$e.indexBuffer,vt,x.paint,C.transform.zoom)}}function zS(C,h,x,T){const{painter:D,sourceCache:R,layer:z,coords:V,colorMode:X,elevationType:re,terrainEnabled:ae,pass:me}=C,he=D.context.gl,pe=z.paint.get("fill-pattern"),Me=z.paint.get("fill-pattern-cross-fade"),Ce=pe.constantOr(null);let $e=re;re!=="road"||h&&!ae||($e="none");const Be=$e==="road",Xe=C.painter.shadowRenderer,ot=Be&&!!Xe&&Xe.enabled,et=new Er(D.context.gl.LEQUAL,Er.ReadOnly,D.depthRangeFor3D);let Ct=[0,0,0];if(ot){const pt=D.style.directionalLight,Et=D.style.ambientLight;pt&&Et&&(Ct=Pf(D.style,pt,Et))}const vt=pe&&pe.constantOr(1),jt=D.terrain&&D.terrain.renderingToTexture,xt=(pt,Et)=>{let Ht,Ut,ts,ss,ps;Et?(Ht=vt&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ts=he.LINES):(Ht=vt?"fillPattern":"fill",ts=he.TRIANGLES);for(const zs of V){const Xt=R.getTile(zs);if(vt&&!Xt.patternsLoaded())continue;const Dt=Xt.getBucket(z);if(!Dt)continue;const ls=h?Dt.elevationBufferData:Dt.bufferData;if(ls.isEmpty())continue;D.prepareDrawTile();const es=ls.programConfigurations.get(z.id),As=D.isTileAffectedByFog(zs),Xs=[],ur=[];Be&&(Xs.push("ELEVATED_ROADS"),ur.push(ls.elevatedLayoutVertexBuffer)),ot&&Xs.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),jt&&x&&Xs.push("USE_MRT1"),vt&&(D.context.activeTexture.set(he.TEXTURE0),Xt.imageAtlasTexture&&Xt.imageAtlasTexture.bind(he.LINEAR,he.CLAMP_TO_EDGE),es.updatePaintBuffers());let Ws=!1;if(Ce&&Xt.imageAtlas){const mr=Xt.imageAtlas,$r=i.e3.from(Ce),jn=$r.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),da=$r.getSecondary(),Va=mr.patternPositions.get(jn),Tr=da?mr.patternPositions.get(da.scaleSelf(i.o.devicePixelRatio).toString()):null;Ws=!!Va&&!!Tr,Va&&es.setConstantPatternPositions(Va,Tr)}Me>0&&(Ws||es.getPatternTransitionVertexBuffer("fill-pattern"))&&Xs.push("FILL_PATTERN_TRANSITION");const Bs=D.getOrCreateProgram(Ht,{config:es,overrideFog:As,defines:Xs}),kr=D.translatePosMatrix(zs.projMatrix,Xt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));ot&&Xe.setupShadows(Xt.tileID.toUnwrapped(),Bs,"vector-tile");const br=z.paint.get("fill-emissive-strength");if(Et){ss=ls.lineIndexBuffer,ps=ls.lineSegments;const mr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[he.drawingBufferWidth,he.drawingBufferHeight];Ut=Ht==="fillOutlinePattern"&&vt?cT(kr,br,D,Xt,mr,Ct,Me):uD(kr,br,mr,Ct)}else ss=ls.indexBuffer,ps=ls.triangleSegments,Ut=vt?lT(kr,br,D,Xt,Ct,Me):oT(kr,br,Ct);D.uploadCommonUniforms(D.context,Bs,zs.toUnwrapped());let or=pt;(re==="road"&&!ae||re==="offset")&&(or=et),Bs.draw(D,ts,or,T||D.stencilModeForClipping(zs),X,rn.disabled,Ut,z.id,ls.layoutVertexBuffer,ss,ps,z.paint,D.transform.zoom,es,ur)}};D.renderPass===me&&xt(D.depthModeForSublayer(1,D.renderPass==="opaque"?Er.ReadWrite:Er.ReadOnly),!1),$e==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&&xt(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Er.ReadOnly),!0)}function BS(C,h,x,T,D,R,z,V){x.resetLayerRenderingStats(C);const X=C.context,re=X.gl,ae=C.transform,me=x.paint.get("fill-extrusion-pattern"),he=x.paint.get("fill-extrusion-pattern-cross-fade"),pe=me.constantOr(null),Me=me.constantOr(1),Ce=x.paint.get("fill-extrusion-opacity"),$e=C.style.enable3dLights(),Be=x.paint.get($e&&!Me?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),Xe=[x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Be],ot=x.layout.get("fill-extrusion-edge-radius"),et=ot>0&&!x.paint.get("fill-extrusion-rounded-roof"),Ct=et?0:ot,vt=ae.projection.name==="globe"?i.eb():0,jt=ae.projection.name==="globe",xt=jt?i.aj(ae.zoom):0,pt=[i.aF(ae.center.lng),i.aJ(ae.center.lat)],Et=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Ht=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Et?null:x.lut).toArray01().slice(0,3),Ut=x.paint.get("fill-extrusion-flood-light-intensity"),ts=x.paint.get("fill-extrusion-vertical-scale"),ss=x.paint.get("fill-extrusion-line-width").constantOr(1)!==0,ps=x.paint.get("fill-extrusion-height-alignment"),zs=x.paint.get("fill-extrusion-base-alignment"),Xt=Qg(C,x.paint.get("fill-extrusion-cutoff-fade-range")),Dt=[];let ls;jt&&Dt.push("PROJECTION_GLOBE_VIEW"),Xe[0]>0&&Dt.push("FAUX_AO"),et&&Dt.push("ZERO_ROOF_RADIUS"),V&&Dt.push("HAS_CENTROID"),Ut>0&&Dt.push("FLOOD_LIGHT"),Xt.shouldRenderCutoff&&Dt.push("RENDER_CUTOFF"),ss&&Dt.push("RENDER_WALL_MODE");const es=C.renderPass==="shadow",As=C.shadowRenderer,Xs=es&&!!As,ur=es?rn.disabled:rn.backCCW;C.shadowRenderer&&(C.shadowRenderer.useNormalOffset=!0);let Ws=[0,0,0];if(As){const br=C.style.directionalLight,or=C.style.ambientLight;br&&or&&(Ws=Pf(C.style,br,or)),es||(Dt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),As.useNormalOffset&&Dt.push("NORMAL_OFFSET")),ls=Dt.concat(["SHADOWS_SINGLE_CASCADE"])}const Bs=Xs?"fillExtrusionDepth":Me?"fillExtrusionPattern":"fillExtrusion",kr=x.getLayerRenderingStats();for(const br of T){const or=h.getTile(br),mr=or.getBucket(x);if(!mr||mr.projection.name!==ae.projection.name)continue;let $r=!1;As&&($r=As.getMaxCascadeForTile(br.toUnwrapped())===0);const jn=C.isTileAffectedByFog(br),da=mr.programConfigurations.get(x.id);let Va=!1;if(pe&&or.imageAtlas){const Ea=or.imageAtlas,On=i.e3.from(pe),Za=On.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),po=On.getSecondary(),Vi=Ea.patternPositions.get(Za),Xa=po?Ea.patternPositions.get(po.scaleSelf(i.o.devicePixelRatio).toString()):null;Va=!!Vi&&!!Xa,Vi&&da.setConstantPatternPositions(Vi,Xa)}he>0&&(Va||da.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Dt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Tr=C.getOrCreateProgram(Bs,{config:da,defines:$r?ls:Dt,overrideFog:jn});if(C.terrain&&C.terrain.setupElevationDraw(or,Tr,{useMeterToDem:!0}),!mr.centroidVertexBuffer){const Ea=Tr.getAttributeLocation(re,"a_centroid_pos");Ea!==-1&&re.vertexAttrib2f(Ea,0,0)}!es&&As&&As.setupShadows(or.tileID.toUnwrapped(),Tr,"vector-tile"),Me&&(C.context.activeTexture.set(re.TEXTURE0),or.imageAtlasTexture&&or.imageAtlasTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),da.updatePaintBuffers());const Oa=x.paint.get("fill-extrusion-vertical-gradient"),vn=1/mr.tileToMeter;let Ya;if(es&&As){if(Of(or.tileID,mr.maxHeight,C))continue;const Ea=As.calculateShadowPassMatrixFromTile(or.tileID.toUnwrapped());Ya=iT(Ea,Ct,vn,ts,ps,zs)}else{const Ea=C.translatePosMatrix(br.expandedProjMatrix,or,x.paint.get("fill-extrusion-translate"),x.paint.get("fill-extrusion-translate-anchor")),On=ae.projection.createInversionMatrix(ae,br.canonical);Ya=Me?dD(Ea,C,Oa,Ce,Xe,Ct,vn,br,or,vt,ps,zs,xt,pt,On,Ht,ts,he):PS(Ea,C,Oa,Ce,Xe,Ct,vn,br,vt,ps,zs,xt,pt,On,Ht,ts,Ut,Ws)}C.uploadCommonUniforms(X,Tr,br.toUnwrapped(),null,Xt);let ui=mr.segments;if(ae.projection.name==="mercator"&&!es&&(ui=mr.getVisibleSegments(or.tileID,C.terrain,C.transform.getFrustum(0)),!ui.get().length))continue;if(kr)if(es)for(const Ea of ui.get())kr.numRenderedVerticesInShadowPass+=Ea.primitiveLength;else for(const Ea of ui.get())kr.numRenderedVerticesInTransparentPass+=Ea.primitiveLength;const ni=[];(C.terrain||V)&&ni.push(mr.centroidVertexBuffer),jt&&ni.push(mr.layoutVertexExtBuffer),ss&&ni.push(mr.wallVertexBuffer),Tr.draw(C,X.gl.TRIANGLES,D,R,z,ur,Ya,x.id,mr.layoutVertexBuffer,mr.indexBuffer,ui,x.paint,C.transform.zoom,da,ni)}C.shadowRenderer&&(C.shadowRenderer.useNormalOffset=!1)}class pT{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Df(C,h,x,T,D,R,z,V,X,re,ae,me,he,pe,Me,Ce,$e,Be,Xe,ot){const et=h.context,Ct=et.gl,vt=h.transform,jt=h.transform.zoom,xt=[],pt=C.translate,Et=C.translateAnchor,Ht=C.edgeRadius,Ut=Qg(h,C.cutoffFadeRange);ae==="clear"?(xt.push("CLEAR_SUBPASS"),ot&&(xt.push("CLEAR_FROM_TEXTURE"),et.activeTexture.set(Ct.TEXTURE0),ot.bind(Ct.LINEAR,Ct.CLAMP_TO_EDGE))):ae==="sdf"?xt.push("SDF_SUBPASS"):ae==="emissive"&&(xt.push("USE_MRT1"),et.activeTexture.set(Ct.TEXTURE0),ot.bind(Ct.LINEAR,Ct.CLAMP_TO_EDGE)),Be&&xt.push("HAS_CENTROID"),Ut.shouldRenderCutoff&&xt.push("RENDER_CUTOFF");const ts=(ss,ps,zs,Xt,Dt)=>{let ls=xt;ps.groundRadiusBuffer!=null&&(ls=xt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const es=ps.programConfigurations.get(T.id),As=h.isTileAffectedByFog(ss),Xs=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:es,defines:ls,overrideFog:As}),ur=gv(h,Xt,me,re,Dt,[he,pe*Dt],Me,Ce,$e,jt>=17?0:Ht*Dt,ot?ot.size[0]:0),Ws=[];Be&&Ws.push(ps.hiddenByLandmarkVertexBuffer),ps.groundRadiusBuffer!=null&&Ws.push(ps.groundRadiusBuffer),h.uploadCommonUniforms(et,Xs,ss.toUnwrapped(),null,Ut),Xs.draw(h,et.gl.TRIANGLES,R,z,V,X,ur,T.id,ps.vertexBuffer,ps.indexBuffer,zs,T.paint,jt,es,Ws)};for(const ss of D){const ps=x.getTile(ss),zs=ps.getBucket(T);if(!zs||zs.projection.name!==vt.projection.name||!zs.groundEffect||zs.groundEffect&&!zs.groundEffect.hasData())continue;const Xt=zs.groundEffect,Dt=1/zs.tileToMeter;{const ls=h.translatePosMatrix(ss.projMatrix,ps,pt,Et),es=Xt.getDefaultSegment();ts(ss,Xt,es,ls,Dt)}if(Xe)for(let ls=0;ls<4;ls++){const es=i.e9[ls](ss),As=x.getTile(es);if(!As)continue;const Xs=As.getBucket(T);if(!Xs||Xs.projection.name!==vt.projection.name||!Xs.groundEffect||Xs.groundEffect&&!Xs.groundEffect.hasData())continue;const ur=Xs.groundEffect;let Ws,Bs;ls===0?(Ws=[-i.al,0,0],Bs=1):ls===1?(Ws=[i.al,0,0],Bs=0):ls===2?(Ws=[0,-i.al,0],Bs=3):(Ws=[0,i.al,0],Bs=2);const kr=ur.regionSegments[Bs];if(!kr)continue;const br=new Float32Array(16);i.br(br,ss.projMatrix,Ws),ts(ss,ur,kr,h.translatePosMatrix(br,ps,pt,Et),Dt)}}}function Bce(C,h,x,T,D,R,z){T.centroidVertexArray.length===0&&T.createCentroidsBuffer();const V=R?R.findDEMTileFor(x):null;if(!(V&&V.dem||z))return;R&&V&&V.dem&&T.selfDEMTileTimestamp!==V.dem._timestamp&&(T.borderDoneWithNeighborZ=[-1,-1,-1,-1],T.selfDEMTileTimestamp=V.dem._timestamp);const X=Be=>new i.P(Math.ceil((Be+i.ed)*i.ee),0),re=Be=>{const Xe=h.getSource().minzoom,ot=Ct=>{const vt=h.getTileByID(Ct);if(vt&&vt.hasData())return vt.getBucket(D)},et=[0,-1,1];for(const Ct of et){if(Be.overscaledZ+Ct(ae[0]=Math.min(Be.min.y,Xe.min.y),ae[1]=Math.max(Be.max.y,Xe.max.y),ae[2]=i.al-Xe.min.x>Be.max.x?Xe.min.x-i.al:Be.max.x,ae),he=(Be,Xe)=>(ae[0]=Math.min(Be.min.x,Xe.min.x),ae[1]=Math.max(Be.max.x,Xe.max.x),ae[2]=i.al-Xe.min.y>Be.max.y?Xe.min.y-i.al:Be.max.y,ae),pe=[(Be,Xe)=>me(Be,Xe),(Be,Xe)=>me(Xe,Be),(Be,Xe)=>he(Be,Xe),(Be,Xe)=>he(Xe,Be)],Me=(Be,Xe,ot,et,Ct,vt,jt)=>{if(!R)return 0;const xt=[[vt?ot:Be,vt?Be:ot,0],[vt?ot:Xe,vt?Xe:ot,0]],pt=jt<0?i.al+jt:jt,Et=[vt?pt:(Be+Xe)/2,vt?(Be+Xe)/2:pt,0];return ot===0&&jt<0||ot!==0&&jt>0?R.getForTilePoints(Ct,[Et],!0,et):xt.push(Et),R.getForTilePoints(x,xt,!0,V),Math.max(xt[0][2],xt[1][2],Et[2])/R.exaggeration()};for(let Be=0;Be<4;Be++){const Xe=T.borderFeatureIndices[Be];if(Xe.length===0)continue;const ot=i.e9[Be](x),et=re(ot);if(!(et&&et instanceof i.ea))continue;const Ct=R?R.findDEMTileFor(ot):null;if(!(Ct&&Ct.dem||z)||(R&&Ct&&Ct.dem&&T.borderDEMTileTimestamp[Be]!==Ct.dem._timestamp&&(T.borderDoneWithNeighborZ[Be]=-1,T.borderDEMTileTimestamp[Be]=Ct.dem._timestamp),T.borderDoneWithNeighborZ[Be]===et.canonical.z))continue;et.centroidVertexArray.length===0&&et.createCentroidsBuffer();const vt=(Be<2?1:5)-Be,jt=et.borderDoneWithNeighborZ[vt]!==T.canonical.z,xt=et.borderFeatureIndices[vt];let pt=0;if(T.canonical.z!==et.canonical.z){for(const Et of Xe)T.showCentroid(T.featuresOnBorder[Et]);if(jt)for(const Et of xt)et.showCentroid(et.featuresOnBorder[Et]);T.borderDoneWithNeighborZ[Be]=et.canonical.z,et.borderDoneWithNeighborZ[vt]=T.canonical.z}for(const Et of Xe){const Ht=T.featuresOnBorder[Et],Ut=T.centroidData[Ht.centroidDataIndex],ts=Ht.borders[Be];let ss;for(;ptts[0]+3||ps[0]>ts[0]-3)break;et.showCentroid(ss),pt++}if(ss&&ptts[1]-3)&&(zs++,++pt!==xt.length);)ss=et.featuresOnBorder[xt[pt]];ss=et.featuresOnBorder[xt[ps]];let Xt=!1;if(zs>=1){const es=ss.borders[vt];Math.abs(ts[0]-es[0])<3&&Math.abs(ts[1]-es[1])<3&&(zs=1,Xt=!0,pt=ps+1)}else if(zs===0){T.showCentroid(Ht);continue}const Dt=et.centroidData[ss.centroidDataIndex];z&&Xt&&(((Ce=Ut).flags|($e=Dt).flags)&i.ec?(Ce.flags|=i.ec,$e.flags|=i.ec):(Ce.flags&=~i.ec,$e.flags&=~i.ec));const ls=Ht.intersectsCount()>1||ss.intersectsCount()>1;if(zs>1)pt=ps,Ut.centroidXY=Dt.centroidXY=new i.P(0,0);else if(Ct&&Ct.dem&&!ls){const es=pe[Be](Ut,Dt),As=Be%2?i.al-1:0,Xs=Me(es[0],Math.min(i.al-1,es[1]),As,Ct,ot,Be<2,es[2]);Ut.centroidXY=Dt.centroidXY=X(Xs)}else ls?Ut.centroidXY=Dt.centroidXY=new i.P(0,0):(Ut.centroidXY=T.encodeBorderCentroid(Ht),Dt.centroidXY=et.encodeBorderCentroid(ss));T.writeCentroidToBuffer(Ut),et.writeCentroidToBuffer(Dt)}else T.showCentroid(Ht)}T.borderDoneWithNeighborZ[Be]=et.canonical.z,et.borderDoneWithNeighborZ[vt]=T.canonical.z}var Ce,$e;(T.needsCentroidUpdate||!T.centroidVertexBuffer&&T.centroidVertexArray.length!==0)&&T.uploadCentroid(C)}const Fu=[1,0,0],fT=[0,1,0],Gd=[0,0,1];function Of(C,h,x){const T=x.transform,D=x.shadowRenderer;if(!D)return!0;const R=C.toUnwrapped(),z=T.tileSize*D._cascades[x.currentShadowCascade].scale;let V=h;if(T.elevation){const Ce=T.elevation.getMinMaxForTile(C);Ce&&(V+=Ce.max)}const X=[...D.shadowDirection];X[2]=-X[2];const re=D.computeSimplifiedTileShadowVolume(R,V,z,X);if(!re)return!1;const ae=[Fu,fT,Gd,X,[X[0],0,X[2]],[0,X[1],X[2]]],me=T.projection.name==="globe",he=T.scaleZoom(z),pe=i.cB.fromInvProjectionMatrix(T.invProjMatrix,T.worldSize,he,!me),Me=D.getCurrentCascadeFrustum();return pe.intersectsPrecise(re.vertices,re.planes,ae)===0||Me.intersectsPrecise(re.vertices,re.planes,ae)===0}function fb(C){const{painter:h,source:x,layer:T,coords:D}=C;let R=C.defines;const z=h.context,V=h.renderPass==="shadow",X=h.renderPass==="light-beam",re=h.shadowRenderer,ae=i.ef(h.transform.center.lat,h.transform.zoom),me=Qg(h,T.paint.get("building-cutoff-fade-range"));me.shouldRenderCutoff&&(R=R.concat("RENDER_CUTOFF")),C.floodLightIntensity>0&&(R=R.concat("FLOOD_LIGHT"));for(const he of D){const pe=x.getTile(he),Me=pe.getBucket(T);if(!Me)continue;re&&re.getMaxCascadeForTile(he.toUnwrapped())===0&&(R=R.concat("SHADOWS_SINGLE_CASCADE"));const Ce=Me.programConfigurations.get(T.id);let $e,Be,Xe,ot=h.translatePosMatrix(he.expandedProjMatrix,pe,[0,0],"map");if(ot=i.cS(i.bC(),ot,[1,1,C.verticalScale]),V&&re){if(Of(pe.tileID,Me.maxHeight*ae,h))continue;let Ct=re.calculateShadowPassMatrixFromTile(pe.tileID.toUnwrapped());Ct=i.cS(i.bC(),Ct,[1,1,C.verticalScale]),Xe=ax(Ct),$e=Be=h.getOrCreateProgram("buildingDepth",{config:Ce,defines:R,overrideFog:!1})}else if(X)$e=Be=h.getOrCreateProgram("buildingBloom",{config:Ce,defines:R,overrideFog:!1}),Xe=hD(ot);else{const Ct=h.transform.calculatePosMatrix(he.toUnwrapped(),h.transform.worldSize);i.cS(Ct,Ct,[1,1,C.verticalScale]);const vt=i.bC();i.cS(vt,Ct,[1,-1,1/ae]),i.bl(vt,vt),i.eg(vt,vt);const jt=h.transform.getFreeCameraOptions().position,xt=1<{if(X){const jt=Ct.entranceBloom;vt.draw(h,z.gl.TRIANGLES,C.depthMode,ln.disabled,C.blendMode,rn.disabled,Xe,T.id,jt.layoutVertexBuffer,jt.indexBuffer,jt.segmentsBucket,T.paint,h.transform.zoom,Ce,[jt.layoutAttenuationBuffer,jt.layoutColorBuffer])}else{const jt=Ct.segmentsBucket;let xt=[Ct.layoutNormalBuffer,Ct.layoutCentroidBuffer,Ct.layoutColorBuffer,Ct.layoutFloodLightDataBuffer];Ct.layoutFacadePaintBuffer&&(xt=xt.concat([Ct.layoutFacadeDataBuffer,Ct.layoutFacadeVerticalRangeBuffer,Ct.layoutFacadePaintBuffer])),vt.draw(h,z.gl.TRIANGLES,C.depthMode,ln.disabled,C.blendMode,V?rn.disabled:rn.backCW,Xe,T.id,Ct.layoutVertexBuffer,Ct.indexBuffer,jt,T.paint,h.transform.zoom,Ce,xt)}};h.uploadCommonUniforms(z,Be,he.toUnwrapped(),null,me),Me.buildingWithoutFacade&&et(Me.buildingWithoutFacade,Be),Me.buildingWithFacade&&($e!==Be&&h.uploadCommonUniforms(z,$e,he.toUnwrapped(),null,me),et(Me.buildingWithFacade,$e))}}function $S(C,h,x,T,D,R,z,V,X,re,ae,me,he){const pe=C.context.gl,Me=C.depthModeForSublayer(1,Er.ReadOnly,pe.LEQUAL,!0),Ce=.1*(1-($e=ae))+3*$e;var $e;const Be=C._showOverdrawInspector,Xe=me,ot=new pT;Be||Df(ot,C,h,x,T,Me,new ln({func:pe.ALWAYS,mask:255},255,255,pe.KEEP,pe.KEEP,pe.REPLACE),new En([pe.ONE,pe.ONE,pe.ONE,pe.ONE],i.ao.transparent,[!1,!1,!1,!0],pe.MIN),rn.disabled,D,"sdf",R,z,V,X,re,Ce,Xe,!1);{const et=Be?ln.disabled:new ln({func:pe.EQUAL,mask:255},255,255,pe.KEEP,pe.DECR,pe.DECR),Ct=Be?C.colorModeForRenderPass():new En([pe.ONE_MINUS_DST_ALPHA,pe.DST_ALPHA,pe.ONE,pe.ONE],i.ao.transparent,[!0,!0,!0,!0]);Df(ot,C,h,x,T,Me,et,Ct,rn.disabled,D,"color",R,z,V,X,re,Ce,Xe,!1)}}function qS(C){return[C[0]*i.eh,C[1]*i.eh,C[2]*i.eh,0]}function gb(C,h,x,T,D,R,z,V,X){const re=T.getSource(),ae=x.globeSharedBuffers;if(!ae)return;let me,he,pe;if(h&&(me=T.getTile(h)),re instanceof i.aU?(he=re.texture,pe=i.dK(0,0,x.transform)):me&&h&&(he=me.texture,pe=i.dK(h.canonical.z,h.canonical.x,x.transform)),!he||!pe)return;C||(pe=i.cS(i.bC(),pe,[1,-1,1]));const Me=x.context,Ce=Me.gl,$e=D.paint.get("raster-resampling")==="nearest"?Ce.NEAREST:Ce.LINEAR,Be=x.colorModeForDrapableLayerRenderPass(R),Xe=z.defines;Xe.push("GLOBE_POLES");const ot=new Er(Ce.LEQUAL,Er.ReadWrite,x.depthRangeFor3D),et=Float32Array.from(x.transform.expandedFarZProjMatrix),Ct=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));x.terrain&&x.terrain.prepareDrawTile(),Me.activeTexture.set(Ce.TEXTURE0),he.bind($e,Ce.CLAMP_TO_EDGE),Me.activeTexture.set(Ce.TEXTURE1),he.bind($e,Ce.CLAMP_TO_EDGE),"useMipmap"in he&&Me.extTextureFilterAnisotropic&&x.transform.pitch>20&&Ce.texParameterf(Ce.TEXTURE_2D,Me.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Me.extTextureFilterAnisotropicMax);const[vt,jt,xt,pt]=h?ae.getPoleBuffers(h.canonical.z,!1):ae.getPoleBuffers(0,!0),Et=D.paint.get("raster-elevation");let Ht;C?(Ht=vt,x.renderDefaultNorthPole=Et!==0):(Ht=jt,x.renderDefaultSouthPole=Et!==0);const Ut=qS(z.mix),ts=((ps,zs,Xt,Dt,ls,es,As,Xs,ur,Ws,Bs,kr,br)=>fD(ps,zs,Xt,new Float32Array(16),new Float32Array(9),[0,0],Dt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},es,[0,0],Xs,2,Ws,Bs,kr,1,0,br))(et,Ct,pe,i.aj(x.transform.zoom),0,D,0,Et,0,Ut,z.offset,z.range,R),ss=x.getOrCreateProgram("raster",{defines:Xe});x.uploadCommonUniforms(Me,ss,null),ss.draw(x,Ce.TRIANGLES,ot,X,Be,V,ts,D.id,Ht,xt,pt)}function wD(C){const h=C._nearZ,x=C.projection.farthestPixelDistance(C),T=x-h,D=.2*C.height,R=h+D;return[h,x,(R-D-h)/T,(R-h)/T]}function Rf(C,h,x,T){if(C)return h instanceof Zc&&C instanceof Xc?h.getTextureDescriptor(C,x,!0):{texture:C.texture,mix:qS(T.mix),offset:T.offset,buffer:0,tileSize:1}}var Ii=i.ei([{name:"a_index",type:"Int16",components:1}]);class US{constructor(h,x,T,D){const R={width:T[0],height:T[1],data:null},z=h.gl;this.targetColorTexture=new i.T(h,R,z.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(h,R,z.RGBA8,{useMipmap:!1}),this.context=h,this.updateParticleTexture(x,D),this.lastInvalidatedAt=0}updateParticleTexture(h,x){if(this.particleTextureDimension===x.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const T=this.context.gl,D=x.width*x.height;this.particleTexture0=new i.T(this.context,x,T.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,x,T.RGBA8,{premultiply:!1,useMipmap:!1});const R=new i.ej;R.reserve(D);for(let z=0;z0){const Ut=i.bj(x.canonical,X),ts=i.el(Ut);he=i.aB(new Float32Array(16),X.globeMatrix,ts),i.aB(he,X.projMatrix,he)}const pe=i.bC();pe[12]+=2*D/(i.o.devicePixelRatio*X.width),pe[13]+=2*R/(i.o.devicePixelRatio*X.height),i.aB(he,pe,he);const Me=C.getOrCreateProgram("debug",{defines:me}),Ce=h.getTileByID(x.key);C.terrain&&C.terrain.setupElevationDraw(Ce,Me);const $e=Er.disabled,Be=ln.disabled,Xe=C.colorModeForRenderPass(),ot="$debug";V.activeTexture.set(re.TEXTURE0),C.emptyTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),ae?Ce._makeGlobeTileDebugBuffers(C.context,X):Ce._makeDebugTileBoundsBuffers(C.context,X.projection);const et=Ce._tileDebugBuffer||C.debugBuffer,Ct=Ce._tileDebugIndexBuffer||C.debugIndexBuffer,vt=Ce._tileDebugSegments||C.debugSegments;if(Me.draw(C,re.LINE_STRIP,$e,Be,Xe,rn.disabled,ub(he,T.toPremultipliedRenderColor(null)),ot,et,Ct,vt,null,null,null,[Ce._globeTileDebugBorderBuffer]),z){const Ut=Ce.latestRawTileData,ts=Math.floor((Ut&&Ut.byteLength||0)/1024);let ss=x.canonical.toString();x.overscaledZ!==x.canonical.z&&(ss+=` => ${x.overscaledZ}`),ss+=` ${Ce.state}`,ss+=` ${ts}kb`,function(ps,zs){ps.initDebugOverlayCanvas();const Xt=ps.debugOverlayCanvas,Dt=ps.context.gl,ls=ps.debugOverlayCanvas.getContext("2d");ls.clearRect(0,0,Xt.width,Xt.height),ls.shadowColor="white",ls.shadowBlur=2,ls.lineWidth=1.5,ls.strokeStyle="white",ls.textBaseline="top",ls.font="bold 36px Open Sans, sans-serif",ls.fillText(zs,5,5),ls.strokeText(zs,5,5),ps.debugOverlayTexture.update(Xt),ps.debugOverlayTexture.bind(Dt.LINEAR,Dt.CLAMP_TO_EDGE)}(C,ss)}const jt=h.getTile(x).tileSize,xt=512/Math.min(jt,512)*(x.overscaledZ/X.zoom)*.5,pt=Ce._tileDebugTextBuffer||C.debugBuffer,Et=Ce._tileDebugTextIndexBuffer||C.quadTriangleIndexBuffer,Ht=Ce._tileDebugTextSegments||C.debugSegments;Me.draw(C,re.TRIANGLES,$e,Be,En.alphaBlended,rn.disabled,ub(he,i.ao.transparent.toPremultipliedRenderColor(null),xt),ot,pt,Et,Ht,null,null,null,[Ce._globeTileDebugTextBuffer])}function Cy(C,h,x,T){Gt(C,0,h+x/2,C.transform.width,x,T)}function _o(C,h,x,T){Gt(C,h-x/2,0,x,C.transform.height,T)}function Gt(C,h,x,T,D,R){const z=C.context,V=z.gl;V.enable(V.SCISSOR_TEST),V.scissor(h*i.o.devicePixelRatio,x*i.o.devicePixelRatio,T*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:R}),V.disable(V.SCISSOR_TEST)}const CD=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:VS}=CD;function Pp(C,h,x,T){C.emplaceBack(h,x,T)}class HS{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Pp(this.vertexArray,-1,-1,1),Pp(this.vertexArray,1,-1,1),Pp(this.vertexArray,-1,1,1),Pp(this.vertexArray,1,1,1),Pp(this.vertexArray,-1,-1,-1),Pp(this.vertexArray,1,-1,-1),Pp(this.vertexArray,-1,1,-1),Pp(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,VS),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function My(C,h,x,T,D,R){const z=C.context.gl,V=h.paint.get("sky-atmosphere-color"),X=h.paint.get("sky-atmosphere-halo-color"),re=h.paint.get("sky-atmosphere-sun-intensity"),ae=((me,he,pe,Me,Ce)=>({u_matrix_3f:me,u_sun_direction:he,u_sun_intensity:pe,u_color_tint_r:[Me.r,Me.g,Me.b,Me.a],u_color_tint_m:[Ce.r,Ce.g,Ce.b,Ce.a],u_luminance:5e-5}))(i.eo(i.dO(),T),D,re,V.toPremultipliedRenderColor(null),X.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+R,h.skyboxTexture,0),x.draw(C,z.TRIANGLES,Er.disabled,ln.disabled,En.unblended,rn.frontCW,ae,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const MD=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class vv{constructor(h){const x=new i.ep;x.emplaceBack(-1,1,1,0,0),x.emplaceBack(1,1,1,1,0),x.emplaceBack(1,-1,1,1,1),x.emplaceBack(-1,-1,1,0,1);const T=new i.b0;T.emplaceBack(0,1,2),T.emplaceBack(2,3,0),this.vertexBuffer=h.createVertexBuffer(x,MD.members),this.indexBuffer=h.createIndexBuffer(T),this.segments=i.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const $ce=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 qce{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class TD{constructor(h){this.colorModeAlphaBlendedWriteRGB=new En([1,Mp,1,Mp],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new En([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new qce,this.updateNeeded=!0}update(h){const x=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new vv(x);const T=this.params.sizeRange,D=this.params.intensityRange,R=function(ae){const me=i.eq(30),he=[];for(let pe=0;pe{const xt=R.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];jt&&xt.push("ALPHA_PASS");const pt=h.getOrCreateProgram("globeAtmosphere",{defines:xt}),Et=((Ut,ts,ss,ps,zs,Xt,Dt,ls,es,As,Xs,ur)=>({u_frustum_tl:Ut,u_frustum_tr:ts,u_frustum_br:ss,u_frustum_bl:ps,u_horizon:zs,u_transition:Xt,u_fadeout_range:Dt,u_atmosphere_fog_color:ls.toArray01(),u_high_color:es.toArray01(),u_space_color:As.toArray01(),u_temporal_offset:Xs,u_horizon_angle:ur}))(R.frustumCorners.TL,R.frustumCorners.TR,R.frustumCorners.BR,R.frustumCorners.BL,R.frustumCorners.horizon,V,$e,ae,he,Me,Xe,Ct);h.uploadCommonUniforms(T,pt);const Ht=this.atmosphereBuffer;Ht&&pt.draw(h,D.TRIANGLES,z,ln.disabled,jt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,rn.backCW,Et,jt?"atmosphere_glow_alpha":"atmosphere_glow",Ht.vertexBuffer,Ht.indexBuffer,Ht.segments)};vt(!1),vt(!0)}drawStars(h,x){const T=i.aA(x.properties.get("star-intensity"),0,1);if(T===0)return;const D=h.context,R=D.gl,z=h.transform,V=h.getOrCreateProgram("stars"),X=i.c7([]);i.c9(X,X,-z._pitch),i.c8(X,X,-z.angle),i.c9(X,X,i.an(z._center.lat)),i.et(X,X,-i.an(z._center.lng));const re=i.cc(new Float32Array(16),X),ae=i.aB([],z.starsProjMatrix,re),me=i.eo([],re),he=i.eu([],me),pe=[0,1,0];i.dQ(pe,pe,he),i.c5(pe,pe,this.params.sizeMultiplier);const Me=[1,0,0];i.dQ(Me,Me,he),i.c5(Me,Me,this.params.sizeMultiplier);const Ce=($e=pe,Be=Me,Xe=T,{u_matrix:Float32Array.from(ae),u_up:$e,u_right:Be,u_intensity_multiplier:Xe});var $e,Be,Xe;h.uploadCommonUniforms(D,V),this.starsVx&&this.starsIdx&&V.draw(h,R.TRIANGLES,Er.disabled,ln.disabled,this.colorModeAlphaBlendedWriteRGB,rn.disabled,Ce,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class WS{constructor(){this.visibleTiles=[]}updateBorders(h,x){const T=[],D=[],R=h._getRenderableCoordinates(!1,!0);for(const X of R){const re=h.getTile(X);if(!re.hasData())continue;const ae=re.getBucket(x);ae&&(ae.isEmpty()||(T.push(X.key),D.push({bucket:ae,tileID:X.canonical})))}let z=T.length!==this.visibleTiles.length;if(!z){T.sort();for(let X=0;XX.tileID.z-re.tileID.z||X.tileID.x-re.tileID.x||X.tileID.y-re.tileID.y);for(const X of D){const re=new Array,ae=new Array,me=X.bucket;for(const he of me.featuresOnBorder)V.has(he.featureId)?ae.push(he.footprintIndex):(V.add(he.featureId),re.push(he.footprintIndex));me.updateFootprintHiddenFlags(re,i.ev,!1),me.updateFootprintHiddenFlags(ae,i.ev,!0)}}}function GS(C,h){const x=[...C],T=h.cameraWorldSizeForFog/h.worldSize,D=i.bA([]);return i.cS(D,D,[T,T,1]),i.aB(x,D,x),i.aB(x,h.worldToFogMatrix,x),x}function KS(C,h,x,T,D){const R=x.material,z=T.context,{baseColorTexture:V,metallicRoughnessTexture:X}=R.pbrMetallicRoughness,{normalTexture:re,occlusionTexture:ae,emissionTexture:me}=R;function he(Me,Ce,$e){if(Me&&(C.push(Ce),z.activeTexture.set(z.gl.TEXTURE0+$e),Me.gfxTexture)){const{minFilter:Be,magFilter:Xe,wrapS:ot,wrapT:et}=Me.sampler;Me.gfxTexture.bindExtraParam(Be,Xe,ot,et)}}he(V,"HAS_TEXTURE_u_baseColorTexture",gc.BaseColor),he(X,"HAS_TEXTURE_u_metallicRoughnessTexture",gc.MetallicRoughness),he(re,"HAS_TEXTURE_u_normalTexture",gc.Normal),he(ae,"HAS_TEXTURE_u_occlusionTexture",gc.Occlusion),he(me,"HAS_TEXTURE_u_emissionTexture",gc.Emission),D&&(D.texture||(D.texture=new i.d$(T.context,D.image,[D.image.height,D.image.height,D.image.height],z.gl.RGBA8)),z.activeTexture.set(z.gl.TEXTURE0+gc.LUT),D.texture&&D.texture.bind(z.gl.LINEAR,z.gl.CLAMP_TO_EDGE),C.push("APPLY_LUT_ON_GPU")),x.texcoordBuffer&&(C.push("HAS_ATTRIBUTE_a_uv_2f"),h.push(x.texcoordBuffer)),x.colorBuffer&&(C.push(x.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),h.push(x.colorBuffer)),x.normalBuffer&&(C.push("HAS_ATTRIBUTE_a_normal_3f"),h.push(x.normalBuffer)),x.pbrBuffer&&(C.push("HAS_ATTRIBUTE_a_pbr"),C.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),h.push(x.pbrBuffer)),R.alphaMode!=="OPAQUE"&&R.alphaMode!=="MASK"||C.push("UNPREMULT_TEXTURE_IN_SHADER"),R.defined||C.push("DIFFUSE_SHADED");const pe=T.shadowRenderer;pe&&(C.push("RENDER_SHADOWS","DEPTH_TEXTURE"),pe.useNormalOffset&&C.push("NORMAL_OFFSET"))}function ZS(C,h,x,T,D,R){const z=C.modelOpacity,V=h.context,X=new Er(h.context.gl.LEQUAL,C.isLightMesh?Er.ReadOnly:Er.ReadWrite,h.depthRangeFor3D),re=h.transform,ae=C.mesh,me=ae.material,he=me.pbrMetallicRoughness,pe=h.style.fog;let Me;Me=h.transform.projection.zAxisUnit==="pixels"?[...C.nodeModelMatrix]:i.aB([],T.zScaleMatrix,C.nodeModelMatrix),i.aB(Me,T.negCameraPosMatrix,Me);const Ce=i.bl([],Me);i.eg(Ce,Ce);const $e=x.paint.get("model-color-use-theme").constantOr("default")==="none",Be=x.paint.get("model-emissive-strength").constantOr(0),Xe=jy(new Float32Array(C.worldViewProjection),new Float32Array(Me),new Float32Array(Ce),null,h,z,he.baseColorFactor,me.emissiveFactor,he.metallicFactor,he.roughnessFactor,me,Be,x,void 0,void 0,C.materialOverride,C.modelColor),ot={defines:[]},et=[],Ct=h.shadowRenderer;Ct&&(Ct.useNormalOffset=!1),KS(ot.defines,et,ae,h,$e?null:x.lut);let vt=null;if(pe){const pt=GS(C.nodeModelMatrix,h.transform);if(vt=new Float32Array(pt),re.projection.name!=="globe"){const Et=ae.aabb.min,Ht=ae.aabb.max,[Ut,ts]=pe.getOpacityForBounds(pt,Et[0],Et[1],Ht[0],Ht[1]);ot.overrideFog=Ut>=xs||ts>=xs}}const jt=Qg(h,x.paint.get("model-cutoff-fade-range"));jt.shouldRenderCutoff&&ot.defines.push("RENDER_CUTOFF");const xt=h.getOrCreateProgram("model",ot);h.uploadCommonUniforms(V,xt,null,vt,jt),h.renderPass!=="shadow"&&Ct&&Ct.setupShadowsFromMatrix(C.nodeModelMatrix,xt),xt.draw(h,V.gl.TRIANGLES,X,D,R,ae.material.doubleSided?rn.disabled:rn.backCCW,Xe,x.id,ae.vertexBuffer,ae.indexBuffer,ae.segments,x.paint,h.transform.zoom,void 0,et)}function xb(C,h){return C.style._importedAsBasemap?"basemap":h.scope}function Ty(C,h,x,T,D,R,z,V,X,re){const ae=C.transform,me=!!h.isGeometryBloom&&h.isGeometryBloom;if(me&&C.renderPass==="shadow")return;const he=ae.projection.name==="globe"?i.eD(x,ae):[...x];i.aB(he,he,h.globalMatrix);const pe=i.aB([],T,he);if(h.meshes)for(const Me of h.meshes){const Ce=V.get(Me.material.name);if(Ce&&Ce.opacity<=0)continue;if(Me.material.alphaMode!=="BLEND"){z.push({mesh:Me,depth:0,modelIndex:D,worldViewProjection:pe,nodeModelMatrix:he,isLightMesh:me,materialOverride:Ce,modelOpacity:X,modelColor:re});continue}const $e=i.af([],Me.centroid,pe);!ae.isOrthographic&&$e[2]<=0||R.push({mesh:Me,depth:$e[2],modelIndex:D,worldViewProjection:pe,nodeModelMatrix:he,isLightMesh:me,materialOverride:Ce,modelOpacity:X,modelColor:re})}if(h.children)for(const Me of h.children)Ty(C,Me,x,T,D,R,z,V,X,re)}function qm(C,h,x,T){const D=x.shadowRenderer;if(!D)return;const R=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),V=D.calculateShadowPassMatrixFromMatrix(h),X=uT(V);x.getOrCreateProgram("modelDepth",{defines:x._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(x,x.context.gl.TRIANGLES,R,ln.disabled,z,rn.disabled,X,T.id,C.vertexBuffer,C.indexBuffer,C.segments,T.paint,x.transform.zoom,void 0,void 0)}function AD(C,h,x,T,D,R){for(const z of D){const V=Object.assign({},T);V.part=z;const X={type:"Unknown",id:h,properties:V},re={orientation:C.paint.get("model-rotation").evaluate(X,x)};R.set(z,re)}}function ED(C,h,x,T,D,R){for(const z of D){const V=Object.assign({},T);V.part=z;const X={type:"Unknown",id:h,properties:V},re={color:C.paint.get("model-color").evaluate(X,x),colorMix:C.paint.get("model-color-mix-intensity").evaluate(X,x),opacity:C.paint.get("model-opacity").evaluate(X,x),emissionStrength:C.paint.get("model-emissive-strength").evaluate(X,x)};R.set(z,re)}}function PD(C,h,x,T,D){let R=!1;for(const V of T)V.modelOpacity!==1&&(ZS(V,C,h,D[V.modelIndex],ln.disabled,En.disabled),R=!0);for(const V of T)ZS(V,C,h,D[V.modelIndex],V.modelOpacity!==1?C.stencilModeFor3D():ln.disabled,C.colorModeForRenderPass());R&&C.resetStencilClippingMasks();const z=En.additive;for(const V of x)ZS(V,C,h,D[V.modelIndex],ln.disabled,V.isLightMesh?z:C.colorModeForRenderPass())}function ID(C,h,x){const T=h.updateZoomBasedPaintProperties(),D=function(R,z,V){let X,re,ae,me=R.terrain?R.terrain.exaggeration():0;if(R.terrain&&me>0){const he=R.terrain,pe=he.findDEMTileFor(V);pe&&pe.dem?X=i.eF.create(he,V,pe):me=0}if(me===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),me===z.validForExaggeration&&(me===0||X&&X._demTile&&X._demTile.tileID===z.validForDEMTile.id&&X._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const he in z.instancesPerModel){const pe=z.instancesPerModel[he];for(let Me=0;Mere&&(re=pe.max)}const ae=i.aA(T.x,R,z)-T.x,me=i.aA(T.y,V,X)-T.y,he=i.cf(re,h.center.lat)-T.z;return h._zoomFromMercatorZ(Math.sqrt(ae*ae+me*me+he*he))}function LD(C,h,x,T,D,R,z){const V=C.context,X=C.renderPass==="shadow",re=C.shadowRenderer,ae=X&&re?re.getShadowPassDepthMode():new Er(V.gl.LEQUAL,Er.ReadWrite,C.depthRangeFor3D),me=C.isTileAffectedByFog(R),he=C.transform.projection.name==="globe";if(x.meshes)for(const pe of x.meshes){const Me=he?[]:["MODEL_POSITION_ON_GPU"],Ce=[];let $e,Be,Xe;const ot=!he&&T.instancedDataArray.length>20;ot&&Me.push("INSTANCED_ARRAYS");const et=Qg(C,h.paint.get("model-cutoff-fade-range"));if(et.shouldRenderCutoff&&Me.push("RENDER_CUTOFF"),X&&re)$e=C.getOrCreateProgram("modelDepth",{defines:Me}),Be=uT(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(x.globalMatrix)),Xe=re.getShadowPassColorMode();else{KS(Me,Ce,pe,C,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),$e=C.getOrCreateProgram("model",{defines:Me,overrideFog:me});const vt=pe.material,jt=vt.pbrMetallicRoughness,xt=h.paint.get("model-opacity").constantOr(1),pt=h.paint.get("model-emissive-strength").constantOr(0);Be=jy(R.expandedProjMatrix,Float32Array.from(x.globalMatrix),new Float32Array(16),null,C,xt,jt.baseColorFactor,vt.emissiveFactor,jt.metallicFactor,jt.roughnessFactor,vt,pt,h,D),re&&(z.shadowUniformsInitialized?$e.setShadowUniformValues(V,re.getShadowUniformValues()):(re.setupShadows(R.toUnwrapped(),$e,"model-tile"),z.shadowUniformsInitialized=!0)),Xe=et.shouldRenderCutoff||xt<1||vt.alphaMode!=="OPAQUE"?En.alphaBlended:En.unblended}C.uploadCommonUniforms(V,$e,R.toUnwrapped(),null,et);const Ct=pe.material.doubleSided?rn.disabled:rn.backCCW;if(ot)Ce.push(T.instancedDataBuffer),$e.draw(C,V.gl.TRIANGLES,ae,ln.disabled,Xe,Ct,Be,h.id,pe.vertexBuffer,pe.indexBuffer,pe.segments,h.paint,C.transform.zoom,void 0,Ce,T.instancedDataArray.length);else{const vt=X?"u_instance":"u_normal_matrix";for(let jt=0;jtX[1]?z:X,R[0]=x.max[0],z=i.aC(i.eG(),R,D),V=z[1]X[1]?z:X,R[1]=x.min[1],z=i.aC(i.eG(),R,D),V=z[1]X[1]?z:X;const re=i.aA(T[0],0,1),ae=100*h.pixelsPerMeter*i.aA(T[1],0,1),me=i.aA(T[2],0,1),he=i.eH(i.eG(),V,X,re),pe=Math.tan(.5*h.fovX),Me=-he[2]*pe;if(ae===0)return he[1]<-Math.abs(Me)?me:1;const Ce=(-Math.abs(Me)-he[1])/ae,$e=(Xe,ot,et)=>(1-et)*Xe+et*ot,Be=i.aA($e(1,me,Ce),me,1);return $e(1,Be,i.aA((h.pitch-20)/20,0,1))}class DD{}class lx{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,x,T){{const me=this._storage.get(x.id);if(me)return me.lastUsedFrameIdx=h,me.buf}const D=T.gl,R=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(R),V=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const X=new i.eJ;for(let me=0;me30&&(T.buf.destroy(),this._storage.delete(x))}destroy(){for(const[h,x]of this._storage)x.buf.destroy(),this._storage.delete(h)}}class _v{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const bv=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 Ff{constructor(h){this.revealStart=11,this.revealRange=2}}const xT=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class yT{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(h,x){const T=h.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const z=new i.eK,V=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),V.emplaceBack(0,1,2),V.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,xT.members),this.vignetteIdx=h.context.createIndexBuffer(V)}const D=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){h.uploadCommonUniforms(h.context,T);const z={u_vignetteShape:(R={vignetteShape:[x.start,x.range,Math.pow(10,x.fadePower)],vignetteColor:[x.color.r,x.color.g,x.color.b,x.color.a*x.strength]}).vignetteShape,u_vignetteColor:R.vignetteColor};T.draw(h,h.context.gl.TRIANGLES,Er.disabled,ln.disabled,En.alphaBlended,rn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var R}}class vT{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,x){const T=h.getFreeCameraOptions().position,D=T.toAltitude(),R=T.toLngLat(),z=i.an(R.lng),V=i.an(R.lat),X=h.pixelsPerMeter/x,re=z*i.eM,ae=i.eM*Math.log(Math.tan(Math.PI/4+V/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 me=-this._offsetYPrev+ae,he=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+re)*X,this._accumulatedOffsetY+=me*X,this._accumulatedElevation+=he*X,this._offsetXPrev=re,this._offsetYPrev=ae,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function YS(C,h){return[-(C[0]-Math.floor(C[0]/h)*h),-(C[1]-Math.floor(C[1]/h)*h),-(C[2]-Math.floor(C[2]/h)*h)]}function uh(C){const h=i.eq(1323123451230),x=[];for(let T=0;T 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 x=h.context;if(!this.particlesVx){const T=uh(this.particlesCount),D=new i.eN,R=new i.b0;let z=0;const V=i.eq(1323123451230);for(let X=0;XT)return;const D=yu(0,1,x.revealStart,x.revealStart+x.revealRange,T);if(!this.particlesVx||!this.particlesIdx)return;const R=structuredClone(this._params);let z=[-R.direction.x,R.direction.y,-100];i.aw(z,z);const V=structuredClone(this._vignetteParams);V.strength*=D,R.overrideStyleParameters||(R.intensity=h.style.rain.state.density,R.timeFactor=h.style.rain.state.intensity,R.color=structuredClone(h.style.rain.state.color),z=structuredClone(h.style.rain.state.direction),R.screenThinning.intensity=h.style.rain.state.centerThinning,R.dropletSizeX=h.style.rain.state.dropletSize[0],R.dropletSizeYScale=h.style.rain.state.dropletSize[1]/h.style.rain.state.dropletSize[0],R.distortionStrength=100*h.style.rain.state.distortionStrength,V.strength=1,V.color=structuredClone(h.style.rain.state.vignetteColor));const X=this.updateOnRender(h,R.timeFactor),re=h.context,ae=re.gl,me=h.transform;this.screenTexture&&this.screenTexture.size[0]===h.width&&this.screenTexture.size[1]===h.height||(this.screenTexture=new i.T(re,{width:h.width,height:h.height,data:null},ae.RGBA8)),R.distortionStrength>0&&(re.activeTexture.set(ae.TEXTURE0),this.screenTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),ae.copyTexSubImage2D(ae.TEXTURE_2D,0,0,0,0,0,h.width,h.height));const he=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(re,he),re.activeTexture.set(ae.TEXTURE0),this.screenTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE);const pe=[R.color.r,R.color.g,R.color.b,R.color.a],Me=(Ce,$e)=>{const Be=YS(this._movement.getPosition(),Ce),Xe=R.dropletSizeX,ot=R.dropletSizeX*R.dropletSizeYScale,et=h.width/2,Ct=h.height/2,vt=yu(0,R.screenThinning.start,0,1,R.screenThinning.intensity),jt=yu(.001,R.screenThinning.range,0,1,R.screenThinning.intensity),xt=yu(0,R.screenThinning.particleOffset,0,1,R.screenThinning.intensity),pt=(Et={modelview:X.modelviewMatrix,projection:X.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Be,velocityConeAperture:R.velocityConeAperture,velocity:R.velocity,boxSize:Ce,rainDropletSize:[Xe,ot],distortionStrength:R.distortionStrength,rainDirection:z,color:pe,screenSize:[me.width,me.height],thinningCenterPos:[et,Ct],thinningShape:[vt,jt,Math.pow(10,R.screenThinning.fadePower)],thinningAffectedRatio:R.screenThinning.affectedRatio,thinningParticleOffset:xt,shapeDirectionalPower:R.shapeDirPower,shapeNormalPower:R.shapeNormalPower,mode:$e?0:1},{u_modelview:Float32Array.from(Et.modelview),u_projection:Float32Array.from(Et.projection),u_time:Et.time,u_cam_pos:Et.camPos,u_texScreen:0,u_velocityConeAperture:Et.velocityConeAperture,u_velocity:Et.velocity,u_boxSize:Et.boxSize,u_rainDropletSize:Et.rainDropletSize,u_distortionStrength:Et.distortionStrength,u_rainDirection:Et.rainDirection,u_color:Et.color,u_screenSize:Et.screenSize,u_thinningCenterPos:Et.thinningCenterPos,u_thinningShape:Et.thinningShape,u_thinningAffectedRatio:Et.thinningAffectedRatio,u_thinningParticleOffset:Et.thinningParticleOffset,u_shapeDirectionalPower:Et.shapeDirectionalPower,u_shapeNormalPower:Et.shapeNormalPower,u_mode:Et.mode});var Et;const Ht=Math.round(R.intensity*this.particlesCount),Ut=i.bg.simpleSegment(0,0,4*Ht,2*Ht);he.draw(h,ae.TRIANGLES,Er.disabled,ln.disabled,En.alphaBlended,rn.disabled,pt,"rain_particles",this.particlesVx,this.particlesIdx,Ut)};R.distortionStrength>0&&Me(R.boxSize,!0),Me(R.boxSize,!1),this._vignette.draw(h,V)}}const _T=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 bT extends Ay{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 Ff("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 x=h.context;if(!this.particlesVx){const T=uh(this.particlesCount),D=new i.eO,R=new i.b0;let z=0;const V=i.eq(1323123451230);for(let X=0;Xz)return;const V=yu(0,1,R.revealStart,R.revealStart+R.revealRange,z);D.strength*=V,x.overrideStyleParameters||(x.intensity=h.style.snow.state.density,x.timeFactor=h.style.snow.state.intensity,x.color=structuredClone(h.style.snow.state.color),T=structuredClone(h.style.snow.state.direction),x.screenThinning.intensity=h.style.snow.state.centerThinning,x.billboardSize=2.79*h.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(h.style.snow.state.vignetteColor));const X=this.updateOnRender(h,x.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const re=h.context,ae=re.gl,me=h.transform,he=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(re,he),((pe,Me,Ce)=>{const $e=YS(this._movement.getPosition(),pe),Be=me.width/2,Xe=me.height/2,ot=yu(0,Ce.screenThinning.start,0,1,Ce.screenThinning.intensity),et=yu(.001,Ce.screenThinning.range,0,1,Ce.screenThinning.intensity),Ct=yu(0,Ce.screenThinning.particleOffset,0,1,Ce.screenThinning.intensity),vt=(jt={modelview:X.modelviewMatrix,projection:X.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:$e,velocityConeAperture:Ce.velocityConeAperture,velocity:Ce.velocity,horizontalOscillationRadius:Ce.horizontalOscillationRadius,horizontalOscillationRate:Ce.horizontalOscillationRate,boxSize:pe,billboardSize:1*Ce.billboardSize,simpleShapeParameters:[Ce.shapeFadeStart,Ce.shapeFadePower],screenSize:[me.width,me.height],thinningCenterPos:[Be,Xe],thinningShape:[ot,et,Math.pow(10,Ce.screenThinning.fadePower)],thinningAffectedRatio:Ce.screenThinning.affectedRatio,thinningParticleOffset:Ct,color:[Ce.color.r,Ce.color.g,Ce.color.b,Ce.color.a],direction:T},{u_modelview:Float32Array.from(jt.modelview),u_projection:Float32Array.from(jt.projection),u_time:jt.time,u_cam_pos:jt.camPos,u_velocityConeAperture:jt.velocityConeAperture,u_velocity:jt.velocity,u_horizontalOscillationRadius:jt.horizontalOscillationRadius,u_horizontalOscillationRate:jt.horizontalOscillationRate,u_boxSize:jt.boxSize,u_billboardSize:jt.billboardSize,u_simpleShapeParameters:jt.simpleShapeParameters,u_screenSize:jt.screenSize,u_thinningCenterPos:jt.thinningCenterPos,u_thinningShape:jt.thinningShape,u_thinningAffectedRatio:jt.thinningAffectedRatio,u_thinningParticleOffset:jt.thinningParticleOffset,u_particleColor:jt.color,u_direction:jt.direction});var jt;const xt=Math.round(Ce.intensity*this.particlesCount),pt=i.bg.simpleSegment(0,0,4*xt,2*xt);this.particlesVx&&this.particlesIdx&&he.draw(h,ae.TRIANGLES,Er.disabled,ln.disabled,En.alphaBlended,rn.disabled,vt,"snow_particles",this.particlesVx,this.particlesIdx,pt)})(x.boxSize,0,x),this._vignette.draw(h,D)}}const cx={symbol:function(C,h,x,T,D){if(C.renderPass!=="translucent")return;const R=ln.disabled,z=C.colorModeForRenderPass(),V=x.layout.get("text-variable-anchor"),X=x.layout.get("text-size-scale-range"),re=i.aA(C.scaleFactor,X[0],X[1]);V&&function(he,pe,Me,Ce,$e,Be,Xe,ot){const et=pe.transform,Ct=$e==="map",vt=Be==="map";for(const jt of he){const xt=Ce.getTile(jt),pt=xt.getBucket(Me);if(!pt||!pt.text||!pt.text.segments.get().length)continue;const Et=i.bK(pt.textSizeData,et.zoom,ot),Ht=Qh(jt,pt.getProjection(),et),Ut=et.calculatePixelsToTileUnitsMatrix(xt),ts=Hs(Ht,xt.tileID.canonical,vt,Ct,et,pt.getProjection(),Ut),ss=pt.hasIconTextFit()&&pt.hasIconData();Et&&Zr(pt,Ct,vt,Xe,et,ts,jt,Math.pow(2,et.zoom-xt.tileID.overscaledZ),Et,ss)}}(T,C,x,h,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),D,re);const ae=x.paint.get("icon-opacity").constantOr(1)!==0,me=x.paint.get("text-opacity").constantOr(1)!==0;x.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(ae||me)?pb(C,h,x,T,R,z):(ae&&pb(C,h,x,T,R,z,{onlyIcons:!0}),me&&pb(C,h,x,T,R,z,{onlyText:!0})),h.map.showCollisionBoxes&&(vr(C,h,x,T,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),!0),vr(C,h,x,T,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),!1))},circle:function(C,h,x,T){if(C.renderPass!=="translucent")return;const D=x.paint.get("circle-opacity"),R=x.paint.get("circle-stroke-width"),z=x.paint.get("circle-stroke-opacity"),V=x.layout.get("circle-sort-key").constantOr(1)!==void 0,X=x.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(R.constantOr(1)===0||z.constantOr(1)===0))return;const re=C.context,ae=re.gl,me=C.transform,he=!(!C.terrain||!C.terrain.enabled),pe=x.layout.get("circle-elevation-reference"),Me=C.depthModeForSublayer(0,Er.ReadOnly),Ce=new Er(C.context.gl.LEQUAL,Er.ReadOnly,C.depthRangeFor3D),$e=pe==="none"||he?Me:Ce,Be=ln.disabled,Xe=C.colorModeForDrapableLayerRenderPass(X),ot=me.projection.name==="globe",et=[i.aF(me.center.lng),i.aJ(me.center.lat)],Ct=[];for(let jt=0;jtjt.sortKey-xt.sortKey);const vt={useDepthForOcclusion:me.depthOcclusionForSymbolsAndCircles};for(const jt of Ct){const{programConfiguration:xt,program:pt,layoutVertexBuffer:Et,dynamicBuffers:Ht,indexBuffer:Ut,uniformValues:ts,tile:ss}=jt.state,ps=jt.segments;C.terrain&&C.terrain.setupElevationDraw(ss,pt,vt),C.uploadCommonUniforms(re,pt,ss.tileID.toUnwrapped()),pt.draw(C,ae.TRIANGLES,$e,Be,Xe,rn.disabled,ts,x.id,Et,Ut,ps,x.paint,me.zoom,xt,Ht)}},heatmap:function(C,h,x,T){if(x.paint.get("heatmap-opacity")!==0)if(C.renderPass==="offscreen"){const D=C.context,R=D.gl,z=ln.disabled,V=new En([R.ONE,R.ONE,R.ONE,R.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(pe,Me,Ce,$e){const Be=pe.gl,Xe=Me.width*$e,ot=Me.height*$e;pe.activeTexture.set(Be.TEXTURE1),pe.viewport.set([0,0,Xe,ot]);let et=Ce.heatmapFbo;if(!et||et&&(et.width!==Xe||et.height!==ot)){et&&et.destroy();const Ct=Be.createTexture();Be.bindTexture(Be.TEXTURE_2D,Ct),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_WRAP_S,Be.CLAMP_TO_EDGE),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_WRAP_T,Be.CLAMP_TO_EDGE),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_MIN_FILTER,Be.LINEAR),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_MAG_FILTER,Be.LINEAR),et=Ce.heatmapFbo=pe.createFramebuffer(Xe,ot,1,null),function(vt,jt,xt,pt,Et,Ht){const Ut=vt.gl;Ut.texImage2D(Ut.TEXTURE_2D,0,vt.extRenderToTextureHalfFloat?Ut.RGBA16F:Ut.RGBA,Et,Ht,0,Ut.RGBA,vt.extRenderToTextureHalfFloat?Ut.HALF_FLOAT:Ut.UNSIGNED_BYTE,null),pt.colorAttachment0.set(xt)}(pe,0,Ct,et,Xe,ot)}else Be.bindTexture(Be.TEXTURE_2D,et.colorAttachment0.get()),pe.bindFramebuffer.set(et.framebuffer)})(D,C,x,C.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const X=C.transform,re=X.projection.name==="globe",ae=re?["PROJECTION_GLOBE_VIEW"]:[],me=re?rn.frontCCW:rn.disabled,he=[i.aF(X.center.lng),i.aJ(X.center.lat)];for(let pe=0;pe({u_image:0,u_color_ramp:1,u_opacity:me.paint.get("heatmap-opacity")}))(0,R),R.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,R.paint,D.transform.zoom)}(C,x))},line:function(C,h,x,T){if(C.renderPass!=="translucent")return;const D=x.paint.get("line-opacity"),R=x.paint.get("line-width");if(D.constantOr(1)===0||R.constantOr(1)===0)return;const z=x.paint.get("line-emissive-strength").isConstant(),V=x.paint.get("line-emissive-strength").constantOr(0),X=x.paint.get("line-occlusion-opacity"),re=x.layout.get("line-elevation-reference"),ae=x.layout.get("line-width-unit")==="meters",me=re==="sea",he=!(!C.terrain||!C.terrain.enabled),pe=C.context,Me=pe.gl;if(x.hasElevatedBuckets&&C.transform.projection.name==="globe")return;const Ce=x.layout.get("line-cross-slope"),$e=Ce!==void 0,Be=Ce<1,Xe=C.colorModeForDrapableLayerRenderPass(z?V:null),ot=C.terrain&&C.terrain.renderingToTexture,et=ot?1:i.o.devicePixelRatio,Ct=x.paint.get("line-dasharray"),vt=Ct.constantOr(1),jt=x.layout.get("line-cap"),xt=Ct.constantOr(null),pt=jt.constantOr(null),Et=x.paint.get("line-pattern"),Ht=Et.constantOr(1),Ut=x.paint.get("line-pattern-cross-fade"),ts=Et.constantOr(null),ss=x.paint.get("line-opacity").constantOr(1);let ps=!Ht&&ss!==1||C.depthOcclusion&&X>0&&X<1;const zs=x.paint.get("line-gradient"),Xt=Ht?"linePattern":"line",Dt=i.e2(x);let ls;if(ot&&C.terrain&&C.terrain.clipOrMaskOverlapStencilType()&&(ps=!1),X!==0&&C.depthOcclusion){const ur=x.paint._values["line-opacity"];ur&&ur.value&&ur.value.kind==="constant"?ls=ur.value:i.w(`Occlusion opacity for layer ${x.id} is supported only when line-opacity isn't data-driven.`)}R.value.kind!=="constant"&&R.value.isLineProgressConstant===!1&&Dt.push("VARIABLE_LINE_WIDTH"),ot&&(C.emissiveMode!=="dual-source-blending"||z?C.emissiveMode==="mrt-fallback"&&Dt.push("USE_MRT1"):Dt.push("DUAL_SOURCE_BLENDING"));const es=(ur,Ws,Bs,kr,br,or)=>{for(const mr of ur){const $r=h.getTile(mr);if(Ht&&!$r.patternsLoaded())continue;const jn=$r.getBucket(x);if(!jn||jn.elevationType!=="none"&&!br||jn.elevationType==="none"&&br)continue;C.prepareDrawTile();const da=[...Ws],Va=C.shadowRenderer,Tr=jn.elevationType==="road"&&!!Va&&Va.enabled;let Oa=[0,0,0];if(Tr){const Rn=C.style.directionalLight,zi=C.style.ambientLight;Rn&&zi&&(Oa=Pf(C.style,Rn,zi)),da.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const vn=jn.programConfigurations.get(x.id);let Ya=!1;if(ts&&$r.imageAtlas){const Rn=i.e3.from(ts),zi=Rn.getPrimary().scaleSelf(et).toString(),Mo=$r.imageAtlas.patternPositions.get(zi),oo=Rn.getSecondary(),_i=oo?$r.imageAtlas.patternPositions.get(oo.scaleSelf(et).toString()):null;Ya=!!Mo&&!!_i,Mo&&vn.setConstantPatternPositions(Mo,_i)}Ut>0&&(Ya||vn.getPatternTransitionVertexBuffer("line-pattern"))&&da.push("LINE_PATTERN_TRANSITION");const ui=C.isTileAffectedByFog(mr),ni=C.getOrCreateProgram(Xt,{config:vn,defines:da,overrideFog:ui});if(!Ht&&xt&&pt&&$r.lineAtlas){const Rn=$r.lineAtlas.getDash(xt,pt);Rn&&vn.setConstantPatternPositions(Rn)}Tr&&Va.setupShadows($r.tileID.toUnwrapped(),ni,"vector-tile");let[Ea,On]=x.paint.get("line-trim-offset");(pt==="round"||pt==="square")&&Ea!==On&&(Ea===0&&(Ea-=1),On===1&&(On+=1));const Za=ot?mr.projMatrix:null,po=ae?1/jn.tileToMeter/i.ay($r,1,C.transform.zoom):1,Vi=ae?1/jn.tileToMeter/i.ay($r,1,Math.floor(C.transform.zoom)):1,Xa=Ht?i.e4(C,$r,x,Za,et,po,Vi,[Ea,On],Oa,Ut):i.e5(C,$r,x,Za,jn.lineClipsArray.length,et,po,Vi,[Ea,On],Oa);if(zs){const Rn=jn.gradients[x.id];let zi=Rn.texture;if(x.gradientVersion!==Rn.version){let Mo=256;if(x.stepInterpolant){const oo=h.getSource().maxzoom,_i=mr.canonical.z===oo?Math.ceil(1<{ls!=null&&(ls.value=ss*X),ni.draw(C,Me.TRIANGLES,Bs,Rn,Xe,rn.disabled,Xa,x.id,jn.layoutVertexBuffer,jn.indexBuffer,jn.segments,x.paint,C.transform.zoom,vn,[jn.layoutVertexBuffer2,jn.patternVertexBuffer,jn.zOffsetVertexBuffer]),ls!=null&&(ls.value=ss)};if(ps&&!br){const Rn=C.stencilModeForClipping(mr).ref;Rn===0&&ot&&pe.clear({stencil:0});const zi={func:Me.EQUAL,mask:255};Xa.u_alpha_discard_threshold=.8,ja(new ln(zi,Rn,255,Me.KEEP,Me.KEEP,Me.INVERT)),Xa.u_alpha_discard_threshold=0,ja(new ln(zi,Rn,255,Me.KEEP,Me.KEEP,Me.KEEP))}else Xa.u_alpha_discard_threshold=ps&&br&&or?.8:0,ja(br?kr:C.stencilModeForClipping(mr))}};let As=C.depthModeForSublayer(0,Er.ReadOnly);const Xs=new Er(C.depthOcclusion?Me.GREATER:Me.LEQUAL,Er.ReadOnly,C.depthRangeFor3D);if(x.hasNonElevatedBuckets){const ur=!ot&&C.terrain;X!==0&&ur?i.w(`Occlusion opacity for layer ${x.id} is supported on terrain only if the layer has line-z-offset enabled.`):ur?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${x.id}.`):es(T,Dt,As,ln.disabled,!1,!0)}if(x.hasElevatedBuckets){re==="hd-road-markup"?he||(As=Xs,Dt.push("ELEVATED_ROADS")):(Dt.push("ELEVATED"),As=Xs,$e&&Dt.push(Be?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),me&&Dt.push("ELEVATION_REFERENCE_SEA"));const ur=ps?C.stencilModeFor3D():ln.disabled;C.forceTerrainMode=!0,es(T,Dt,As,ur,!0,!0),ps&&es(T,Dt,As,ur,!0,!1),C.forceTerrainMode=!1}ps&&(C.resetStencilClippingMasks(),ot&&pe.clear({stencil:0})),X===0||C.depthOcclusion||ot||C.layersWithOcclusionOpacity.push(C.currentLayer)},fill:function(C,h,x,T){const D=x.paint.get("fill-color"),R=x.paint.get("fill-opacity");if(R.constantOr(1)===0)return;const z=x.paint.get("fill-emissive-strength"),V=C.colorModeForDrapableLayerRenderPass(z),X=x.paint.get("fill-pattern"),re=C.opaquePassEnabledForLayer()&&!X.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&R.constantOr(0)===1?"opaque":"translucent";let ae="none";x.layout.get("fill-elevation-reference")!=="none"?ae="road":x.paint.get("fill-z-offset").constantOr(1)!==0&&(ae="offset");const me=!(!C.terrain||!C.terrain.enabled),he={painter:C,sourceCache:h,layer:x,coords:T,colorMode:V,elevationType:ae,terrainEnabled:me,pass:re};if(C.renderPass==="shadow")return void(C.shadowRenderer&&ae==="road"&&!me&&function(Me){const{painter:Ce,sourceCache:$e,layer:Be,coords:Xe}=Me,ot=Ce.context.gl,et=Me.painter.shadowRenderer;for(const Ct of Xe){const vt=$e.getTile(Ct),jt=vt.getBucket(Be);if(!jt)continue;const xt=jt.elevatedStructures;if(!xt||!xt.shadowCasterSegments||xt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ce.prepareDrawTile();const pt=jt.bufferData.programConfigurations.get(Be.id),Et=Ce.isTileAffectedByFog(Ct),Ht=Ce.getOrCreateProgram("elevatedStructuresDepth",{config:pt,overrideFog:Et}),Ut=et.calculateShadowPassMatrixFromTile(vt.tileID.toUnwrapped());Ce.uploadCommonUniforms(Ce.context,Ht,Ct.toUnwrapped());const ts={u_matrix:Ut,u_depth_bias:0};Ht.draw(Ce,ot.TRIANGLES,et.getShadowPassDepthMode(),ln.disabled,et.getShadowPassColorMode(),rn.disabled,ts,Be.id,xt.vertexBuffer,xt.indexBuffer,xt.shadowCasterSegments,Be.paint,Ce.transform.zoom,pt)}}(he));const pe=C.emissiveMode==="mrt-fallback";if(ae!=="offset"){if(zS(he,!1,pe),ae==="road"){const Me=!me&&C.renderPass==="translucent";Me&&FS(C,h,x,T,"geometry"),zS(he,!0,pe,ln.disabled),Me&&function(Ce){const{painter:$e,sourceCache:Be,layer:Xe,coords:ot,colorMode:et}=Ce,Ct=$e.context.gl,vt=Ce.painter.shadowRenderer,jt=!!vt&&vt.enabled,xt=new Er($e.context.gl.LEQUAL,Er.ReadOnly,$e.depthRangeFor3D);let pt=[0,0,0];if(jt){const Ht=$e.style.directionalLight,Ut=$e.style.ambientLight;Ht&&Ut&&(pt=Pf($e.style,Ht,Ut))}const Et=Ht=>{for(const Ut of ot){const ts=Be.getTile(Ut),ss=ts.getBucket(Xe);if(!ss)continue;const ps=ss.elevatedStructures;if(!ps)continue;let zs,Xt;if(Ht?(zs=ps.renderableBridgeSegments,Xt=ps.bridgeProgramConfigurations.get(Xe.id)):(zs=ps.renderableTunnelSegments,Xt=ps.tunnelProgramConfigurations.get(Xe.id)),!zs||zs.segments[0].primitiveLength===0)continue;Xt.updatePaintBuffers(),$e.prepareDrawTile();const Dt=$e.isTileAffectedByFog(Ut),ls=[];jt&&ls.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const es=$e.getOrCreateProgram("elevatedStructures",{config:Xt,overrideFog:Dt,defines:ls}),As=$e.translatePosMatrix(Ut.projMatrix,ts,Xe.paint.get("fill-translate"),Xe.paint.get("fill-translate-anchor"));jt&&vt.setupShadows(ts.tileID.toUnwrapped(),es,"vector-tile");const Xs=nx(As,pt);$e.uploadCommonUniforms($e.context,es,Ut.toUnwrapped()),es.draw($e,Ct.TRIANGLES,xt,ln.disabled,et,rn.backCCW,Xs,Xe.id,ps.vertexBuffer,ps.indexBuffer,zs,Xe.paint,$e.transform.zoom,Xt,[ps.vertexBufferNormal])}};Et(!0),Et(!1)}(he)}}else zS(he,!1,pe,C.stencilModeFor3D())},"fill-extrusion":function(C,h,x,T){const D=x.paint.get("fill-extrusion-opacity"),R=C.context,z=R.gl,V=C.terrain,X=V&&V.renderingToTexture;if(D===0)return;const re=C.emissiveMode==="mrt-fallback",ae=C.conflationActive&&C.style.isLayerClipped(x,h.getSource()),me=C.style.order.indexOf(x.fqid);if(ae&&function(he,pe,Me,Ce,$e){for(const Be of Ce){const Xe=pe.getTile(Be).getBucket(Me);Xe&&(Xe.updateReplacement(Be,he.replacementSource,$e),Xe.uploadCentroid(he.context))}}(C,h,x,T,me),V||ae)for(const he of T){const pe=h.getTile(he).getBucket(x);pe&&Bce(C.context,h,he,pe,x,V,ae)}if(C.renderPass==="shadow"&&C.shadowRenderer){const he=C.shadowRenderer;if(V&&D<.65&&x._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const pe=he.getShadowPassDepthMode(),Me=he.getShadowPassColorMode();BS(C,h,x,T,pe,ln.disabled,Me,ae)}else if(C.renderPass==="translucent"){const he=!x.paint.get("fill-extrusion-pattern").constantOr(1),pe=x.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!X&&pe.a!==0){const Me=new Er(C.context.gl.LEQUAL,Er.ReadWrite,C.depthRangeFor3D);D===1&&he?BS(C,h,x,T,Me,ln.disabled,En.unblended,ae):(BS(C,h,x,T,Me,ln.disabled,En.disabled,ae),BS(C,h,x,T,Me,C.stencilModeFor3D(),C.colorModeForRenderPass(),ae),C.resetStencilClippingMasks())}if(C.style.enable3dLights()&&he&&(!V&&C.transform.projection.name!=="globe"||X)){const Me=x.paint.get("fill-extrusion-opacity"),Ce=x.paint.get("fill-extrusion-ambient-occlusion-intensity"),$e=x.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Be=x.paint.get("fill-extrusion-flood-light-intensity"),Xe=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ot=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Xe?null:x.lut).toArray01().slice(0,3),et=Ce>0&&$e>0,Ct=Be>0,vt=(pt,Et,Ht)=>(1-Ht)*pt+Ht*Et,jt=new pT;jt.translate=x.paint.get("fill-extrusion-translate"),jt.translateAnchor=x.paint.get("fill-extrusion-translate-anchor"),jt.edgeRadius=x.layout.get("fill-extrusion-edge-radius"),jt.cutoffFadeRange=x.paint.get("fill-extrusion-cutoff-fade-range");const xt=pt=>{const Et=C.depthModeForSublayer(1,Er.ReadOnly,z.LEQUAL,!0),Ht=x.paint.get(pt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ut=vt(.1,3,Ht),ts=C._showOverdrawInspector;if(!ts){const ss=new ln({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),ps=new En([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Df(jt,C,h,x,T,Et,ss,ps,rn.disabled,pt,"sdf",Me,Ce,$e,Be,ot,Ut,ae,!1)}{const ss=ts?ln.disabled:new ln({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),ps=ts?C.colorModeForRenderPass():new En([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);Df(jt,C,h,x,T,Et,ss,ps,rn.disabled,pt,"color",Me,Ce,$e,Be,ot,Ut,ae,!1)}};if(X){const pt=()=>{const Ht=V.drapeBufferSize[0],Ut=V.drapeBufferSize[1];let ts=V.framebufferCopyTexture;return ts&&(!ts||ts.size[0]===Ht&&ts.size[1]===Ut)||(ts&&ts.destroy(),ts=V.framebufferCopyTexture=new i.T(R,new i.q({width:Ht,height:Ut}),z.RGBA8)),ts.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Ht,Ut),ts},Et=(Ht,Ut,ts)=>{const ss=C.depthModeForSublayer(1,Er.ReadOnly,z.LEQUAL,!1),ps=x.paint.get(Ht?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),zs=vt(.1,3,ps);{const Xt=new En([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);Df(jt,C,h,x,T,ss,ln.disabled,Xt,rn.disabled,Ht,"clear",Me,Ce,$e,Be,ot,zs,ae,Ut)}{const Xt=new ln({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),Dt=new En([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Df(jt,C,h,x,T,ss,Xt,Dt,rn.disabled,Ht,"sdf",Me,Ce,$e,Be,ot,zs,ae,Ut)}re&&!Ht&&(ts=pt());{const Xt=Ht?z.ZERO:z.ONE_MINUS_DST_ALPHA,Dt=new ln({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),ls=new En([Xt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);Df(jt,C,h,x,T,ss,Dt,ls,rn.disabled,Ht,"color",Me,Ce,$e,Be,ot,zs,ae,Ut)}if(!re||Ht){const Xt=new En([z.ONE,z.ONE,z.ONE,Ht?z.ZERO:z.ONE],i.ao.transparent,[!1,!1,!1,!0],Ht?z.FUNC_ADD:z.MAX);Df(jt,C,h,x,T,ss,ln.disabled,Xt,rn.disabled,Ht,"clear",Me,Ce,$e,Be,ot,zs,ae,Ut,ts)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Xt=new ln({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),Dt=new En([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);Df(jt,C,h,x,T,ss,Xt,Dt,rn.disabled,Ht,"emissive",Me,Ce,$e,Be,ot,zs,ae,Ut,ts),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(et||Ct){let Ht;C.prepareDrawTile(),re&&!et||(Ht=pt()),et&&Et(!0,!1,Ht),Ct&&Et(!1,!0,Ht)}}else et&&xt(!0),Ct&&xt(!1),(et||Ct)&&C.resetStencilClippingMasks()}}},building:function(C,h,x,T){C.currentLayer0&&R>0,re=!0;const ae=x.paint.get("building-vertical-scale");if(ae<=0)return;C.shadowRenderer||(re=!1);const me=C.conflationActive&&C.style.isLayerClipped(x,h.getSource()),he=C.style.order.indexOf(x.fqid);if(function(pe,Me,Ce,$e,Be,Xe){for(const ot of Xe){const et=Me.getTile(ot).getBucket(Ce);et&&(Be&&et.updateReplacement(ot,pe.replacementSource,$e),et.uploadUpdatedIndexBuffer(pe.context))}}(C,h,x,he,me,T),function(pe,Me,Ce,$e){for(const Be of $e){const Xe=Me.getTile(Be).getBucket(Ce);Xe&&Xe.needsEvaluation()&&Xe.uploadUpdatedColorBuffer(pe.context)}}(C,h,x,T),x.resetLayerRenderingStats(C),C.shadowRenderer&&(C.shadowRenderer.useNormalOffset=!0),C.renderPass==="shadow"&&C.shadowRenderer){const pe=C.shadowRenderer,Me=[],Ce=pe.getShadowPassDepthMode();fb({painter:C,source:h,layer:x,coords:T,defines:Me,blendMode:pe.getShadowPassColorMode(),depthMode:Ce,opacity:V,verticalScale:ae,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(C.renderPass==="translucent"){let pe=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];re&&(pe=pe.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),C.shadowRenderer&&C.shadowRenderer.useNormalOffset&&(pe=pe.concat("NORMAL_OFFSET"));const Me=x.paint.get("building-facade-emissive-chance"),Ce=x.paint.get("building-ambient-occlusion-intensity"),$e=x.paint.get("building-flood-light-intensity"),Be=x.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",Xe=x.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Be?null:x.lut).toArray01().slice(0,3),ot=x.paint.get("building-flood-light-ground-attenuation"),et=$e>0,Ct=new Er(C.context.gl.LEQUAL,Er.ReadWrite,C.depthRangeFor3D);V<1&&fb({painter:C,source:h,layer:x,coords:T,defines:pe,blendMode:En.disabled,depthMode:Ct,opacity:V,verticalScale:ae,facadeEmissiveChance:Me,facadeAOIntensity:Ce,floodLightIntensity:$e,floodLightColor:Xe,depthOnly:!0});const vt=C.colorModeForRenderPass();fb({painter:C,source:h,layer:x,coords:T,defines:pe,blendMode:vt,depthMode:Ct,opacity:V,verticalScale:ae,facadeEmissiveChance:Me,facadeAOIntensity:Ce,floodLightIntensity:$e,floodLightColor:Xe}),X&&$S(C,h,x,T,!0,V,D,R,$e,Xe,z,me),et&&$S(C,h,x,T,!1,V,D,R,$e,Xe,ot,me)}else if(C.renderPass==="light-beam"){const pe=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Me=new Er(C.context.gl.LEQUAL,Er.ReadOnly,C.depthRangeFor3D);fb({painter:C,source:h,layer:x,coords:T,defines:pe,blendMode:En.alphaBlended,depthMode:Me,opacity:V,verticalScale:ae,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}C.shadowRenderer&&(C.shadowRenderer.useNormalOffset=!1),C.resetStencilClippingMasks()},hillshade:function(C,h,x,T){if(C.renderPass!=="offscreen"&&C.renderPass!=="translucent"||C.style.disableElevatedTerrain)return;const D=C.context,R=C.terrain&&C.terrain.renderingToTexture,[z,V]=C.renderPass!=="translucent"||R?[{},T]:C.stencilConfigForOverlap(T);for(const X of V){const re=h.getTile(X);if(re.needsHillshadePrepare&&C.renderPass==="offscreen")Ace(C,re,x);else if(C.renderPass==="translucent"){const ae=C.depthModeForSublayer(0,Er.ReadOnly),me=x.paint.get("hillshade-emissive-strength"),he=C.colorModeForDrapableLayerRenderPass(me),pe=R&&C.terrain?C.terrain.stencilModeForRTTOverlap(X):z[X.overscaledZ];Tce(C,X,re,x,ae,pe,he)}}D.viewport.set([0,0,C.width,C.height]),C.resetStencilClippingMasks()},raster:function(C,h,x,T,D,R){if(C.renderPass!=="translucent"||x.paint.get("raster-opacity")===0)return;const z=C.transform.projection.name==="globe",V=x.paint.get("raster-elevation")!==0,X=V&&z;if(C.renderElevatedRasterBackface&&!X)return;const re=C.context,ae=re.gl,me=h.getSource(),he=function(vt,jt,xt,pt,Et){const Ht=jt.paint.get("raster-color"),Ut=vt.type==="raster-array",ts=[],ss=jt.paint.get("raster-resampling"),ps=jt.paint.get("raster-color-mix");let zs=jt.paint.get("raster-color-range");const Xt=[ps[0],ps[1],ps[2],0],Dt=ps[3];let ls=ss==="nearest"?pt.NEAREST:pt.LINEAR;if(Ut&&(ts.push("RASTER_ARRAY"),Ht||ts.push("RASTER_COLOR"),ss==="linear"&&ts.push("RASTER_ARRAY_LINEAR"),ls=pt.NEAREST,!zs&&vt.rasterLayers)){const es=vt.rasterLayers.find(({id:As})=>As===jt.sourceLayer);es&&es.fields&&es.fields.range&&(zs=es.fields.range)}if(zs=zs||[0,1],Ht){ts.push("RASTER_COLOR"),xt.activeTexture.set(pt.TEXTURE2),jt.updateColorRamp(zs);let es=jt.colorRampTexture;es||(es=jt.colorRampTexture=new i.T(xt,jt.colorRamp,pt.RGBA8)),es.bind(pt.LINEAR,pt.CLAMP_TO_EDGE)}return Et&&ts.push("USE_MRT1"),{mix:Xt,range:zs,offset:Dt,defines:ts,resampling:ls}}(me,x,re,ae,C.terrain&&C.terrain.renderingToTexture&&C.emissiveMode==="mrt-fallback");if(me instanceof i.aU&&!T.length&&!z)return;const pe=x.paint.get("raster-emissive-strength"),Me=C.colorModeForDrapableLayerRenderPass(pe),Ce=C.terrain&&C.terrain.renderingToTexture,$e=!C.options.moving,Be=x.paint.get("raster-resampling")==="nearest"?ae.NEAREST:ae.LINEAR;if(me instanceof i.aU&&!T.length&&(me.onNorthPole||me.onSouthPole)){const vt=V?C.stencilModeFor3D():ln.disabled;return void gb(!!me.onNorthPole,null,C,h,x,pe,he,rn.disabled,vt)}if(!T.length)return;const[Xe,ot]=me instanceof i.aU||Ce?[{},T]:C.stencilConfigForOverlap(T),et=ot[ot.length-1].overscaledZ;X&&he.defines.push("PROJECTION_GLOBE_VIEW"),V&&he.defines.push("RENDER_CUTOFF");const Ct=(vt,jt,xt)=>{for(const pt of vt){const Et=pt.toUnwrapped(),Ht=h.getTile(pt);if(Ce&&(!Ht||!Ht.hasData()))continue;re.activeTexture.set(ae.TEXTURE0);const Ut=Rf(Ht,me,x,he);if(!Ut||!Ut.texture)continue;const{texture:ts,mix:ss,offset:ps,tileSize:zs,buffer:Xt}=Ut;let Dt,ls;Ce?(Dt=Er.disabled,ls=pt.projMatrix):V?(Dt=new Er(ae.LEQUAL,Er.ReadWrite,C.depthRangeFor3D),ls=z?Float32Array.from(C.transform.expandedFarZProjMatrix):C.transform.calculateProjMatrix(Et,$e)):(Dt=C.depthModeForSublayer(pt.overscaledZ-et,x.paint.get("raster-opacity")===1?Er.ReadWrite:Er.ReadOnly,ae.LESS),ls=C.transform.calculateProjMatrix(Et,$e));const es=C.terrain&&Ce?C.terrain.stencilModeForRTTOverlap(pt):Xe[pt.overscaledZ],As=R?0:x.paint.get("raster-fade-duration");Ht.registerFadeDuration(As);const Xs=h.findLoadedParent(pt,0),ur=db(Ht,Xs,h,C.transform,As);let Ws,Bs;!ur.isFading&&Ht.refreshedUponExpiration&&(Ht.refreshedUponExpiration=!1),C.terrain&&C.terrain.prepareDrawTile(),re.activeTexture.set(ae.TEXTURE0),ts.bind(Be,ae.CLAMP_TO_EDGE),re.activeTexture.set(ae.TEXTURE1),Xs?(Xs.texture&&Xs.texture.bind(Be,ae.CLAMP_TO_EDGE),Ws=Math.pow(2,Xs.tileID.overscaledZ-Ht.tileID.overscaledZ),Bs=[Ht.tileID.canonical.x*Ws%1,Ht.tileID.canonical.y*Ws%1]):ts.bind(Be,ae.CLAMP_TO_EDGE),"useMipmap"in ts&&re.extTextureFilterAnisotropic&&C.transform.pitch>20&&ae.texParameterf(ae.TEXTURE_2D,re.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,re.extTextureFilterAnisotropicMax);const kr=C.transform;let br;const or=V?wD(kr):[0,0,0,0];let mr,$r,jn,da,Va,Tr=0;if(X&&me instanceof i.aU&&me.coordinates.length>3)mr=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),$r=Float32Array.from(kr.globeMatrix),jn=Float32Array.from(i.dF(kr)),da=[i.aF(kr.center.lng),i.aJ(kr.center.lat)],br=me.elevatedGlobePerspectiveTransform,Va=me.elevatedGlobeGridMatrix||new Float32Array(9);else if(X){const ui=i.dG(pt.canonical);Tr=i.dH(ui.getCenter().lat),mr=Float32Array.from(i.bk(i.dJ(pt.canonical))),$r=Float32Array.from(kr.globeMatrix),jn=Float32Array.from(i.dF(kr)),da=[i.aF(kr.center.lng),i.aJ(kr.center.lat)],br=[0,0],Va=Float32Array.from(i.dI(pt.canonical,ui,Tr,kr.worldSize/kr._pixelsPerMercatorPixel))}else br=me instanceof i.aU?me.perspectiveTransform:[0,0],mr=new Float32Array(16),$r=new Float32Array(9),jn=new Float32Array(16),da=[0,0],Va=new Float32Array(9);const Oa=fD(ls,mr,$r,jn,Va,Bs||[0,0],i.aj(C.transform.zoom),da,or,Ws||1,ur,x,br,V?x.paint.get("raster-elevation"):0,2,ss,ps,he.range,zs,Xt,pe),vn=C.isTileAffectedByFog(pt),Ya=C.getOrCreateProgram("raster",{defines:he.defines,overrideFog:vn});if(C.uploadCommonUniforms(re,Ya,Et),me instanceof i.aU){const ui=me.elevatedGlobeVertexBuffer,ni=me.elevatedGlobeIndexBuffer;if(Ce||!z)me.boundsBuffer&&me.boundsSegments&&Ya.draw(C,ae.TRIANGLES,Dt,ln.disabled,Me,rn.disabled,Oa,x.id,me.boundsBuffer,C.quadTriangleIndexBuffer,me.boundsSegments);else if(ui&&ni){const Ea=kr.zoom<=i.c_?me.elevatedGlobeSegments:me.getSegmentsForLongitude(kr.center.lng);Ea&&Ya.draw(C,ae.TRIANGLES,Dt,ln.disabled,Me,jt,Oa,x.id,ui,ni,Ea)}}else if(X){Dt=new Er(ae.LEQUAL,Er.ReadOnly,C.depthRangeFor3D);const ui=C.globeSharedBuffers;if(ui){const[ni,Ea,On]=ui.getGridBuffers(Tr,!1);Ya.draw(C,ae.TRIANGLES,Dt,xt||es,C.colorModeForRenderPass(),jt,Oa,x.id,ni,Ea,On)}}else{const{tileBoundsBuffer:ui,tileBoundsIndexBuffer:ni,tileBoundsSegments:Ea}=C.getTileBoundsBuffers(Ht);Ya.draw(C,ae.TRIANGLES,Dt,es,Me,rn.disabled,Oa,x.id,ui,ni,Ea)}}if(!(me instanceof i.aU)&&X)for(const pt of vt){const Et=pt.canonical.y===(1<>>16,2654435769),((pt=Math.imul(pt^pt>>>16,2654435769))>>>0)/4294967296},xt=1/1.1;for(let pt=0;pti.e9[es](ts));Xt.push(ts);const Dt=ts.canonical.x,ls=ts.canonical.y;for(const es of Xt){const As=et.getTile(Et?es.wrapped():es);if(!As)continue;const Xs=As.rasterParticleState;if(!Xs)continue;const ur=es.canonical.x+(1<jt.tileID)),pe&&(re.activeTexture.set(ae.TEXTURE0),C.imageManager.bind(C.context,x.scope));const vt=[];if(C.terrain&&C.terrain.renderingToTexture&&C.emissiveMode==="mrt-fallback"&&vt.push("USE_MRT1"),X){const jt=C.getOrCreateProgram(ot,{overrideFog:!1,overrideRtt:!0,defines:vt}),xt=new Float32Array(i.bA([])),pt=new i.aQ(0,0,0,0,0),Et=pe?ix(xt,V,z,C,0,x.scope,Me,X,{tileID:pt,tileSize:he}):hb(xt,V,z,D.toPremultipliedRenderColor(R?null:x.lut));jt.draw(C,ae.TRIANGLES,Be,$e,Xe,rn.disabled,Et,x.id,C.viewportBuffer,C.quadTriangleIndexBuffer,C.viewportSegments)}else for(const jt of Ct){const xt=C.isTileAffectedByFog(jt),pt=C.getOrCreateProgram(ot,{overrideFog:xt,defines:vt}),Et=jt.toUnwrapped(),Ht=T?jt.projMatrix:C.transform.calculateProjMatrix(Et);C.prepareDrawTile();const Ut=h?h.getTile(jt):et?et[jt.key]:new Xh(jt,he,me.zoom,C),ts=pe?ix(Ht,V,z,C,0,x.scope,Me,X,{tileID:jt,tileSize:he}):hb(Ht,V,z,D.toPremultipliedRenderColor(R?null:x.lut));C.uploadCommonUniforms(re,pt,Et);const{tileBoundsBuffer:ss,tileBoundsIndexBuffer:ps,tileBoundsSegments:zs}=C.getTileBoundsBuffers(Ut);pt.draw(C,ae.TRIANGLES,Be,$e,Xe,rn.disabled,ts,x.id,ss,ps,zs)}},sky:function(C,h,x){const T=C._atmosphere?i.aj(C.transform.zoom):1,D=x.paint.get("sky-opacity")*T;if(D===0)return;const R=C.context,z=x.paint.get("sky-type"),V=new Er(R.gl.LEQUAL,Er.ReadOnly,[0,1]),X=C.frameCounter/1e3%1;z==="atmosphere"?C.renderPass==="offscreen"?x.needsSkyboxCapture(C)&&(function(re,ae,me,he){const pe=re.context,Me=pe.gl;let Ce=ae.skyboxFbo;if(!Ce){Ce=ae.skyboxFbo=pe.createFramebuffer(32,32,1,null),ae.skyboxGeometry=new HS(pe),ae.skyboxTexture=pe.gl.createTexture(),Me.bindTexture(Me.TEXTURE_CUBE_MAP,ae.skyboxTexture),Me.texParameteri(Me.TEXTURE_CUBE_MAP,Me.TEXTURE_WRAP_S,Me.CLAMP_TO_EDGE),Me.texParameteri(Me.TEXTURE_CUBE_MAP,Me.TEXTURE_WRAP_T,Me.CLAMP_TO_EDGE),Me.texParameteri(Me.TEXTURE_CUBE_MAP,Me.TEXTURE_MIN_FILTER,Me.LINEAR),Me.texParameteri(Me.TEXTURE_CUBE_MAP,Me.TEXTURE_MAG_FILTER,Me.LINEAR);for(let ot=0;ot<6;++ot)Me.texImage2D(Me.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,Me.RGBA,32,32,0,Me.RGBA,Me.UNSIGNED_BYTE,null)}pe.bindFramebuffer.set(Ce.framebuffer),pe.viewport.set([0,0,32,32]);const $e=ae.getCenter(re,!0),Be=re.getOrCreateProgram("skyboxCapture"),Xe=new Float64Array(16);i.bA(Xe),i.en(Xe,Xe,.5*-Math.PI),My(re,ae,Be,Xe,$e,0),i.bA(Xe),i.en(Xe,Xe,.5*Math.PI),My(re,ae,Be,Xe,$e,1),i.bA(Xe),i.cU(Xe,Xe,.5*-Math.PI),My(re,ae,Be,Xe,$e,2),i.bA(Xe),i.cU(Xe,Xe,.5*Math.PI),My(re,ae,Be,Xe,$e,3),i.bA(Xe),My(re,ae,Be,Xe,$e,4),i.bA(Xe),i.en(Xe,Xe,Math.PI),My(re,ae,Be,Xe,$e,5),pe.viewport.set([0,0,re.width,re.height])}(C,x),x.markSkyboxValid(C)):C.renderPass==="sky"&&function(re,ae,me,he,pe){const Me=re.context,Ce=Me.gl,$e=re.transform,Be=re.getOrCreateProgram("skybox");Me.activeTexture.set(Ce.TEXTURE0),Ce.bindTexture(Ce.TEXTURE_CUBE_MAP,ae.skyboxTexture);const Xe=((ot,et,Ct,vt,jt)=>({u_matrix:ot,u_sun_direction:et,u_cubemap:0,u_opacity:vt,u_temporal_offset:jt}))($e.skyboxMatrix,ae.getCenter(re,!1),0,he,pe);re.uploadCommonUniforms(Me,Be),Be.draw(re,Ce.TRIANGLES,me,ln.disabled,re.colorModeForRenderPass(),rn.backCW,Xe,"skybox",ae.skyboxGeometry.vertexBuffer,ae.skyboxGeometry.indexBuffer,ae.skyboxGeometry.segment)}(C,x,V,D,X):z==="gradient"&&C.renderPass==="sky"&&function(re,ae,me,he,pe){const Me=re.context,Ce=Me.gl,$e=re.transform,Be=re.getOrCreateProgram("skyboxGradient");ae.skyboxGeometry||(ae.skyboxGeometry=new HS(Me)),Me.activeTexture.set(Ce.TEXTURE0);let Xe=ae.colorRampTexture;Xe||(Xe=ae.colorRampTexture=new i.T(Me,ae.colorRamp,Ce.RGBA8)),Xe.bind(Ce.LINEAR,Ce.CLAMP_TO_EDGE);const ot=((et,Ct,vt,jt,xt)=>({u_matrix:et,u_color_ramp:0,u_center_direction:Ct,u_radius:i.an(vt),u_opacity:jt,u_temporal_offset:xt}))($e.skyboxMatrix,ae.getCenter(re,!1),ae.paint.get("sky-gradient-radius"),he,pe);re.uploadCommonUniforms(Me,Be),Be.draw(re,Ce.TRIANGLES,me,ln.disabled,re.colorModeForRenderPass(),rn.backCW,ot,"skyboxGradient",ae.skyboxGeometry.vertexBuffer,ae.skyboxGeometry.indexBuffer,ae.skyboxGeometry.segment)}(C,x,V,D,X)},custom:function(C,h,x,T){const D=C.context,R=x.implementation;if(!C.transform.projection.unsupportedLayers||!C.transform.projection.unsupportedLayers.includes("custom")||C.terrain&&(C.terrain.renderingToTexture||C.renderPass==="offscreen")&&x.isDraped(h)){if(C.renderPass==="offscreen"){const z=R.prerender;if(z){if(C.setCustomLayerDefaults(),D.setColorMode(C.colorModeForRenderPass()),C.transform.projection.name==="globe"){const V=C.transform.pointMerc;z.call(R,D.gl,C.transform.customLayerMatrix(),C.transform.getProjection(),C.transform.globeToMercatorMatrix(),i.aj(C.transform.zoom),[V.x,V.y],C.transform.pixelsPerMeterRatio)}else z.call(R,D.gl,C.transform.customLayerMatrix());D.setDirty(),C.setBaseState()}}else if(C.renderPass==="translucent"){if(C.terrain&&C.terrain.renderingToTexture){const V=R.renderToTile;if(V){const X=T[0].canonical,re={x:X.x+T[0].wrap*(R.wrapTileId?0:1<{re&&(re.useNormalOffset=!0,ae||(re.enabled=!0))},he=h.getSource();if(C.renderPass==="light-beam"&&he.type!=="batched-model")return;if(he.type==="vector"||he.type==="geojson")return function(et,Ct,vt,jt,xt){const pt=et.transform,Et=pt.projection.name==="globe",Ht=pt.getFreeCameraOptions().position;if(!et.modelManager)return;const Ut=et.modelManager;vt.modelManager=Ut;const ts=et.shadowRenderer;if(!vt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ss=vt._unevaluatedLayout._values["model-id"],ps=Object.assign({},vt.layout.get("model-id").parameters),zs=et.style.order.indexOf(vt.fqid),Xt=vt.paint.get("model-opacity").constantOr(1);for(const Dt of jt){const ls=Ct.getTile(Dt).getBucket(vt);if(!ls||ls.projection.name!==pt.projection.name)continue;const es=ls.getModelUris();if(es&&!ls.modelsRequested&&(Ut.addModelsFromBucket(es,xt),ls.modelsRequested=!0),Et)ps.zoom=Dt.overscaledZ;else{const or=Kd(Dt,pt);ps.zoom=or}const As=ss.possiblyEvaluate(ps);if(ID(et,ls,Dt),Ip.shadowUniformsInitialized=!1,Ip.useSingleShadowCascade=!!ts&&ts.getMaxCascadeForTile(Dt.toUnwrapped())===0,et.renderPass==="shadow"&&ts){if(et.currentShadowCascade===1&&ls.isInsideFirstShadowMapFrustum)continue;const or=pt.calculatePosMatrix(Dt.toUnwrapped(),pt.worldSize);if(Ip.tileMatrix.set(or),Ip.shadowTileMatrix=Float32Array.from(ts.calculateShadowPassMatrixFromMatrix(or)),Ip.aabb.min=[0,0,0],Ip.aabb.max[0]=Ip.aabb.max[1]=i.al,Ip.aabb.max[2]=0,Uce(ls,Ip,et,vt.scope))continue}const Xs=1<0&&et.style.isLayerClipped(vt,Ct.getSource())&&ls.updateReplacement(Dt,et.replacementSource,zs,vt.scope)&&(ls.uploaded=!1,ls.upload(et.context));let Ws=0;const Bs=new Array,kr=new Array,br=new Array;for(let or in ls.instancesPerModel){const mr=ls.instancesPerModel[or];mr.features.length>0&&!Et&&(or=As.evaluate(mr.features[0].feature,{}));const $r=Ut.getModel(or,xt);if($r||Ut.hasURLBeenRequested(or)||ls.modelUris.includes(or)||(ls.modelUris.push(or),ls.modelsRequested=!1),$r&&$r.uploaded)if(Et){const jn=i.c5([],[Ht.x,Ht.y,Ht.z],et.transform.worldSize);i.ew(jn,jn);for(let da=0;da0&&Oa.elevationUpdate(or.terrain,da,Tr,$r.source),Oa.needsReEvaluation(or,Va,$r)&&Oa.evaluate($r))}})(et,Ct,vt,jt),function(){let or,mr,$r;Bs?(or=jt.length-1,mr=-1,$r=-1):(or=0,mr=jt.length,$r=1);const jn=new Float64Array(16),da=i.cA(),Va=new i.P(0,0);for(let Tr=or;Tr!==mr;Tr+=$r){const Oa=jt[Tr],vn=Ct.getTile(Oa).getBucket(vt);if(!vn||!vn.uploaded)continue;let Ya=!1;Ht&&(Ya=Ht.getMaxCascadeForTile(Oa.toUnwrapped())===0);const ui=pt.calculatePosMatrix(Oa.toUnwrapped(),pt.worldSize),ni=vn.modelTraits;!Xs&&Bs&&(i.bl(jn,ui),i.af(da,ts,jn),Va.x=da[0],Va.y=da[1]);const Ea=[];vn.setFilter(vt.filter);for(const On of vn.getNodesInfo()){if(On.hiddenByReplacement||!On.node.meshes)continue;const Za=On.node;let po=0;et.terrain&&Za.elevation&&(po=Za.elevation*et.terrain.exaggeration());const Vi=(()=>{const ud=On.aabb;return As.min=[...ud.min],As.max=[...ud.max],As.min[2]+=po,As.max[2]+=po,i.af(As.min,As.min,ui),i.af(As.max,As.max,ui),As})(),Xa=On.evaluatedScale;if(Xa[0]<=1&&Xa[1]<=1&&Xa[2]<=1&&Vi.intersects(ur)===0)continue;if(!Xs&&Bs){const ud=.16666666666666666;On.cameraCollisionOpacity=ts[0]>Vi.min[0]&&ts[0]Vi.min[1]&&ts[1]!Bs||On.opacity===1&&Za.opacity===1?On.depthZa.depth?-1:1);for(const On of Ea){const Za=On.nodeInfo,po=Za.node;let Vi=i.aB([],Xt,On.tileModelMatrix);i.aB(Vi,ps,Vi);const Xa=i.bl([],Vi);i.eg(Xa,Xa),i.cS(Xa,Xa,yb),Vi=i.aB(Vi,Vi,po.globalMatrix);const ja=et.renderPass==="light-beam",Rn=vt.paint.get("model-color-use-theme").constantOr("default")==="none",zi=ni&i.eI.HasMapboxMeshFeatures,Mo=zi?0:Za.evaluatedRMEA[0][2];for(let oo=0;oo=xs||lo>=xs}}const Mc=_i.material;let mh;Mc.occlusionTexture&&Mc.occlusionTexture.offsetScale&&(mh=Mc.occlusionTexture.offsetScale,_l.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const im=et.getOrCreateProgram("model",_l);!Xs&&Ht&&Ht.setupShadowsFromMatrix(On.tileModelMatrix,im,Ht.useNormalOffset),et.uploadCommonUniforms(xt,im,null,hd);const _u=Mc.pbrMetallicRoughness;_u.metallicFactor=.9,_u.roughnessFactor=.5;const bo=jy(new Float32Array(Qc),new Float32Array(Vi),new Float32Array(Xa),new Float32Array(po.globalMatrix),et,On.opacity,_u.baseColorFactor,Mc.emissiveFactor,_u.metallicFactor,_u.roughnessFactor,Mc,Mo,vt,[0,0,0],mh);!Zd&&(Za.hasTranslucentParts||On.opacity<1)&&im.draw(et,xt.gl.TRIANGLES,ls,ln.disabled,En.disabled,rn.backCCW,bo,vt.id,_i.vertexBuffer,_i.indexBuffer,_i.segments,vt.paint,et.transform.zoom,void 0,ud),im.draw(et,xt.gl.TRIANGLES,Zd?es:ls,ln.disabled,Zd||On.opacity<1||Za.hasTranslucentParts?En.alphaBlended:En.unblended,rn.backCCW,bo,vt.id,_i.vertexBuffer,_i.indexBuffer,_i.segments,vt.paint,et.transform.zoom,void 0,ud)}}}}()}(C,h,x,T),void me();if(he.type!=="model")return;const pe=he.getModels(),Me=[],Ce=C.transform.getFreeCameraOptions().position,$e=i.c5([],[Ce.x,Ce.y,Ce.z],C.transform.worldSize);i.ew($e,$e);const Be=[],Xe=[];let ot=0;for(const et of pe){const Ct=h.getFeatureState("",et.id),vt={type:"Unknown",id:et.id,properties:et.featureProperties},jt=x.paint.get("model-rotation").evaluate(vt,Ct),xt=x.paint.get("model-scale").evaluate(vt,Ct),pt=x.paint.get("model-translation").evaluate(vt,Ct),Et=x.paint.get("model-opacity").evaluate(vt,Ct);AD(x,et.id,Ct,et.featureProperties,et.nodeOverrideNames,et.nodeOverrides),ED(x,et.id,Ct,et.featureProperties,et.materialOverrideNames,et.materialOverrides),et.nodeOverrides.size>0&&et.computeBoundsAndApplyParent(),et.computeModelMatrix(C,jt,xt,pt,V,z,!1);const Ht=i.bA([]),Ut=i.ef(et.position.lat,C.transform.zoom),ts=i.bq([],[1,1,1/Ut]);i.br(Ht,Ht,$e),Me.push({zScaleMatrix:ts,negCameraPosMatrix:Ht});for(const ss of et.nodes)Ty(C,ss,et.matrix,C.transform.expandedFarZProjMatrix,ot,Be,Xe,et.materialOverrides,Et);ot++}if(Be.sort((et,Ct)=>Ct.depth-et.depth),C.renderPass!=="shadow")PD(C,x,Be,Xe,Me),me();else{for(const et of Xe)qm(et.mesh,et.nodeModelMatrix,C,x);for(const et of Be)qm(et.mesh,et.nodeModelMatrix,C,x);me()}}},QS={line:function(C,h,x){if(C.hasElevatedBuckets=!1,C.hasNonElevatedBuckets=!1,C._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||C._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(h){const T=h.getVisibleCoordinates();for(const D of T){const R=h.getTile(D).getBucket(C);if(R&&(R.elevationType!=="none"?C.hasElevatedBuckets=!0:C.hasNonElevatedBuckets=!0,C.hasElevatedBuckets&&C.hasNonElevatedBuckets))break}}}else C.hasNonElevatedBuckets=!0},model:function(C,h,x){const T=h.getSource();if(!T.loaded())return;if(T.type==="vector"||T.type==="geojson")return void(x.modelManager&&x.modelManager.upload(x,xb(x,C)));if(T.type==="batched-model"||T.type!=="model")return;const D=T.getModels();for(const R of D)R.upload(x.context)},raster:function(C,h,x){const T=h.getSource();if(!(T instanceof Zc&&T.loaded()))return;const D=C.sourceLayer||T.rasterLayerIds&&T.rasterLayerIds[0];if(!D)return;const R=C.paint.get("raster-array-band")||T.getInitialBand(D);if(R==null)return;const z=h.getIds().map(V=>h.getTileByID(V));for(const V of z)V.updateNeeded(C.id,R)&&T.prepareTile(V,D,C.id,R)},"raster-particle":function(C,h,x){const T=h.getSource();if(!(T instanceof Zc&&T.loaded()))return;const D=C.sourceLayer||T.rasterLayerIds&&T.rasterLayerIds[0];if(!D)return;const R=C.paint.get("raster-particle-array-band")||T.getInitialBand(D);if(R==null)return;const z=h.getIds().map(V=>h.getTileByID(V));for(const V of z)V.updateNeeded(C.id,R)&&T.prepareTile(V,D,C.id,R)}},hh={fill:FS},JS={fill:function(C,h,x,T){if(!x.layout||x.layout.get("fill-elevation-reference")==="none"||x.paint.get("fill-opacity").constantOr(1)===0)return;const D=C.context.gl,R=new Er(D.LEQUAL,Er.ReadOnly,C.depthRangeFor3D),z=new ln({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),V=C.transform.getFreeCameraOptions().position,X=C.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const re of T){const ae=h.getTile(re),me=ae.getBucket(x);if(!me)continue;const he=me.elevatedStructures;if(!he||he.depthSegments.segments[0].primitiveLength===0)continue;const pe=bD(re.toUnwrapped(),V),Me=C.translatePosMatrix(re.projMatrix,ae,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor")),Ce=wy(Me,pe,0,1,0);X.draw(C,D.TRIANGLES,R,z,En.disabled,rn.disabled,Ce,x.id,he.vertexBuffer,he.indexBuffer,he.depthSegments,x.paint,C.transform.zoom)}}};class eC{constructor(h,x,T,D,R){this.context=new yv(h,x),this.transform=T,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 X of z)this._debugParams.enabledLayers[X]=!0;for(const X of z);this.occlusionParams=new _v,this.setup(),this.numSublayers=ul.maxUnderzooming+ul.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 iv(this),this._wireframeDebugCache=new lx,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const V=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,V,h.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.worldview=R,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(h,x){const T=!!h&&!!h.terrain&&this.transform.projection.supportsTerrain;if(!(T||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new aT(this,h));const D=this._terrain;this.transform.elevation=T?D:null,D.update(h,this.transform,x),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(h){const x=h.fog;if(!x||this.transform.projection.name==="globe"||x.getOpacity(this.transform.pitch)<1||x.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[T,D]=x.getFovAdjustedRange(this.transform._fov);if(T>D)return void(this.transform.fogCullDistSq=null);const R=T+.78*(D-T);this.transform.fogCullDistSq=R*R}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 aT(this,this.style)),this._forceTerrainMode=h}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(h,x){if(this.width=h*i.o.devicePixelRatio,this.height=x*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const T of this.style.order)this.style._mergedLayers[T].resize()}setup(){const h=this.context,x=new i.bd;x.emplaceBack(0,0),x.emplaceBack(i.al,0),x.emplaceBack(0,i.al),x.emplaceBack(i.al,i.al),this.tileExtentBuffer=h.createVertexBuffer(x,i.bf.members),this.tileExtentSegments=i.bg.simpleSegment(0,0,4,2);const T=new i.bd;T.emplaceBack(0,0),T.emplaceBack(i.al,0),T.emplaceBack(0,i.al),T.emplaceBack(i.al,i.al),this.debugBuffer=h.createVertexBuffer(T,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 R=new i.b1;R.emplaceBack(0,0,0,0),R.emplaceBack(i.al,0,i.al,0),R.emplaceBack(0,i.al,0,i.al),R.emplaceBack(i.al,i.al,i.al,i.al),this.mercatorBoundsBuffer=h.createVertexBuffer(R,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 V=new i.be;for(const re of[0,1,3,2,0])V.emplaceBack(re);this.debugIndexBuffer=h.createIndexBuffer(V),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 X=this.context.gl;this.stencilClearMode=new ln({func:X.ALWAYS,mask:0},0,255,X.ZERO,X.ZERO,X.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,Er.disabled,this.stencilClearMode,En.disabled,rn.disabled,cb(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,x,T){if(!x||this.currentStencilSource===x.id||!h.isTileClipped()||!T||T.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let V=!1;for(const X of T)if(this._tileClippingMaskIDs[X.key]===void 0){V=!0;break}if(!V)return}this.currentStencilSource=x.id;const D=this.context,R=D.gl;this.nextStencilID+T.length>256&&this.clearStencil(),D.setColorMode(En.disabled),D.setDepthMode(Er.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const V of T){const X=x.getTile(V),re=this._tileClippingMaskIDs[V.key]=this.nextStencilID++,{tileBoundsBuffer:ae,tileBoundsIndexBuffer:me,tileBoundsSegments:he}=this.getTileBoundsBuffers(X);z.draw(this,R.TRIANGLES,Er.disabled,new ln({func:R.ALWAYS,mask:0},re,255,R.KEEP,R.KEEP,R.REPLACE),En.disabled,rn.disabled,cb(V.projMatrix),"$clipping",ae,me,he)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,x=this.context.gl;return new ln({func:x.NOTEQUAL,mask:255},h,255,x.KEEP,x.KEEP,x.REPLACE)}stencilModeForClipping(h){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(h);const x=this.context.gl;return new ln({func:x.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,x.KEEP,x.KEEP,x.REPLACE)}stencilConfigForOverlap(h){const x=this.context.gl,T=h.sort((z,V)=>V.overscaledZ-z.overscaledZ),D=T[T.length-1].overscaledZ,R=T[0].overscaledZ-D+1;if(R>1){this.currentStencilSource=void 0,this.nextStencilID+R>256&&this.clearStencil();const z={};for(let V=0;Vthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((h,x)=>h+x/this._fpsHistory.length,0))}render(h,x){const T=i.o.now();this._dt=T-this._timeStamp,this._timeStamp=T,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=h.map.repaint,this.style=h,this.options=x;const D=this.style._mergedLayers,R=!(!this.terrain||!this.terrain.enabled),z=()=>this.style._getOrder(R).filter(Xt=>{const Dt=D[Xt];return!(Dt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Dt.type]});let V=z(),X=!1,re=!1,ae=null,me=0,he=!1;for(const Xt of V){const Dt=D[Xt];Dt.visibility!=="none"&&(Dt.type==="circle"?X=!0:Dt.type==="building"?(ae=Dt,++me):Dt.type==="symbol"&&(Dt.hasOcclusionOpacityProperties?re=!0:X=!0))}this.updateEmissiveMode();let pe=V.map(Xt=>D[Xt]);const Me=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 Me){const Dt=Me[Xt];Dt.used&&(Dt.prepare(this.context),Dt.getSource().usedInConflation&&++me)}let Ce=!1;for(const Xt of pe)Xt.isHidden(this.transform.zoom)||(Xt.type==="clip"&&(Ce=!0),this.prepareLayer(Xt));const $e={},Be={},Xe={},ot={},et={};for(const Xt in Me){const Dt=Me[Xt];$e[Xt]=Dt.getVisibleCoordinates(),Be[Xt]=$e[Xt].slice().reverse(),Xe[Xt]=Dt.getVisibleCoordinates(!0).reverse(),ot[Xt]=Dt.getShadowCasterCoordinates(),et[Xt]=Dt.sortCoordinatesByDistance($e[Xt])}const Ct=Xt=>{const Dt=this.style.getLayerSourceCache(Xt);return Dt&&Dt.used?Dt.getSource():null};if(me||Ce||this._clippingActiveLastFrame){const Xt=[],Dt=[];let ls=0;for(const es of pe)this.isSourceForClippingOrConflation(es,Ct(es))&&(Xt.push(es),Dt.push(ls)),ls++;if(Xt&&(Ce||Xt.length>1)||this._clippingActiveLastFrame){Ce=!1;const es=[];for(let As=0;As0){const es=Ct(Dt);es&&(this.minCutoffZoom=Math.max(es.minzoom,this.minCutoffZoom)),Dt.minzoom&&(this.minCutoffZoom=Math.max(Dt.minzoom,this.minCutoffZoom))}Dt.is3D(R)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Xt),this._lastOcclusionLayer=Xt)}const vt=this.style&&this.style.fog;vt?(this._fogVisible=vt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=vt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(Xe),this.opaquePassCutoff=0,V=z(),pe=V.map(Xt=>D[Xt]));const jt=this._shadowRenderer;if(jt){jt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Xt in Me)for(const Dt of $e[Xt]){let ls={min:0,max:0};this.terrain&&(ls=this.terrain.getMinMaxForTile(Dt)||ls),jt.addShadowReceiver(Dt.toUnwrapped(),ls.min,ls.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 TD(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const xt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),pt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(xt&&!this._snow&&(this._snow=new bT(this)),!xt&&this._snow&&(this._snow.destroy(),delete this._snow),pt&&!this._rain&&(this._rain=new XS(this)),!pt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),ae){this.buildingTileBorderManager||(this.buildingTileBorderManager=new WS);const Xt=this.style.getLayerSourceCache(ae);this.buildingTileBorderManager.updateBorders(Xt,ae)}if(!at.has(this.context.gl))return;this.renderPass="offscreen";for(const Xt of pe){const Dt=h.getLayerSourceCache(Xt);if(!Xt.hasOffscreenPass()||Xt.isHidden(this.transform.zoom))continue;const ls=Dt?Be[Dt.id]:void 0;(Xt.type==="custom"||Xt.type==="raster"||Xt.type==="raster-particle"||Xt.isSky()||ls&&ls.length)&&this.renderLayer(this,Dt,Xt,ls)}this.depthRangeFor3D=[0,1-(pe.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,ot)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Et=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ht=(()=>{if(x.showOverdrawInspector)return i.ao.black;const Xt=this.style.fog;if(Xt&&this.transform.projection.supportsFog){const Dt=this.style.getLut(Xt.scope);if(!Et){const ls=Xt.properties.get("color-use-theme")==="none",es=Xt.properties.get("color").toNonPremultipliedRenderColor(ls?null:Dt).toArray01();return new i.ao(...es)}if(Et){const ls=Xt.properties.get("space-color-use-theme")==="none",es=Xt.properties.get("space-color").toNonPremultipliedRenderColor(ls?null:Dt).toArray01();return new i.ao(...es)}}return i.ao.transparent})();if(this.context.clear({color:Ht,depth:1}),this.clearStencil(),this._showOverdrawInspector=x.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Et&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=V.length-1;this.currentLayer>=0;this.currentLayer--){const Xt=pe[this.currentLayer],Dt=h.getLayerSourceCache(Xt);if(Xt.isSky())continue;const ls=Dt?(Xt.is3D(R)?et:Be)[Dt.id]:void 0;this._renderTileClippingMasks(Xt,Dt,ls),this.renderLayer(this,Dt,Xt,ls)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Et&&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()&&--ts==0){{this.clearStencil(),this.resetStencilClippingMasks();const ls=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const ls=this.currentLayer;this.depthOcclusion=!0;for(const es of this.layersWithOcclusionOpacity){this.currentLayer=es;const As=pe[this.currentLayer],Xs=h.getLayerSourceCache(As),ur=Xs?Be[Xs.id]:void 0;this.terrain||this._renderTileClippingMasks(As,Xs,Xs?$e[Xs.id]:void 0),this.renderLayer(this,Xs,As,ur)}this.depthOcclusion=!1,this.currentLayer=ls,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;pe.forEach(Dt=>{const ls=h.getLayerSourceCache(Dt);ls&&!Dt.isHidden(this.transform.zoom)&&ls.getVisibleCoordinates().length&&(!Xt||Xt.getSource().maxzoom0?x.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(h,x,T){const D=T===void 0?this.terrain&&this.terrain.renderingToTexture:T,R=[];return this.style&&this.style.enable3dLights()&&(h==="globeRaster"||h==="terrainRaster"?(R.push("LIGHTING_3D_MODE"),R.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):D||R.push("LIGHTING_3D_MODE")),this.renderPass==="shadow"&&(this._shadowMapDebug||R.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(R.push("TERRAIN"),this.linearFloatFilteringSupported()&&R.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&R.push("GLOBE"),!this._fogVisible||D||x!==void 0&&!x||R.push("FOG","FOG_DITHERING"),D&&R.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&R.push("OVERDRAW_INSPECTOR"),R}getOrCreateProgram(h,x){this.cache=this.cache||{};const T=x&&x.defines||[],D=x&&x.config,R=this.currentGlobalDefines(h,x&&x.overrideFog,x&&x.overrideRtt).concat(T),z=lD.cacheKey(WM[h],h,R,D);return this.cache[z]||(this.cache[z]=new lD(this.context,h,WM[h],D,RS[h],R)),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,x){if(this.style.enable3dLights()){const T=this.style.directionalLight,D=this.style.ambientLight;if(T&&D){const R=((z,V,X)=>{const re=z.properties.get("direction"),ae=z.properties.get("color-use-theme")==="none",me=z.properties.get("color").toNonPremultipliedRenderColor(ae?null:X.getLut(z.scope)).toArray01(),he=z.properties.get("intensity"),pe=V.properties.get("color-use-theme")==="none",Me=V.properties.get("color").toNonPremultipliedRenderColor(pe?null:X.getLut(V.scope)).toArray01(),Ce=V.properties.get("intensity"),$e=[re.x,re.y,re.z],Be=i.dN(Me,Ce),Xe=i.dN(me,he);return{u_lighting_ambient_color:Be,u_lighting_directional_dir:$e,u_lighting_directional_color:Xe,u_ground_radiance:fv($e,Xe,Be)}})(T,D,this.style);x.setLightsUniformValues(h,R)}}}uploadCommonUniforms(h,x,T,D,R){if(this.uploadCommonLightUniforms(h,x),this.terrain&&this.terrain.renderingToTexture)return;const z=this.style.fog;if(z){const V=z.getOpacity(this.transform.pitch),X=((re,ae,me,he,pe,Me,Ce,$e,Be,Xe,ot,et)=>{const Ct=re.transform,vt=ae.properties.get("color-use-theme")==="none",jt=ae.properties.get("color").toNonPremultipliedRenderColor(vt?null:re.style.getLut(ae.scope)).toArray01();jt[3]=he;const xt=re.frameCounter/1e3%1,[pt,Et]=ae.properties.get("vertical-range");return{u_fog_matrix:me?Ct.calculateFogTileMatrix(me):et||re.identityMat,u_fog_range:ae.getFovAdjustedRange(Ct._fov),u_fog_color:jt,u_fog_horizon_blend:ae.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(pt,Et),Et],u_fog_temporal_offset:xt,u_frustum_tl:pe,u_frustum_tr:Me,u_frustum_br:Ce,u_frustum_bl:$e,u_globe_pos:Be,u_globe_radius:Xe,u_viewport:ot,u_globe_transition:i.aj(Ct.zoom),u_is_globe:+(Ct.projection.name==="globe")}})(this,z,T,V,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);x.setFogUniformValues(h,X)}R&&x.setCutoffUniformValues(h,R.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,x=h.createTexture();return h.bindTexture(h.TEXTURE_2D,x),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,h.drawingBufferWidth,h.drawingBufferHeight,0),x}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,x=this._backgroundTiles={},T=this.transform.coveringTiles({tileSize:512});for(const D of T)x[D.key]=h[D.key]||new Xh(D,512,this.transform.tileZoom,this,void 0,this.worldview);return x}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(h,x){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")&&(!x||x.type!=="batched-model")))}isTileAffectedByFog(h){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let x=this._cachedTileFogOpacities[h.key];return x||(this._cachedTileFogOpacities[h.key]=x=this.style.fog.getOpacityForTile(h)),x[0]>=xs||x[1]>=xs}setupDepthForOcclusion(h,x,T){const D=this.context,R=D.gl,z=!!T;var V;T||(T={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(R.TEXTURE3),h&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(R.NEAREST,R.CLAMP_TO_EDGE),T.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],T.u_depth_range_unpack=[2/((V=this.depthRangeFor3D)[1]-V[0]),-1-2*V[0]/(V[1]-V[0])],T.u_occluder_half_size=.5*this.occlusionParams.occluderSize,T.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(R.NEAREST,R.CLAMP_TO_EDGE),D.activeTexture.set(R.TEXTURE0),z||x.setTerrainUniformValues(D,T)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const h=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=h?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function tC(C,h){let x=!1,T=null;const D=()=>{T=null,x&&(C(),T=setTimeout(D,h),x=!1)};return()=>(x=!0,T||D(),T)}class wT{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=tC(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 x=yl(h);if(this._hashName){const T=this._hashName;let D=!1;const R=location.hash.slice(1).split("&").map(z=>{const V=z.split("=")[0];return V===T?(D=!0,`${V}=${x}`):z}).filter(z=>z);return D||R.push(`${T}=${x}`),`#${R.join("&")}`}return`#${x}`}_getCurrentHash(){const h=location.hash.replace("#","");if(this._hashName){let x;return h.split("&").map(T=>T.split("=")).forEach(T=>{T[0]===this._hashName&&(x=T)}),(x&&x[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._map;if(!h)return!1;const x=this._getCurrentHash();if(x.length>=3&&!x.some(T=>isNaN(Number(T)))){const T=h.dragRotate.isEnabled()&&h.touchZoomRotate.isEnabled()?+(x[3]||0):h.getBearing();return h.jumpTo({center:[+x[2],+x[1]],zoom:+x[0],bearing:T,pitch:+(x[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function yl(C,h){const x=C.getCenter(),T=Math.round(100*C.getZoom())/100,D=Math.ceil((T*Math.LN2+Math.log(512/360/.5))/Math.LN10),R=Math.pow(10,D),z=Math.round(x.lng*R)/R,V=Math.round(x.lat*R)/R,X=C.getBearing(),re=C.getPitch();let ae=h?`/${z}/${V}/${T}`:`${T}/${V}/${z}`;return(X||re)&&(ae+="/"+Math.round(10*X)/10),re&&(ae+=`/${Math.round(re)}`),ae}const wv={linearity:.3,easing:i.eT(0,0,.3,1)},jT=Object.assign({deceleration:2500,maxSpeed:1400},wv),kT=Object.assign({deceleration:20,maxSpeed:1400},wv),Ey=Object.assign({deceleration:1e3,maxSpeed:360},wv),NT=Object.assign({deceleration:1e3,maxSpeed:90},wv);class ST{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,x=i.o.now();for(;h.length>0&&x-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const x={zoom:0,bearing:0,pitch:0,pan:new i.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:R}of this._inertiaBuffer)x.zoom+=R.zoomDelta||0,x.bearing+=R.bearingDelta||0,x.pitch+=R.pitchDelta||0,R.panDelta&&x.pan._add(R.panDelta),R.around&&(x.around=R.around),R.pinchAround&&(x.pinchAround=R.pinchAround);const T=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(x.pan.mag()){const R=Lp(x.pan.mag(),T,Object.assign({},jT,h||{}));D.offset=x.pan.mult(R.amount/x.pan.mag()),D.center=this._map.transform.center,jv(D,R)}if(x.zoom){const R=Lp(x.zoom,T,kT);D.zoom=this._map.transform.zoom+R.amount,jv(D,R)}if(x.bearing){const R=Lp(x.bearing,T,Ey);D.bearing=this._map.transform.bearing+i.aA(R.amount,-179,179),jv(D,R)}if(x.pitch){const R=Lp(x.pitch,T,NT);D.pitch=this._map.transform.pitch+R.amount,jv(D,R)}if(D.zoom||D.bearing){const R=x.pinchAround===void 0?x.around:x.pinchAround;D.around=R?this._map.unproject(R):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function jv(C,h){(!C.duration||C.durationx.unproject(X)),V=R.reduce((X,re,ae,me)=>X.add(re.div(me.length)),new i.P(0,0));super(h,{points:R,point:V,lngLats:z,lngLat:x.unproject(V),originalEvent:T}),this._defaultPrevented=!1}}class CT extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,x){super("wheel",{originalEvent:x}),this._defaultPrevented=!1}}class sC{constructor(h,x){this._map=h,this._clickTolerance=x.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new CT(this._map,h))}mousedown(h,x){return this._mousedownPos=x,this._firePreventable(new vu(h.type,this._map,h))}mouseup(h){this._map.fire(new vu(h.type,this._map,h))}preclick(h){const x=new MouseEvent("preclick",h);this._map.fire(new vu(x.type,this._map,x))}click(h,x){this._mousedownPos&&this._mousedownPos.dist(x)>=this._clickTolerance||(this.preclick(h),this._map.fire(new vu(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new vu(h.type,this._map,h))}mouseover(h){this._map.fire(new vu(h.type,this._map,h))}mouseout(h){this._map.fire(new vu(h.type,this._map,h))}touchstart(h){return this._firePreventable(new dx(h.type,this._map,h))}touchmove(h){this._map.fire(new dx(h.type,this._map,h))}touchend(h){this._map.fire(new dx(h.type,this._map,h))}touchcancel(h){this._map.fire(new dx(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class MT{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new vu(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new vu("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new vu(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class rC{constructor(h,x){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=x.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,x){this.isEnabled()&&h.shiftKey&&h.button===0&&(I(),this._startPos=this._lastPos=x,this._active=!0)}mousemoveWindow(h,x){if(!this._active)return;const T=x,D=this._startPos,R=this._lastPos;if(!D||!R||R.equals(T)||!this._box&&T.dist(D){this._box&&(this._box.style.transform=`translate(${z}px,${X}px)`,this._box.style.width=V-z+"px",this._box.style.height=re-X+"px")})}mouseupWindow(h,x){if(!this._active)return;const T=this._startPos,D=x;if(T&&h.button===0){if(this.reset(),$(),T.x!==D.x||T.y!==D.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:h})),{cameraAnimation:R=>R.fitScreenCoordinates(T,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,x){return this._map.fire(new i.z(h,{originalEvent:x}))}}function nC(C,h){const x={};for(let T=0;Tthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=h.timeStamp),T.length===this.numTouches&&(this.centroid=function(D){const R=new i.P(0,0);for(const z of D)R._add(z);return R.div(D.length)}(x),this.touches=nC(T,x)))}touchmove(h,x,T){if(this.aborted||!this.centroid)return;const D=nC(T,x);for(const R in this.touches){const z=D[R];(!z||z.dist(this.touches[R])>30)&&(this.aborted=!0)}}touchend(h,x,T){if((!this.centroid||h.timeStamp-this.startTime>500)&&(this.aborted=!0),T.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class aC{constructor(h){this.singleTap=new OD(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(h,x,T){this.singleTap.touchstart(h,x,T)}touchmove(h,x,T){this.singleTap.touchmove(h,x,T)}touchend(h,x,T){const D=this.singleTap.touchend(h,x,T);if(D){const R=h.timeStamp-this.lastTime<500,z=!this.lastTap||this.lastTap.dist(D)<30;if(R&&z||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class RD{constructor(){this._zoomIn=new aC({numTouches:1,numTaps:2}),this._zoomOut=new aC({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,x,T){this._zoomIn.touchstart(h,x,T),this._zoomOut.touchstart(h,x,T)}touchmove(h,x,T){this._zoomIn.touchmove(h,x,T),this._zoomOut.touchmove(h,x,T)}touchend(h,x,T){const D=this._zoomIn.touchend(h,x,T),R=this._zoomOut.touchend(h,x,T);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})}):R?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()-1,around:z.unproject(R)},{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 FD={0:1,2:2},TT={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class iC{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,x){return!1}_move(h,x){return{}}mousedown(h,x){if(this._lastPoint)return;const T=U(h);this._correctButton(h,T)&&(this._lastPoint=x,this._eventButton=T)}mousemoveWindow(h,x){const T=this._lastPoint;if(T){if(h.preventDefault(),this._eventButton!=null&&function(D,R){const z=FD[R];return D.buttons===void 0||(D.buttons&z)!==z}(h,this._eventButton))this.reset();else if(this._moved||!(x.dist(T)0&&(this._active=!0);const D=nC(T,x),R=new i.P(0,0),z=new i.P(0,0);let V=0;for(const re in D){const ae=D[re],me=this._touches[re];me&&(R._add(ae),z._add(ae.sub(me)),V++,D[re]=ae)}if(this._touches=D,V{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class oC{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(h){}_move(h,x,T){return{}}touchstart(h,x,T){this._firstTwoTouches||T.length<2||(this._firstTwoTouches=[T[0].identifier,T[1].identifier],this._start([x[0],x[1]]))}touchmove(h,x,T){const D=this._firstTwoTouches;if(!D)return;h.preventDefault();const[R,z]=D,V=vb(T,x,R),X=vb(T,x,z);if(!V||!X)return;const re=this._aroundCenter?null:V.add(X).div(2);return this._move([V,X],re,h)}touchend(h,x,T){if(!this._firstTwoTouches)return;const[D,R]=this._firstTwoTouches,z=vb(T,x,D),V=vb(T,x,R);z&&V||(this._active&&$(),this.reset())}touchcancel(){this.reset()}enable(h){this._enabled=!0,this._aroundCenter=!!h&&h.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function vb(C,h,x){for(let T=0;TMath.abs(C.x)}class Hce extends oC{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,lC(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,x,T){const D=this._lastPoints;if(!D)return;const R=h[0].sub(D[0]),z=h[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eU()&&T.touches.length<3||(this._valid=this.gestureBeginsVertically(R,z,T.timeStamp),!this._valid)?void 0:(this._lastPoints=h,this._active=!0,{pitchDelta:(R.y+z.y)/2*-.5})}gestureBeginsVertically(h,x,T){if(this._valid!==void 0)return this._valid;const D=h.mag()>=2,R=x.mag()>=2;if(!D&&!R)return;if(!D||!R)return this._firstMove==null&&(this._firstMove=T),T-this._firstMove<100&&void 0;const z=h.y>0==x.y>0;return lC(h)&&lC(x)&&z}}const Wce={panStep:100,bearingStep:15,pitchStep:10};class Gce{constructor(){const h=Wce;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 x=0,T=0,D=0,R=0,z=0;switch(h.keyCode){case 61:case 107:case 171:case 187:x=1;break;case 189:case 109:case 173:x=-1;break;case 37:h.shiftKey?T=-1:(h.preventDefault(),R=-1);break;case 39:h.shiftKey?T=1:(h.preventDefault(),R=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&&(T=0,D=0),{cameraAnimation:V=>{const X=V.getZoom();V.easeTo({duration:300,easeId:"keyboardHandler",easing:_b,zoom:x?Math.round(X)+x*(h.shiftKey?2:1):X,bearing:V.getBearing()+T*this._bearingStep,pitch:V.getPitch()+D*this._pitchStep,offset:[-R*this._panStep,-z*this._panStep],center:V.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 _b(C){return C*(2-C)}const PT=4.000244140625,IT=1/450;class cC{constructor(h,x){this._map=h,this._el=h.getCanvasContainer(),this._handler=x,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=IT,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 x=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const T=i.o.now(),D=T-(this._lastWheelEventTime||0);this._lastWheelEventTime=T,x!==0&&x%PT==0?this._type="wheel":x!==0&&Math.abs(x)<4?this._type="trackpad":D>400?(this._type=null,this._lastValue=x,this._timeout=window.setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(D*x)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,x+=this._lastValue)),h.shiftKey&&x&&(x/=4),this._type&&(this._lastWheelEvent=h,this._delta-=x,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 x=q(this._el,h);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:x,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 x=()=>h._terrainEnabled()&&this._aroundCoord?h.computeZoomRelativeTo(this._aroundCoord):h.zoom;if(this._delta!==0){const re=this._type==="wheel"&&Math.abs(this._delta)>PT?this._wheelZoomRate:this._defaultZoomRate;let ae=2/(1+Math.exp(-Math.abs(this._delta*re)));this._delta<0&&ae!==0&&(ae=1/ae);const me=x(),he=Math.pow(2,me),pe=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):he;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(pe*ae))),this._type==="wheel"&&(this._startZoom=me,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const T=typeof this._targetZoom=="number"?this._targetZoom:x(),D=this._startZoom,R=this._easing;let z,V=!1;if(this._type==="wheel"&&D&&R){const re=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),ae=R(re);z=i.ak(D,T,ae),re<1?this._frameId||(this._frameId=!0):V=!0}else z=T,V=!0;this._active=!0,V&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let X=z-x();return X*this._lastDelta<0&&(X=0),{noInertia:!0,needsRenderFrame:!V,zoomDelta:X,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let x=i.eV;if(this._prevEase){const T=this._prevEase,D=(i.o.now()-T.start)/T.duration,R=T.easing(D+.01)-T.easing(D),z=.27/Math.sqrt(R*R+1e-4)*.01,V=Math.sqrt(.0729-z*z);x=i.eT(z,V,.25,1)}return this._prevEase={start:i.o.now(),duration:h,easing:x},x}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=w("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class zf{constructor(h,x){this._clickZoom=h,this._tapZoom=x}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 dC{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(h,x){return h.preventDefault(),{cameraAnimation:T=>{T.easeTo({duration:300,zoom:T.getZoom()+(h.shiftKey?-1:1),around:T.unproject(x)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class vl{constructor(){this._tap=new aC({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,x,T){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?T.length>0&&(this._swipePoint=x[0],this._swipeTouch=T[0].identifier):this._tap.touchstart(h,x,T))}touchmove(h,x,T){if(this._tapTime){if(this._swipePoint){if(T[0].identifier!==this._swipeTouch)return;const D=x[0],R=D.y-this._swipePoint.y;return this._swipePoint=D,h.preventDefault(),this._active=!0,{zoomDelta:R/128}}}else this._tap.touchmove(h,x,T)}touchend(h,x,T){this._tapTime?this._swipePoint&&T.length===0&&this.reset():this._tap.touchend(h,x,T)&&(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 Dp{constructor(h,x,T){this._el=h,this._mousePan=x,this._touchPan=T}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 bb{constructor(h,x,T){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=x,this._mousePitch=T}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 uC{constructor(h,x,T,D){this._el=h,this._touchZoom=x,this._touchRotate=T,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 wb=C=>C.zoom||C.drag||C.pitch||C.rotate;class Kce extends i.z{}class jb{constructor(){this.constants=[1,1,.01],this.radius=0}setup(h,x){const T=i.av([],x,h);this.radius=i.ag(T[2]<0?i.eX([],T,this.constants):[T[0],T[1],0])}projectRay(h){i.eX(h,h,this.constants),i.aw(h,h),i.eY(h,h,this.constants);const x=i.c5([],h,this.radius);if(x[2]>0){const T=i.c5([],[0,0,1],i.bJ(x,[0,0,1])),D=i.c5([],i.aw([],[x[0],x[1],0]),this.radius),R=i.d8([],x,i.c5([],i.av([],i.d8([],D,T),x),2));x[0]=R[0],x[1]=R[1]}return x}}function hC(C){return C.panDelta&&C.panDelta.mag()||C.zoomDelta||C.bearingDelta||C.pitchDelta}class Zce{constructor(h,x){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ST(h),this._bearingSnap=x.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new jb,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(x),i.aY(["handleEvent","handleWindowEvent"],this);const T=this._el;this._listeners=[[T,"touchstart",{passive:!0}],[T,"touchmove",{passive:!1}],[T,"touchend",void 0],[T,"touchcancel",void 0],[T,"mousedown",void 0],[T,"mousemove",void 0],[T,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[T,"mouseover",void 0],[T,"mouseout",void 0],[T,"dblclick",void 0],[T,"click",void 0],[T,"keydown",{capture:!1}],[T,"keyup",void 0],[T,"wheel",{passive:!1}],[T,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,R,z]of this._listeners){const V=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(R,V,z)}}destroy(){for(const[h,x,T]of this._listeners){const D=h===document?this.handleWindowEvent:this.handleEvent;h.removeEventListener(x,D,T)}}_addDefaultHandlers(h){const x=this._map,T=x.getCanvasContainer();this._add("mapEvent",new sC(x,h));const D=x.boxZoom=new rC(x,h);this._add("boxZoom",D);const R=new RD,z=new dC;x.doubleClickZoom=new zf(z,R),this._add("tapZoom",R),this._add("clickZoom",z);const V=new vl;this._add("tapDragZoom",V);const X=x.touchPitch=new Hce(x);this._add("touchPitch",X);const re=new AT(h),ae=new ET(h);x.dragRotate=new bb(h,re,ae),this._add("mouseRotate",re,["mousePitch"]),this._add("mousePitch",ae,["mouseRotate"]);const me=new zD(h),he=new BD(x,h);x.dragPan=new Dp(T,me,he),this._add("mousePan",me),this._add("touchPan",he,["touchZoom","touchRotate"]);const pe=new io,Me=new Vce;x.touchZoomRotate=new uC(T,Me,pe,V),this._add("touchRotate",pe,["touchPan","touchZoom"]),this._add("touchZoom",Me,["touchPan","touchRotate"]),this._add("blockableMapEvent",new MT(x));const Ce=x.scrollZoom=new cC(x,this);this._add("scrollZoom",Ce,["mousePan"]);const $e=x.keyboard=new Gce;this._add("keyboard",$e);for(const Be of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Be]&&x[Be].enable(h[Be])}_add(h,x,T){this._handlers.push({handlerName:h,handler:x,allowed:T}),this._handlersById[h]=x}stop(h){if(!this._updatingCamera){for(const{handler:x}of this._handlers)x.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!!wb(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(h,x,T){for(const D in h)if(D!==T&&(!x||x.indexOf(D)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const x=[];for(const T of h)this._el.contains(T.target)&&x.push(T);return x}handleEvent(h,x){this._updatingCamera=!0;const T=h.type==="renderFrame",D=T?void 0:h,R={needsRenderFrame:!1},z={},V={},X=h.touches?this._getMapTouches(h.touches):void 0,re=X?H(this._el,X):T?void 0:q(this._el,h);for(const{handlerName:he,handler:pe,allowed:Me}of this._handlers){if(!pe.isEnabled())continue;let Ce;this._blockedByActive(V,Me,he)?pe.reset():pe[x||h.type]&&(Ce=pe[x||h.type](h,re,X),this.mergeHandlerResult(R,z,Ce,he,D),Ce&&Ce.needsRenderFrame&&this._triggerRenderFrame()),(Ce||pe.isActive())&&(V[he]=pe)}const ae={};for(const he in this._previousActiveHandlers)V[he]||(ae[he]=D);this._previousActiveHandlers=V,(Object.keys(ae).length||hC(R))&&(this._changes.push([R,z,ae]),this._triggerRenderFrame()),(Object.keys(V).length||hC(R))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:me}=R;me&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],me(this._map))}mergeHandlerResult(h,x,T,D,R){if(!T)return;Object.assign(h,T);const z={handlerName:D,originalEvent:T.originalEvent||R};T.zoomDelta!==void 0&&(x.zoom=z),T.panDelta!==void 0&&(x.drag=z),T.pitchDelta!==void 0&&(x.pitch=z),T.bearingDelta!==void 0&&(x.rotate=z)}_applyChanges(){const h={},x={},T={};for(const[D,R,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(x,R),Object.assign(T,z);this._updateMapTransform(h,x,T),this._changes=[]}_updateMapTransform(h,x,T){const D=this._map,R=D.transform,z=Xe=>[Xe.x,Xe.y,Xe.z];if((Xe=>{const ot=this._eventsInProgress.drag;return ot&&!this._handlersById[ot.handlerName].isActive()})()&&!hC(h)){const Xe=R.zoom;R.cameraElevationReference="sea",this._originalZoom!=null&&R._orthographicProjectionAtLowPitch&&R.projection.name!=="globe"&&R.pitch===0?(R.cameraElevationReference="ground",R.zoom=this._originalZoom):(R.recenterOnTerrain(),R.cameraElevationReference="ground"),Xe!==R.zoom&&this._map._update(!0)}if(R._isCameraConstrained&&D._stop(!0),!hC(h))return void this._fireEvents(x,T,!0);let{panDelta:V,zoomDelta:X,bearingDelta:re,pitchDelta:ae,around:me,aroundCoord:he,pinchAround:pe}=h;R._isCameraConstrained&&(X>0&&(X=0),R._isCameraConstrained=!1),pe!==void 0&&(me=pe),(X||(Xe=>x[Xe]&&!this._eventsInProgress[Xe])("drag"))&&me&&(this._dragOrigin=z(R.pointCoordinate3D(me)),this._originalZoom=R.zoom,this._trackingEllipsoid.setup(R._camera.position,this._dragOrigin)),R.cameraElevationReference="sea",D._stop(!0),me=me||D.transform.centerPoint,re&&(R.bearing+=re),ae&&(R.pitch+=ae),R._updateCameraState();const Me=[0,0,0];if(V)if(R.projection.name==="mercator"){const Xe=this._trackingEllipsoid.projectRay(R.screenPointToMercatorRay(me).dir),ot=this._trackingEllipsoid.projectRay(R.screenPointToMercatorRay(me.sub(V)).dir);Me[0]=ot[0]-Xe[0],Me[1]=ot[1]-Xe[1]}else{const Xe=R.pointCoordinate(me);if(R.projection.name==="globe"){V=V.rotate(-R.angle);const ot=R._pixelsPerMercatorPixel/R.worldSize;Me[0]=-V.x*i.eW(i.a$(Xe.y))*ot,Me[1]=-V.y*i.eW(R.center.lat)*ot}else{const ot=R.pointCoordinate(me.sub(V));Xe&&ot&&(Me[0]=ot.x-Xe.x,Me[1]=ot.y-Xe.y)}}const Ce=R.zoom,$e=[0,0,0];if(X){const Xe=z(he||R.pointCoordinate3D(me)),ot={dir:i.aw([],i.av([],Xe,R._camera.position))};if(ot.dir[2]<0){const et=R.zoomDeltaToMovement(Xe,X);i.c5($e,ot.dir,et)}}const Be=i.d8(Me,Me,$e);R._translateCameraConstrained(Be),X&&Math.abs(R.zoom-Ce)>1e-4&&R.recenterOnTerrain(),R.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(x,T,!0)}_fireEvents(h,x,T){const D=wb(this._eventsInProgress),R=wb(h),z={};for(const ae in h){const{originalEvent:me}=h[ae];this._eventsInProgress[ae]||(z[`${ae}start`]=me),this._eventsInProgress[ae]=h[ae]}!D&&R&&this._fireEvent("movestart",R.originalEvent);for(const ae in z)this._fireEvent(ae,z[ae]);R&&this._fireEvent("move",R.originalEvent);for(const ae in h){const{originalEvent:me}=h[ae];this._fireEvent(ae,me)}const V={};let X;for(const ae in this._eventsInProgress){const{handlerName:me,originalEvent:he}=this._eventsInProgress[ae];this._handlersById[me].isActive()||(delete this._eventsInProgress[ae],X=x[me]||he,V[`${ae}end`]=X)}for(const ae in V)this._fireEvent(ae,V[ae]);const re=wb(this._eventsInProgress);if(T&&(D||R)&&!re){this._updatingCamera=!0;const ae=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),me=he=>he!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Kce("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const mC="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class LT extends i.E{constructor(h,x){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=x.bearingSnap,this._respectPrefersReducedMotion=x.respectPrefersReducedMotion!==!1,i.aY(["_renderFrameCallback"],this)}getCenter(){return new i.aT(this.transform.center.lng,this.transform.center.lat)}setCenter(h,x){return this.jumpTo({center:h},x)}panBy(h,x,T){return h=i.P.convert(h).mult(-1),this.panTo(this.transform.center,Object.assign({offset:h},x),T)}panTo(h,x,T){return this.easeTo(Object.assign({center:h},x),T)}getZoom(){return this.transform.zoom}setZoom(h,x){return this.jumpTo({zoom:h},x),this}zoomTo(h,x,T){return this.easeTo(Object.assign({zoom:h},x),T)}zoomIn(h,x){return this.zoomTo(this.getZoom()+1,h,x),this}zoomOut(h,x){return this.zoomTo(this.getZoom()-1,h,x),this}getBearing(){return this.transform.bearing}setBearing(h,x){return this.jumpTo({bearing:h},x),this}getPadding(){return this.transform.padding}setPadding(h,x){return this.jumpTo({padding:h},x),this}rotateTo(h,x,T){return this.easeTo(Object.assign({bearing:h},x),T)}resetNorth(h,x){return this.rotateTo(0,Object.assign({duration:1e3},h),x),this}resetNorthPitch(h,x){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},h),x),this}snapToNorth(h,x){return Math.abs(this.getBearing())h.aspect?T/(2*Math.tan(.5*h.fovX)*h.aspect):D/(2*Math.tan(.5*h.fovY)*h.aspect)}_cameraForBoundsOnGlobe(h,x,T,D,R,z){const V=h.clone(),X=this._extendCameraOptions(z);V.bearing=D,V.pitch=R;const re=i.aT.convert(x),ae=i.aT.convert(T),me=.5*(re.lat+ae.lat),he=.5*(re.lng+ae.lng),pe=i.eZ(me,he),Me=i.aw([],pe),Ce=i.aw([],i.bI([],Me,[0,1,0])),$e=i.bI([],Ce,Me),Be=[Ce[0],Ce[1],Ce[2],0,$e[0],$e[1],$e[2],0,Me[0],Me[1],Me[2],0,0,0,0,1],Xe=[pe,i.eZ(re.lat,re.lng),i.eZ(ae.lat,re.lng),i.eZ(ae.lat,ae.lng),i.eZ(re.lat,ae.lng),i.eZ(me,re.lng),i.eZ(me,ae.lng),i.eZ(re.lat,he),i.eZ(ae.lat,he)];let ot=i.d9.fromPoints(Xe.map(es=>[i.bJ(Ce,es),i.bJ($e,es),i.bJ(Me,es)]));const et=i.af([],ot.center,Be);i.e_(et)===0&&i.e$(et,0,0,1),i.aw(et,et),i.c5(et,et,i.aD),V.center=i.f0(et);const Ct=V.getWorldToCameraMatrix(),vt=i.bl(new Float64Array(16),Ct);ot=i.d9.applyTransform(ot,i.aB([],Ct,Be));const jt=this._extendAABB(ot,V,X,D);if(!jt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ot=jt,i.af(et,et,Ct);const xt=.5*(ot.max[2]-ot.min[2]),pt=this._minimumAABBFrustumDistance(V,ot),Et=i.c5([],[0,0,1],xt),Ht=i.d8(Et,et,Et),Ut=pt+(V.pitch===0?0:i.bG(et,Ht)),ts=V.globeCenterInViewSpace,ss=i.av([],et,[ts[0],ts[1],ts[2]]);i.aw(ss,ss),i.c5(ss,ss,Ut);const ps=i.d8([],et,ss);i.af(ps,ps,vt);const zs=i.eM/i.aD,Xt=i.ag(ps),Dt=i.cf(Math.max(Xt*zs-i.eM,Number.EPSILON),0),ls=Math.min(V.zoomFromMercatorZAdjusted(Dt),X.maxZoom);return ls>.5*(i.c_+i.cL)?(V.setProjection({name:"mercator"}),V.zoom=ls,this._cameraForBounds(V,x,T,D,R,z)):{center:V.center,zoom:ls,bearing:D,pitch:R}}_extendAABB(h,x,T,D){const R=.5*((T.padding.left||0)+(T.padding.right||0)),z=.5*((T.padding.top||0)+(T.padding.bottom||0)),V=z,X=R,re=R,ae=z,me=x.width-(X+re),he=x.height-(V+ae),pe=i.av([],h.max,h.min),Me=Math.min(me/pe[0],he/pe[1]),Ce=Math.min(x.scaleZoom(x.scale*Me),T.maxZoom);if(isNaN(Ce))return null;const $e=x.scale/x.zoomScale(Ce),Be=new i.d9([h.min[0]-X*$e,h.min[1]-ae*$e,h.min[2]],[h.max[0]+re*$e,h.max[1]+V*$e,h.max[2]]),Xe=(typeof T.offset.x=="number"&&typeof T.offset.y=="number"?new i.P(T.offset.x,T.offset.y):i.P.convert(T.offset)).rotate(-i.an(D));return Be.center[0]-=Xe.x*$e,Be.center[1]+=Xe.y*$e,Be}queryTerrainElevation(h,x){const T=this.transform.elevation;return T?(x=Object.assign({},{exaggerated:!0},x),T.getAtPoint(i.ae.fromLngLat(h),null,x.exaggerated)):null}_cameraForBounds(h,x,T,D,R,z){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,x,T,D,R,z);const V=h.clone(),X=this._extendCameraOptions(z);V.bearing=D,V.pitch=R;const re=i.aT.convert(x),ae=i.aT.convert(T),me=new i.aT(re.lng,ae.lat),he=new i.aT(ae.lng,re.lat),pe=V.project(re),Me=V.project(ae),Ce=this.queryTerrainElevation(re),$e=this.queryTerrainElevation(ae),Be=this.queryTerrainElevation(me),Xe=this.queryTerrainElevation(he),ot=[[pe.x,pe.y,Math.min(Ce||0,$e||0,Be||0,Xe||0)],[Me.x,Me.y,Math.max(Ce||0,$e||0,Be||0,Xe||0)]];let et=i.d9.fromPoints(ot);const Ct=V.getWorldToCameraMatrix(),vt=i.bl(new Float64Array(16),Ct);et=i.d9.applyTransform(et,Ct);const jt=this._extendAABB(et,V,X,D);if(!jt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");et=jt;const xt=.5*i.av([],et.max,et.min)[2],pt=this._minimumAABBFrustumDistance(V,et),Et=[0,0,1,0];i.aC(Et,Et,Ct),i.f1(Et,Et);const Ht=i.c5([],Et,pt+xt),Ut=i.d8([],et.center,Ht);i.af(et.center,et.center,vt),i.af(Ut,Ut,vt);const ts=V.unproject(new i.P(et.center[0],et.center[1])),ss=i.f2(V.projection,ts),ps=Math.pow(2,ss),zs=Math.min(V._zoomFromMercatorZ(Ut[2]*V.pixelsPerMeter*ps/V.worldSize),X.maxZoom);return V.mercatorFromTransition&&zs<.5*(i.c_+i.cL)?(V.setProjection({name:"globe"}),V.zoom=zs,this._cameraForBounds(V,x,T,D,R,z)):{center:ts,zoom:zs,bearing:D,pitch:R}}fitBounds(h,x,T){const D=this.cameraForBounds(h,x);return this._fitInternal(D,x,T)}fitScreenCoordinates(h,x,T,D,R){const z=i.P.convert(h),V=i.P.convert(x),X=new i.P(Math.min(z.x,V.x),Math.min(z.y,V.y)),re=new i.P(Math.max(z.x,V.x),Math.max(z.y,V.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,V))return this;const ae=this.transform.pointLocation3D(X),me=this.transform.pointLocation3D(re),he=this.transform.pointLocation3D(new i.P(X.x,re.y)),pe=this.transform.pointLocation3D(new i.P(re.x,X.y)),Me=[Math.min(ae.lng,me.lng,he.lng,pe.lng),Math.min(ae.lat,me.lat,he.lat,pe.lat)],Ce=[Math.max(ae.lng,me.lng,he.lng,pe.lng),Math.max(ae.lat,me.lat,he.lat,pe.lat)],$e=D&&D.pitch?D.pitch:this.getPitch(),Be=this._cameraForBounds(this.transform,Me,Ce,T,$e,D);return this._fitInternal(Be,D,R)}_fitInternal(h,x,T){return h?(x=Object.assign(h,x)).linear?this.easeTo(x,T):this.flyTo(x,T):this}jumpTo(h,x){this.stop();const T=h.preloadOnly?this.transform.clone():this.transform;let D=!1,R=!1,z=!1;"zoom"in h&&T.zoom!==+h.zoom&&(D=!0,T.zoom=+h.zoom),h.center!==void 0&&(T.center=i.aT.convert(h.center)),"bearing"in h&&T.bearing!==+h.bearing&&(R=!0,T.bearing=+h.bearing),"pitch"in h&&T.pitch!==+h.pitch&&(z=!0,T.pitch=+h.pitch);const V=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!T.isPaddingEqual(V))if(h.retainPadding===!1){const X=T.clone();X.padding=V,T.setLocationAtPoint(T.center,X.centerPoint)}else T.padding=V;return h.preloadOnly?(this._preloadTiles(T),this):(this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),D&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),R&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),z&&this.fire(new i.z("pitchstart",x)).fire(new i.z("pitch",x)).fire(new i.z("pitchend",x)),this.fire(new i.z("moveend",x)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w(mC),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,x){const T=this.transform;if(!T.projection.supportsFreeCamera)return i.w(mC),this;this.stop();const D=T.zoom,R=T.pitch,z=T.bearing;T.setFreeCameraOptions(h);const V=D!==T.zoom,X=R!==T.pitch,re=z!==T.bearing;return this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),V&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),re&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),X&&this.fire(new i.z("pitchstart",x)).fire(new i.z("pitch",x)).fire(new i.z("pitchend",x)),this.fire(new i.z("moveend",x)),this}easeTo(h,x){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 T=this.transform,D=this.getZoom(),R=this.getBearing(),z=this.getPitch(),V=this.getPadding(),X="zoom"in h?+h.zoom:D,re="bearing"in h?this._normalizeBearing(h.bearing,R):R,ae="pitch"in h?+h.pitch:z,me=this._extendPadding(h.padding),he=i.P.convert(h.offset);let pe,Me,Ce;if(T.projection.name==="globe"){const Et=i.ae.fromLngLat(T.center),Ht=he.rotate(-T.angle);Et.x+=Ht.x/T.worldSize,Et.y+=Ht.y/T.worldSize;const Ut=Et.toLngLat(),ts=i.aT.convert(h.center||Ut);this._normalizeCenter(ts),pe=T.centerPoint.add(Ht),Me=new i.P(Et.x,Et.y).mult(T.worldSize),Ce=new i.P(i.aF(ts.lng),i.aJ(ts.lat)).mult(T.worldSize).sub(Me)}else{pe=T.centerPoint.add(he);const Et=T.pointLocation(pe),Ht=i.aT.convert(h.center||Et);this._normalizeCenter(Ht),Me=T.project(Et),Ce=T.project(Ht).sub(Me)}const $e=T.zoomScale(X-D);let Be,Xe;h.around&&(Be=i.aT.convert(h.around),Xe=T.locationPoint(Be));const ot=this._zooming||X!==D,et=this._rotating||R!==re,Ct=this._pitching||ae!==z,vt=!T.isPaddingEqual(me),jt=h.retainPadding===!1?T.clone():T,xt=Et=>Ht=>{if(ot&&(Et.zoom=i.ak(D,X,Ht)),et&&(Et.bearing=i.ak(R,re,Ht)),Ct&&(Et.pitch=i.ak(z,ae,Ht)),vt&&(jt.interpolatePadding(V,me,Ht),pe=jt.centerPoint.add(he)),Be)Et.setLocationAtPoint(Be,Xe);else{const Ut=Et.zoomScale(Et.zoom-D),ts=X>D?Math.min(2,$e):Math.max(.5,$e),ss=Math.pow(ts,1-Ht),ps=Et.unproject(Me.add(Ce.mult(Ht*ss)).mult(Ut));Et.setLocationAtPoint(Et.renderWorldCopies?ps.wrap():ps,pe)}return h.preloadOnly||this._fireMoveEvents(x),Et};if(h.preloadOnly){const Et=this._emulate(xt,h.duration,T);return this._preloadTiles(Et),this}const pt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ot,this._rotating=et,this._pitching=Ct,this._padding=vt,this._easeId=h.easeId,this._prepareEase(x,h.noMoveStart,pt),this._ease(xt(T),Et=>{T.cameraElevationReference==="sea"&&T.recenterOnTerrain(),this._afterEase(x,Et)},h),this}_prepareEase(h,x,T={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),x||T.moving||this.fire(new i.z("movestart",h)),this._zooming&&!T.zooming&&this.fire(new i.z("zoomstart",h)),this._rotating&&!T.rotating&&this.fire(new i.z("rotatestart",h)),this._pitching&&!T.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,x){if(this._easeId&&x&&this._easeId===x)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const T=this._zooming,D=this._rotating,R=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,T&&this.fire(new i.z("zoomend",h)),D&&this.fire(new i.z("rotateend",h)),R&&this.fire(new i.z("pitchend",h)),this.fire(new i.z("moveend",h))}flyTo(h,x){if(this._prefersReducedMotion(h)){const es=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(es,x)}this.stop(),h=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},h);const T=this.transform,D=this.getZoom(),R=this.getBearing(),z=this.getPitch(),V=this.getPadding(),X="zoom"in h?i.aA(+h.zoom,T.minZoom,T.maxZoom):D,re="bearing"in h?this._normalizeBearing(h.bearing,R):R,ae="pitch"in h?+h.pitch:z,me=this._extendPadding(h.padding),he=T.zoomScale(X-D),pe=i.P.convert(h.offset);let Me=T.centerPoint.add(pe);const Ce=T.pointLocation(Me),$e=i.aT.convert(h.center||Ce);this._normalizeCenter($e);const Be=T.project(Ce),Xe=T.project($e).sub(Be);let ot=h.curve;const et=Math.max(T.width,T.height),Ct=et/he,vt=Xe.mag();if("minZoom"in h){const es=i.aA(Math.min(h.minZoom,D,X),T.minZoom,T.maxZoom),As=et/T.zoomScale(es-D);ot=Math.sqrt(As/vt*2)}const jt=ot*ot;function xt(es){const As=(Ct*Ct-et*et+(es?-1:1)*jt*jt*vt*vt)/(2*(es?Ct:et)*jt*vt);return Math.log(Math.sqrt(As*As+1)-As)}function pt(es){return(Math.exp(es)-Math.exp(-es))/2}function Et(es){return(Math.exp(es)+Math.exp(-es))/2}const Ht=xt(0);let Ut=function(es){return Et(Ht)/Et(Ht+ot*es)},ts=function(es){return et*((Et(Ht)*(pt(As=Ht+ot*es)/Et(As))-pt(Ht))/jt)/vt;var As},ss=(xt(1)-Ht)/ot;if(Math.abs(vt)<1e-6||!isFinite(ss)){if(Math.abs(et-Ct)<1e-6)return this.easeTo(h,x);const es=Cth.maxDuration&&(h.duration=0);const ps=R!==re,zs=ae!==z,Xt=!T.isPaddingEqual(me),Dt=h.retainPadding===!1?T.clone():T,ls=es=>As=>{const Xs=As*ss,ur=1/Ut(Xs);es.zoom=As===1?X:D+es.scaleZoom(ur),ps&&(es.bearing=i.ak(R,re,As)),zs&&(es.pitch=i.ak(z,ae,As)),Xt&&(Dt.interpolatePadding(V,me,As),Me=Dt.centerPoint.add(pe));const Ws=As===1?$e:es.unproject(Be.add(Xe.mult(ts(Xs))).mult(ur));return es.setLocationAtPoint(es.renderWorldCopies?Ws.wrap():Ws,Me),es._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(x),es};if(h.preloadOnly){const es=this._emulate(ls,h.duration,T);return this._preloadTiles(es),this}return this._zooming=!0,this._rotating=ps,this._pitching=zs,this._padding=Xt,this._prepareEase(x,!1),this._ease(ls(T),()=>this._afterEase(x),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(h){}_cancelRenderFrame(h){}_stop(h,x){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const T=this._onEaseEnd;this._onEaseEnd=void 0,T.call(this,x)}if(!h){const T=this.handlers;T&&T.stop(!1)}return this}_ease(h,x,T){T.animate===!1||T.duration===0?(h(1),x()):(this._easeStart=i.o.now(),this._easeOptions=T,this._onEaseFrame=h,this._onEaseEnd=x,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),x=this._onEaseFrame;x&&x(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,x){h=i.bT(h,-180,180);const T=Math.abs(h-x);return Math.abs(h-360-x)180?-360:T<-180?360:0}_prefersReducedMotion(h){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(h&&h.essential)}_emulate(h,x,T){const D=Math.ceil(15*x/1e3),R=[],z=h(T.clone());for(let V=0;V<=D;V++){const X=z(V/D);R.push(X.clone())}return R}_preloadTiles(h,x){}}class kb{constructor(h={}){this.options=h,i.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){const x=this.options&&this.options.compact,T=h._getUIString("AttributionControl.ToggleAttribution");this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=w("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",T);const D=w("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",T),this._innerContainer=w("div","mapboxgl-ctrl-attrib-inner",this._container),x&&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),x===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 x=[{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 T=x.reduce((D,R,z)=>(R.value&&(D+=`${R.key}=${R.value}${zD.length-R.length),h=h.filter((D,R)=>{for(let z=R+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 T=h.map(D=>function(R){const z=new DOMParser().parseFromString(R,"text/html");return Array.from(z.body.querySelectorAll("*")).forEach(V=>{const X=V.textContent||"";if(V.tagName!=="A")return void V.replaceWith(z.createTextNode(X));const re=V.getAttribute("href");if(!re||!/^(https?:|mailto:)/i.test(re))return void V.replaceWith(z.createTextNode(X));const ae=z.createElement("a");ae.href=re,ae.textContent=X,ae.rel="noopener nofollow";const me=V.getAttribute("class");me&&(ae.className=me),V.replaceWith(ae)}),z.body.innerHTML}(D)).join(" | ");T!==this._attribHTML&&(this._attribHTML=T,h.length?(this._innerContainer.innerHTML=T,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 Nb{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=w("div","mapboxgl-ctrl");const x=w("a","mapboxgl-ctrl-logo");return x.target="_blank",x.rel="noopener nofollow",x.href="https://www.mapbox.com/",x.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),x.setAttribute("rel","noopener nofollow"),this._container.appendChild(x),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 x in h){const T=h[x].getSource();if(T.hasOwnProperty("mapbox_logo")&&!T.mapbox_logo)return!1}return!0}_updateCompact(){const h=this._container.children;if(h.length){const x=h[0];this._map.getCanvasContainer().offsetWidth<250?x.classList.add("mapboxgl-compact"):x.classList.remove("mapboxgl-compact")}}}class kv{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",x=>this._onIndoorUpdate(x)),this._container}_createButton(h,x){const T=w("button",h,this._container);return T.type="button",T.addEventListener("click",x),T}_createSeparator(){return w("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(h,x){this._map&&(h.setAttribute("aria-label",x),h.textContent=x)}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 x=this._model;this._model=h,this._container.style.display="inline-block",this._container.style.borderRadius="8px",x&&Array.from(this._container.children).forEach(T=>T.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 x=this._map;this._model&&x&&x._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});w("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&h.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(h),this._createSeparator()}_updateBuildingsButtonState(){const h=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");h&&this._model&&(this._model.activeFloorsVisible?h.classList.remove("mapboxgl-ctrl-level-button-selected"):h.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(h,x){for(let T=0;T{this._map._selectIndoorFloor(D.id)});this._setButtonTitle(R,D.zIndex.toString()),this._model&&D.id===this._model.selectedFloorId&&x&&R.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(R),T=this._endTime)return this._end;const x=i.dD((h-this._startTime)/(this._endTime-this._startTime));return this._start*(1-x)+this._end*x}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,x,T){this._start=this.getValue(x),this._end=h,this._startTime=x,this._endTime=x+T}}const qf={"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 ux extends i.z{constructor(h,x,T,D){const{point:R,lngLat:z,originalEvent:V,target:X}=h;super(h.type,{point:R,lngLat:z,originalEvent:V,target:X}),this.preventDefault=()=>{h.preventDefault()},this.id=x,this.interaction=T,this.feature=D}}class Um{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,x){if(this.typeById.has(h))throw new Error(`Interaction id "${h}" already exists.`);const T=x.filter;let D=x.type;T&&this.filters.set(h,i.b6(T)),D==="mouseover"&&(D="mouseenter"),D==="mouseout"&&(D="mouseleave");const R=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,x)):R.size===0&&this.map.on(D,this.handleType),R.size===0&&this.interactionsByType.set(D,R),R.set(h,x),this.typeById.set(h,D)}get(h){const x=this.typeById.get(h);if(!x)return;const T=this.interactionsByType.get(x);return T?T.get(h):void 0}remove(h){const x=this.typeById.get(h);if(!x)return;this.typeById.delete(h),this.filters.delete(h);const T=this.interactionsByType.get(x);T&&(T.delete(h),x==="mouseenter"||x==="mouseleave"?(this.delegatedInteractions.delete(h),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):T.size===0&&this.map.off(x,this.handleType))}queryTargets(h,x){const T=[];for(const[D,R]of x)R.target&&T.push({targetId:D,target:R.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(h,T,this.map.transform)}handleMove(h){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const x=this.queryTargets(h.point,Array.from(this.delegatedInteractions).reverse());x.length&&(h.type="mouseenter",this.handleType(h,x));const T=new Map;for(const[D,{feature:R}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||T.set(R.id,R);T.size&&(h.type="mouseleave",this.handleType(h,Array.from(T.values())))}handleOut(h){const x=Array.from(this.hoveredFeatures.values()).map(({feature:T})=>T);x.length&&(h.type="mouseleave",this.handleType(h,x)),this.hoveredFeatures.clear()}handleType(h,x){const T=h.type==="mouseenter";if(T&&!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(),R=!!x;x=x||this.queryTargets(h.point,D);let z=!1;const V=new Set;for(const X of x){for(const[re,ae]of D){if(!ae.target)continue;const me=X.variants?X.variants[re]:null;if(me){for(const he of me){if(Kg(he,X,V,re))continue;const pe=new i.dx(X,he),Me=Sf(he,X,re);R&&pe.id!==void 0&&(pe.state=this.map.getFeatureState(pe));const Ce=T?this.prevHoveredFeatures.get(Me):null,$e=new ux(h,re,ae,pe),Be=Ce?Ce.stop:ae.handler($e);if(T&&this.hoveredFeatures.set(Me,{feature:X,stop:Be}),Be!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[X,re]of D){const{handler:ae,target:me}=re;if(!me&&ae(new ux(h,X,re,null))!==!1)break}}}function Yce(C,h){if(Array.isArray(C)&&Array.isArray(h)){const x=new Set(C),T=new Set(h);return x.size===T.size&&C.every(D=>T.has(D))}return i.by(C,h)}const Xce={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"},Qce={showCompass:!0,showZoom:!0,visualizePitch:!1};class Jce{constructor(h,x,T=!1){this._clickTolerance=10,this.element=x,this.mouseRotate=new AT({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,T&&(this.mousePitch=new ET({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),x.addEventListener("mousedown",this.mousedown),x.addEventListener("touchstart",this.touchstart,{passive:!1}),x.addEventListener("touchmove",this.touchmove),x.addEventListener("touchend",this.touchend),x.addEventListener("touchcancel",this.reset)}down(h,x){this.mouseRotate.mousedown(h,x),this.mousePitch&&this.mousePitch.mousedown(h,x),I()}move(h,x){const T=this.map,D=this.mouseRotate.mousemoveWindow(h,x),R=D&&D.bearingDelta;if(R&&T.setBearing(T.getBearing()+R),this.mousePitch){const z=this.mousePitch.mousemoveWindow(h,x),V=z&&z.pitchDelta;V&&T.setPitch(T.getPitch()+V)}}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()}),q(this.element,h)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(h){this.move(h,q(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=H(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=H(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)x.width||h.y>x.height;x.locationPoint3D(T).distSqr(h)180;){const T=x.locationPoint3D(C);if(T.x>=0&&T.y>=0&&T.x<=x.width&&T.y<=x.height)break;C.lng>x.center.lng?C.lng-=360:C.lng+=360}return C}const dd={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%)"},rm={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class pC extends i.E{constructor(h,x){super(),(h instanceof HTMLElement||x)&&(h=Object.assign({element:h},x)),i.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:T="center",color:D="#3FB1CE",scale:R=1,draggable:z=!1,clickTolerance:V=0,rotation:X=rm.rotation,rotationAlignment:re=rm.rotationAlignment,pitchAlignment:ae=rm.pitchAlignment,occludedOpacity:me=rm.occludedOpacity,altitude:he=rm.altitude}=h||{};this._anchor=T,this._color=D,this._scale=R,this._draggable=z,this._clickTolerance=V,this._rotation=X,this._rotationAlignment=re,this._pitchAlignment=ae,this._occludedOpacity=me,this._altitude=he,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",Ce=>{Ce.preventDefault()}),this._element.addEventListener("mousedown",Ce=>{Ce.preventDefault()});const pe=this._element.classList;for(const Ce in dd)pe.remove(`mapboxgl-marker-anchor-${Ce}`);pe.add(`mapboxgl-marker-anchor-${this._anchor}`);const Me=h&&h.className?h.className.trim().split(/\s+/):[];pe.add(...Me),this._popup=null}_createDefaultMarker(){const h=w("div"),x=j("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const T=j("radialGradient",{id:"shadowGradient"},j("defs",{},x));j("stop",{offset:"10%","stop-opacity":.4},T),j("stop",{offset:"100%","stop-opacity":.05},T),j("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},x)}return j("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},x),j("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},x),j("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},x),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||rm.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 x=h.code,T=h.charCode||h.keyCode;x!=="Space"&&x!=="Enter"&&T!==32&&T!==13||this.togglePopup()}_onMapClick(h){const x=h.originalEvent.target,T=this._element;this._popup&&(x===T||T.contains(x))&&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,x=this._pos;if(!h||!x)return!1;const T=h.unproject(x,this._altitude),D=h.getFreeCameraOptions();if(!D.position)return!1;const R=D.position.toLngLat();return R.distanceTo(T)<.9*R.distanceTo(this._lngLat)}_evaluateOpacity(){const h=this._map;if(!h)return;const x=this._pos;if(!x||x.x<0||x.x>h.transform.width||x.y<0||x.y>h.transform.height)return void this._clearFadeTimer();const T=h.unproject(x,this._altitude);let D;h._showingGlobe()&&i.f5(h.transform,this._lngLat)?D=0:(D=1-h._queryFogOpacity(T),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 x=this._offset.mult(this._scale);this._element.style.transform=` translate(${h.x}px,${h.y}px) ${dd[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${x.x}px,${x.y}px) `}_calculateXYTransform(){const h=this._pos,x=this._map,T=this.getPitchAlignment();if(!x||!h||T!=="map")return"";if(!x._showingGlobe()){const X=x.getPitch();return X?`rotateX(${X}deg)`:""}const D=i.cX(i.f6(x.transform,this._lngLat)),R=h.sub(i.f7(x.transform)),z=Math.abs(R.x)+Math.abs(R.y);if(z===0)return"";const V=D/z;return`rotateX(${-R.y*V}deg) rotateY(${R.x*V}deg)`}_calculateZTransform(){const h=this._pos,x=this._map;if(!x||!h)return"";let T=0;const D=this.getRotationAlignment();if(D==="map")if(x._showingGlobe()){const R=x.project(new i.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),z=x.project(new i.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(R);T=i.cX(Math.atan2(z.y,z.x))-90}else T=-x.getBearing();else if(D==="horizon"){const R=i.ah(4,6,x.getZoom()),z=i.f7(x.transform);z.y+=R*x.transform.height;const V=h.sub(z),X=i.cX(Math.atan2(V.y,V.x));T=(X>90?X-270:X+90)*(1-R)}return T+=this._rotation,T?`rotateZ(${T}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const x=this._map;x&&(x.transform.renderWorldCopies&&(this._lngLat=DT(this._lngLat,this._pos,x.transform)),this._pos=x.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(),x._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(x._showingGlobe()||x.getTerrain()||x.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 x=this._map;if(!x)return;const T=this._pointerdownPos,D=this._positionDelta;if(T&&D){if(!this._isDragging){const R=this._clickTolerance||x._clickTolerance;if(h.point.dist(T)C.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(C.minPitch!=null&&C.maxPitch!=null&&C.minPitch>C.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(C.minPitch!=null&&C.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(C.maxPitch!=null&&C.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(C.antialias&&i.f3(window)&&(C.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 zM(C.minZoom,C.maxZoom,C.minPitch,C.maxPitch,C.renderWorldCopies,null,null),C),this._repaint=!!C.repaint,this._interactive=C.interactive,this._minTileCacheSize=C.minTileCacheSize,this._maxTileCacheSize=C.maxTileCacheSize,this._failIfMajorPerformanceCaveat=C.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=C.preserveDrawingBuffer,this._antialias=C.antialias,this._trackResize=C.trackResize,this._bearingSnap=C.bearingSnap,this._refreshExpiredTiles=C.refreshExpiredTiles,this._fadeDuration=C.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=C.crossSourceCollisions,this._collectResourceTiming=C.collectResourceTiming,this._language=this._parseLanguage(C.language),this._worldview=C.worldview,this._renderTaskQueue=new Bf,this._domRenderTaskQueue=new Bf,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},qf,C.locale),this._clickTolerance=C.clickTolerance,this._cooperativeGestures=C.cooperativeGestures,this._performanceMetricsCollection=C.performanceMetricsCollection,this._tessellationStep=C.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=C.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new $f(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=C.scaleFactor,this._requestManager=new Y(C.transformRequest,C.accessToken,C.testMode),this._silenceAuthErrors=!!C.testMode,this._contextCreateOptions=C.contextCreateOptions?Object.assign({},C.contextCreateOptions):{},typeof C.container=="string"){const x=document.getElementById(C.container);if(!x)throw new Error(`Container '${C.container.toString()}' not found.`);this._container=x}else{if(!(C.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=C.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."),C.maxBounds&&this.setMaxBounds(C.maxBounds),this._spriteFormat=C.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 Zce(this,C),this._localFontFamily=C.localFontFamily,this._localIdeographFontFamily=C.localIdeographFontFamily,(C.style||!C.testMode)&&this.setStyle(C.style||i.e.DEFAULT_STYLE,{config:C.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),C.projection&&this.setProjection(C.projection),C.hash&&(this._hash=new wT(typeof C.hash=="string"&&C.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){h.center==null&&h.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:C.center,zoom:C.zoom,bearing:C.bearing,pitch:C.pitch});const x=C.bounds;x&&(this.resize(),this.fitBounds(x,Object.assign({},C.fitBoundsOptions,{duration:0})))}this.resize(),C.attributionControl&&this.addControl(new kb({customAttribution:C.customAttribution})),this._logoControl=new Nb,this.addControl(this._logoControl,C.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",x=>{this._update(x.dataType==="style"),this.fire(new i.z(`${x.dataType}data`,x))}),this.on("dataloading",x=>{this.fire(new i.z(`${x.dataType}dataloading`,x))}),this._interactions=new Um(this)}_getMapId(){return this._mapId}addControl(C,h){if(h===void 0&&(h=C.getDefaultPosition?C.getDefaultPosition():"top-right"),!C||!C.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 x=C.onAdd(this);this._controls.push(C);const T=this._controlPositions[h];return h.indexOf("bottom")!==-1?T.insertBefore(x,T.firstChild):T.appendChild(x),this}removeControl(C){if(!C||!C.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(C);return h>-1&&this._controls.splice(h,1),C.onRemove(this),this}hasControl(C){return this._controls.indexOf(C)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(C){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",C)).fire(new i.z("move",C)),this.fire(new i.z("resize",C)),h&&this.fire(new i.z("moveend",C)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(C){return this.transform.setMaxBounds(i.aI.convert(C)),this._update()}setMinZoom(C){if((C=C??-2)>=-2&&C<=this.transform.maxZoom)return this.transform.minZoom=C,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=C,this._update(),this.getZoom()>C?this.setZoom(C):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(C){if((C=C??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(C>=0&&C<=this.transform.maxPitch)return this.transform.minPitch=C,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(C>=this.transform.minPitch)return this.transform.maxPitch=C,this._update(),this.getPitch()>C?this.setPitch(C):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(C){return this._scaleFactor=C,this.painter.scaleFactor=C,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(h=>h.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(C){return this.transform.renderWorldCopies=C,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(C){return C==="auto"?navigator.language:Array.isArray(C)?C.length===0?void 0:C.map(h=>h==="auto"?navigator.language:h):C}setLanguage(C){const h=this._parseLanguage(C);if(!this.style||h===this._language)return this;this._language=h,this.style.reloadSources();for(const x of this._controls)x._setLanguage&&x._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(C){return this.style&&C!==this._worldview?(this._worldview=C,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(C){return this._lazyInitEmptyStyle(),C?typeof C=="string"&&(C={name:C}):C=null,this._useExplicitProjection=!!C,this._prioritizeAndUpdateProjection(C,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const C=this.transform,h=C.projection.name;let x;h==="globe"&&C.zoom>=i.cL?(C.setMercatorFromTransition(),x=!0):h==="mercator"&&C.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(C),this.style.applyProjectionUpdate();const T=this.transform.getProjection().name==="mercator"&&x!==this.transform.mercatorFromTransition;return(h||T)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(C,h){return this.transform.locationPoint3D(i.aT.convert(C),h)}unproject(C,h){return this.transform.pointLocation3D(i.P.convert(C),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(C,h,x){const T=D=>{let R=[];if(Array.isArray(h)){const z=h.filter(V=>this.getLayer(V));R=z.length?this.queryRenderedFeatures(D,{layers:z}):[]}else R=this.queryRenderedFeatures(D,{target:h});return R};if(C==="mouseenter"||C==="mouseover"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:z=>{const V=T(z.point);V.length?D||(D=!0,x.call(this,new vu(C,this,z.originalEvent,{features:V}))):D=!1},mouseout:()=>{D=!1}}}}if(C==="mouseleave"||C==="mouseout"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:V=>{T(V.point).length?D=!0:D&&(D=!1,x.call(this,new vu(C,this,V.originalEvent)))},mouseout:V=>{D&&(D=!1,x.call(this,new vu(C,this,V.originalEvent)))}}}}{const D=R=>{const z=T(R.point);z.length&&(R.features=z,x.call(this,R),delete R.features)};return{listener:x,targets:h,delegates:{[C]:D}}}}on(C,h,x){if(typeof h=="function"||x===void 0)return super.on(C,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const T=this._createDelegatedListener(C,h,x);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[C]=this._delegatedListeners[C]||[],this._delegatedListeners[C].push(T);for(const D in T.delegates)this.on(D,T.delegates[D]);return this}once(C,h,x){if(typeof h=="function"||x===void 0)return super.once(C,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const T=this._createDelegatedListener(C,h,x);for(const D in T.delegates)this.once(D,T.delegates[D]);return this}off(C,h,x){if(typeof h=="function"||x===void 0)return super.off(C,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const T=this._delegatedListeners?this._delegatedListeners[C]:void 0;return T&&(D=>{for(let R=0;R{if(x){const D=typeof x=="string"?x:x instanceof Error?x.message:x.error;i.w(`Unable to perform style diff: ${D}. Rebuilding the style from scratch.`),this._updateStyle(C,h)}else T&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=h.localIdeographFontFamily,this._localFontFamily=h.localFontFamily,this._updateStyle(C,h))}_getUIString(C){const h=this._locale[C];if(h==null)throw new Error(`Missing UI string '${C}'`);return h}_updateStyle(C,h){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),C){const x=Object.assign({},h);h&&h.config&&(x.initialConfig=h.config,delete x.config),this.style=new sm(this,x).load(C),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new sm(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(C){return C==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(C)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${C}".`))),!1)}_isTargetValid(C){return"featuresetId"in C?this._isValidId("importId"in C?C.importId:C.featuresetId):"layerId"in C&&this._isValidId(C.layerId)}_areTargetsValid(C){if(Array.isArray(C)){for(const h of C)if(!this._isValidId(h))return!1;return!0}return this._isTargetValid(C)}addSource(C,h){return this._isValidId(C)?(this._lazyInitEmptyStyle(),this.style.addSource(C,h),this._update(!0)):this}isSourceLoaded(C){return!!this._isValidId(C)&&!!this.style&&this.style._isSourceCacheLoaded(C)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(C,h,x){this._lazyInitEmptyStyle(),this.style.addSourceType(C,h,x)}removeSource(C){return this._isValidId(C)?(this.style.removeSource(C),this._updateTerrain(),this._update(!0)):this}getSource(C){return this._isValidId(C)?this.style.getOwnSource(C):null}addImage(C,h,{pixelRatio:x=1,sdf:T=!1,stretchX:D,stretchY:R,content:z}={}){this._lazyInitEmptyStyle();const V=i.I.from(C);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:X,height:re,data:ae}=i.o.getImageData(h);this.style.addImage(V,{data:new i.q({width:X,height:re},ae),pixelRatio:x,stretchX:D,stretchY:R,content:z,sdf:T,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:X,height:re}=h,ae=h;this.style.addImage(V,{data:new i.q({width:X,height:re},new Uint8Array(ae.data)),pixelRatio:x,stretchX:D,stretchY:R,content:z,sdf:T,usvg:!1,version:0,userImage:ae}),ae.onAdd&&ae.onAdd(this,C)}}updateImage(C,h){this._lazyInitEmptyStyle();const x=i.I.from(C),T=this.style.getImage(x);if(!T)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:R,height:z,data:V}=D;if(R===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(R!==(T.usvg?T.icon.usvg_tree.width:T.data.width)||z!==(T.usvg?T.icon.usvg_tree.height:T.data.height))return void this.fire(new i.y(new Error(`The width and height of the updated image (${R}, ${z}) must be that same as the previous version of the image (${T.data.width}, ${T.data.height})`)));const X=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let re=!1;T.usvg?(T.data=new i.q({width:R,height:z},new Uint8Array(V)),T.usvg=!1,T.icon=void 0,re=!0):T.data.replace(V,X),this.style.updateImage(x,T,re)}hasImage(C){return C?!!this.style&&!!this.style.getImage(i.I.from(C)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(C){this.style.removeImage(i.I.from(C))}loadImage(C,h){i.n(this._requestManager.transformRequest(C,i.R.Image),(x,T)=>{h(x,T instanceof HTMLImageElement?i.o.getImageData(T):T)})}listImages(){return this.style.listImages().map(C=>C.name)}addModel(C,h){this._lazyInitEmptyStyle(),this.style.addModel(C,h)}hasModel(C){return C?this.style.hasModel(C):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(C){this.style.removeModel(C)}listModels(){return this.style.listModels()}addLayer(C,h){return this._isValidId(C.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(C,h),this._update(!0)):this}getSlot(C){const h=this.getLayer(C);return h&&h.slot||null}setSlot(C,h){return this.style.setSlot(C,h),this.style.mergeLayers(),this._update(!0)}addImport(C,h){return this.style.addImport(C,h).catch(x=>this.fire(new i.y(new Error("Failed to add import",x)))),this}updateImport(C,h){return typeof h!="string"&&h.id!==C?(this.removeImport(C),this.addImport(h)):(this.style.updateImport(C,h),this._update(!0))}removeImport(C){return this.style.removeImport(C),this}moveImport(C,h){return this.style.moveImport(C,h),this._update(!0)}moveLayer(C,h){return this._isValidId(C)?(this.style.moveLayer(C,h),this._update(!0)):this}removeLayer(C){return this._isValidId(C)?(this.style.removeLayer(C),this._update(!0)):this}getLayer(C){if(!this._isValidId(C))return null;const h=this.style.getOwnLayer(C);return h?h.type==="custom"?h.implementation:h.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(C,h,x){return this._isValidId(C)?(this.style.setLayerZoomRange(C,h,x),this._update(!0)):this}setFilter(C,h,x={}){return this._isValidId(C)?(this.style.setFilter(C,h,x),this._update(!0)):this}getFilter(C){return this._isValidId(C)?this.style.getFilter(C):null}setPaintProperty(C,h,x,T={}){return this._isValidId(C)?(this.style.setPaintProperty(C,h,x,T),this._update(!0)):this}getPaintProperty(C,h){return this._isValidId(C)?this.style.getPaintProperty(C,h):null}setLayoutProperty(C,h,x,T={}){return this._isValidId(C)?(this.style.setLayoutProperty(C,h,x,T),this._update(!0)):this}getLayoutProperty(C,h){return this._isValidId(C)?this.style.getLayoutProperty(C,h):null}setLayerProperty(C,h,x,T={}){return this._isValidId(C)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(C,h,x,T),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(C){return this.style.setGlyphsUrl(C),this._update(!0)}getSchema(C){return this.style.getSchema(C)}setSchema(C,h){return this.style.setSchema(C,h),this._update(!0)}getConfig(C){return this.style.getConfig(C)}setConfig(C,h){return this.style.setConfig(C,h),this._update(!0)}getConfigProperty(C,h){return this.style.getConfigProperty(C,h)}setConfigProperty(C,h,x){return this.style.setConfigProperty(C,h,x),this._update(!0)}getFeaturesetDescriptors(C){return this.style.getFeaturesetDescriptors(C)}setLights(C){if(this._lazyInitEmptyStyle(),C&&C.length===1&&C[0].type==="flat"){const h=C[0];h.properties?this.style.setFlatLight(h.properties,h.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(C),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const C=this.style.getLights()||[];return C.length===0&&C.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),C}setLight(C,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:C}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(C){return this._lazyInitEmptyStyle(),!C&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(C),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(C){return this._lazyInitEmptyStyle(),this.style.setFog(C),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(C){return this._lazyInitEmptyStyle(),this.style.setSnow(C),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(C){return this._lazyInitEmptyStyle(),this.style.setRain(C),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(C){return this._lazyInitEmptyStyle(),this.style.setColorTheme(C),this._update(!0)}setImportColorTheme(C,h){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(C,h),this._update(!0)}setCamera(C){return this.style.setCamera(C),this._triggerCameraUpdate(C)}_triggerCameraUpdate(C){return this._update(this.transform.setOrthographicProjectionAtLowPitch(C["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(C){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(C),this.transform):0}setFeatureState(C,h){return C.source&&!this._isValidId(C.source)?this:(this.style.setFeatureState(C,h),this._update())}removeFeatureState(C,h){return C.source&&!this._isValidId(C.source)?this:(this.style.removeFeatureState(C,h),this._update())}getFeatureState(C){return C.source&&!this._isValidId(C.source)?null:this.style.getFeatureState(C)}_selectIndoorFloor(C){this.indoor.selectFloor(C)}_setIndoorActiveFloorsVisibility(C){this.indoor.setActiveFloorsVisibility(C)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new kv),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const C=this._container.getBoundingClientRect().width||400,h=this._container.getBoundingClientRect().height||300;let x,T,D,R=this._container;for(;R&&(!T||!D);){const z=window.getComputedStyle(R).transform;z&&z!=="none"&&(x=z.match(/matrix.*\((.+)\)/)[1].split(", "),x[0]&&x[0]!=="0"&&x[0]!=="1"&&(T=x[0]),x[3]&&x[3]!=="0"&&x[3]!=="1"&&(D=x[3])),R=R.parentElement}this._containerWidth=T?Math.abs(C/T):C,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 YL(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 C=this._container;C.classList.add("mapboxgl-map"),(this._missingCSSCanary=w("div","mapboxgl-canary",C)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=w("div","mapboxgl-canvas-container",C);this._canvas=w("canvas","mapboxgl-canvas",h),this._interactive&&(h.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const x=this._controlContainer=w("div","mapboxgl-control-container",C),T=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{T[D]=w("div",`mapboxgl-ctrl-${D}`,x)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(C,h){const x=i.o.devicePixelRatio||1;this._canvas.width=x*Math.ceil(C),this._canvas.height=x*Math.ceil(h),this._canvas.style.width=`${C}px`,this._canvas.style.height=`${h}px`}_addMarker(C){this._markers.push(C)}_removeMarker(C){const h=this._markers.indexOf(C);h!==-1&&this._markers.splice(h,1)}_addPopup(C){this._popups.push(C)}_removePopup(C){const h=this._popups.indexOf(C);h!==-1&&this._popups.splice(h,1)}_setupPainter(){const C=Object.assign({},b.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl2",C);h?(rt(h,!0),this.painter=new eC(h,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",x=>{x.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.k.testSupport(h)):this.fire(new i.y(new Error("Failed to initialize WebGL")))}_contextLost(C){C.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:C}))}_contextRestored(C){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:C}))}_onMapScroll(C){if(C.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(C){return this.style?(this._styleDirty=this._styleDirty||C,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(C){return this._update(),this._renderTaskQueue.add(C)}_cancelRenderFrame(C){this._renderTaskQueue.remove(C)}_requestDomTask(C){!this.loaded()||this.loaded()&&!this.isMoving()?C():this._domRenderTaskQueue.add(C)}_render(C){let h;this.fire(new i.z("renderstart")),++this._frameId;const x=this.painter.context.extTimerQuery,T=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(h=D.createQuery(),D.beginQuery(x.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(C),this._domRenderTaskQueue.run(C),this._removed)return;this._updateProjectionTransition();const R=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const re=this.transform.zoom,ae=this.transform.pitch,me=i.o.now(),he=new i.ac(re,{now:me,fadeDuration:R,pitch:ae,transition:this.style.transition,worldview:this._worldview});this.style.update(he)}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(T),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):z=this._updateAverageElevation(T);const V=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,R,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),V&&(this._placementDirty=V.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:R,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,f.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 re=i.o.now()-T;D.endQuery(x.TIME_ELAPSED_EXT),setTimeout(()=>{const ae=D.getQueryParameter(h,D.QUERY_RESULT)/1e6;D.deleteQuery(h),this.fire(new i.z("gpu-timing-frame",{cpuTime:re,gpuTime:ae}))},50)}if(this.listens("gpu-timing-layer")){const re=this.painter.collectGpuTimers();setTimeout(()=>{const ae=this.painter.queryGpuTimers(re);this.fire(new i.z("gpu-timing-layer",{layerTimes:ae}))},50)}if(this.listens("gpu-timing-deferred-render")){const re=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const ae=this.painter.queryGpuTimeDeferredRender(re);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:ae}))},50)}const X=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(X||this._repaint)this.triggerRepaint();else{const re=this.idle();if(re&&(z=this._updateAverageElevation(T,!0)),z)this.triggerRepaint();else if(this._triggerFrame(!1),re&&(this.fire(new i.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const ae=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:ae})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||X||(this._fullyLoaded=!0,f.mark(u.fullLoad),this._performanceMetricsCollection&&Rt(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(C){for(const h of this._markers)C&&!this.getRenderWorldCopies()&&(h._lngLat=h._lngLat.wrap()),h._update();for(const h of this._popups)!C||this.getRenderWorldCopies()||h._trackPointer||(h._lngLat=h._lngLat.wrap()),h._update()}_updateAverageElevation(C,h=!1){const x=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&x(0);const T=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(T||(h||C-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(C)){const D=this.transform.averageElevation;let R=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(R)?R=0:this._averageElevationLastSampledAt=C;const z=Math.abs(D-R);if(z>1){if(this._isInitialLoad||T)return this._averageElevation.jumpTo(R),x(R);this._averageElevation.easeTo(R,C,300)}else if(z>1e-4)return this._averageElevation.jumpTo(R),x(R)}return!!this._averageElevation.isEasing(C)&&x(this._averageElevation.getValue(C))}_authenticate(){Qe(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,C=>{if(C&&(C.message===te||C.status===401)){const h=this.painter.context.gl;rt(h,!1),this._logoControl instanceof Nb&&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&&Pe(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Ie(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){dt(this._requestManager._customAccessToken)}_updateTerrain(){const C=this._isDragging();this.painter.updateTerrain(this.style,C)}_calculateSpeedIndex(){const C=this.painter.canvasCopy(),h=this.painter.getCanvasCopiesAndTimestamps();h.timeStamps.push(performance.now());const x=this.painter.context.gl,T=x.createFramebuffer();function D(R){x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,R,0);const z=new Uint8Array(x.drawingBufferWidth*x.drawingBufferHeight*4);return x.readPixels(0,0,x.drawingBufferWidth,x.drawingBufferHeight,x.RGBA,x.UNSIGNED_BYTE,z),z}return x.bindFramebuffer(x.FRAMEBUFFER,T),this._canvasPixelComparison(D(C),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(C,h,x){let T=x[1]-x[0];const D=C.length/4;for(let R=0;R{const x=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,x&&this._render(h)}))}_preloadTiles(C){const h=this.style?this.style.getSourceCaches():[];return i.bw(h,(x,T)=>x._preloadTiles(C,T),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(C){this._trackResize&&this.resize({originalEvent:C})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(C){this._showTileBoundaries!==C&&(this._showTileBoundaries=C,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(C){this._showParseStatus!==C&&(this._showParseStatus=C,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(C){this._showTerrainWireframe!==C&&(this._showTerrainWireframe=C,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(C){this._showLayers2DWireframe!==C&&(this._showLayers2DWireframe=C,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(C){this._showLayers3DWireframe!==C&&(this._showLayers3DWireframe=C,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(C){this._speedIndexTiming!==C&&(this._speedIndexTiming=C,this._update())}get showPadding(){return!!this._showPadding}set showPadding(C){this._showPadding!==C&&(this._showPadding=C,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(C){this._showCollisionBoxes!==C&&(this._showCollisionBoxes=C,this.style&&C?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(C){this._showOverdrawInspector!==C&&(this._showOverdrawInspector=C,this._update())}get repaint(){return!!this._repaint}set repaint(C){this._repaint!==C&&(this._repaint=C,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(C){this._vertices=C,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(C){this._showTileAABBs!==C&&(this._showTileAABBs=C,C&&this._update())}_setCacheLimits(C,h){i.f4(C,h)}get version(){return d}},NavigationControl:class{constructor(C={}){this.options=Object.assign({},Qce,C),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",h=>{this._map&&this._map.zoomIn({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",h=>{this._map&&this._map.zoomOut({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",h=>{const x=this._map;x&&(this.options.visualizePitch?x.resetNorthPitch({},{originalEvent:h}):x.resetNorth({},{originalEvent:h}))}),this._compassIcon=w("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const C=this._map;if(!C)return;const h=C.getZoom(),x=h===C.getMaxZoom(),T=h===C.getMinZoom();this._zoomInButton.disabled=x,this._zoomOutButton.disabled=T,this._zoomInButton.setAttribute("aria-disabled",x.toString()),this._zoomOutButton.setAttribute("aria-disabled",T.toString())}_rotateCompassArrow(){const C=this._map;if(!C)return;const h=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(C.transform.pitch*(Math.PI/180)),.5)}) rotateX(${C.transform.pitch}deg) rotateZ(${C.transform.angle*(180/Math.PI)}deg)`:`rotate(${C.transform.angle*(180/Math.PI)}deg)`;C._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=h)})}onAdd(C){return this._map=C,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),C.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&C.on("pitch",this._rotateCompassArrow),C.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Jce(C,this._compass,this.options.visualizePitch)),this._container}onRemove(){const C=this._map;C&&(this._container.remove(),this.options.showZoom&&C.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&C.off("pitch",this._rotateCompassArrow),C.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(C,h){const x=w("button",C,this._container);return x.type="button",x.addEventListener("click",h),x}_setButtonTitle(C,h){if(!this._map)return;const x=this._map._getUIString(`NavigationControl.${h}`);C.setAttribute("aria-label",x),C.firstElementChild&&C.firstElementChild.setAttribute("title",x)}},GeolocateControl:class extends i.E{constructor(C={}){super();const h=navigator.geolocation;this.options=Object.assign({geolocation:h},ede,C),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=tC(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(C){return this._map=C,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(C){const h=(x=!!this.options.geolocation)=>{this._supportsGeolocation=x,C(x)};this._supportsGeolocation!==void 0?C(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(x=>h(x.state!=="denied")).catch(()=>h()):h()}_isOutOfMapMaxBounds(C){const h=this._map.getMaxBounds(),x=C.coords;return!!h&&(x.longitudeh.getEast()||x.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(C){if(this._map){if(this._isOutOfMapMaxBounds(C))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",C)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=C,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(C),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(C),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:C.coords,timestamp:C.timestamp},C.toJSON?{toJSON:C.toJSON.bind(C)}:{}))),this._finish()}}_updateCamera(C){const h=new i.aT(C.coords.longitude,C.coords.latitude),x=C.coords.accuracy,T=this._map.getBearing(),D=Object.assign({bearing:T},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(x),D,{geolocateSource:!0})}_updateMarker(C){if(C){const h=new i.aT(C.coords.longitude,C.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=C.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const C=this._map.transform,h=i.cf(1,C._center.lat)*C.worldSize,x=Math.ceil(2*this._accuracy*h);this._circleElement.style.width=`${x}px`,this._circleElement.style.height=`${x}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(C){if(this._map){if(this.options.trackUserLocation)if(C.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(C.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",C)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(C){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=w("button","mapboxgl-ctrl-geolocate",this._container),w("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",C===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=w("div","mapboxgl-user-location"),this._dotElement.appendChild(w("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(w("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new pC({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=w("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new pC({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(C){this._userLocationDotMarker&&(C.webkitCompassHeading?this._heading=C.webkitCompassHeading:C.absolute===!0&&(this._heading=-1*C.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 C;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(C={maximumAge:6e5,timeout:0},this._noTimeout=!0):(C=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,C),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 C=()=>{"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"&&C()}).catch(console.error):C()}_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:kb,ScaleControl:class{constructor(C={}){this.options=Object.assign({},Nv,C),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const C=this.options.maxWidth||100,h=this._map,x=h._containerHeight/2,T=h._containerWidth/2-C/2,D=h.unproject([T,x]),R=h.unproject([T+C,x]),z=D.distanceTo(R);if(this.options.unit==="imperial"){const V=3.2808*z;V>5280?this._setScale(C,V/5280,"mile"):this._setScale(C,V,"foot")}else this.options.unit==="nautical"?this._setScale(C,z/1852,"nautical-mile"):z>=1e3?this._setScale(C,z/1e3,"kilometer"):this._setScale(C,z,"meter")}_setScale(C,h,x){this._map._requestDomTask(()=>{const T=function(R){const z=Math.pow(10,`${Math.floor(R)}`.length-1);let V=R/z;return V=V>=10?10:V>=5?5:V>=3?3:V>=2?2:V>=1?1:function(X){const re=Math.pow(10,Math.ceil(-Math.log(X)/Math.LN10));return Math.round(X*re)/re}(V),z*V}(h),D=T/h;this._container.innerHTML=x!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:x}).format(T):`${T} ${OT[x]}`,this._container.style.width=C*D+"px"})}onAdd(C){return this._map=C,this._language=C.getLanguage(),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-scale",C.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(C){this._language=C,this._update()}setUnit(C){this.options.unit=C,this._update()}},FullscreenControl:class{constructor(C={}){this._fullscreen=!1,C&&C.container&&(C.container instanceof HTMLElement?this._container=C.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(C){return this._map=C,this._container||(this._container=this._map.getContainer()),this._controlContainer=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const C=this._fullscreenButton=w("button","mapboxgl-ctrl-fullscreen",this._controlContainer);w("span","mapboxgl-ctrl-icon",C).setAttribute("aria-hidden","true"),C.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const C=this._getTitle();this._fullscreenButton.setAttribute("aria-label",C),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",C)}_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:kv,Popup:class extends i.E{constructor(C){super(),this.options=Object.assign(Object.create(nm),C),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(C&&C.className?C.className.trim().split(/\s+/):[])}addTo(C){return this._map&&this.remove(),this._map=C,this.options.closeOnClick&&C.on("preclick",this._onClose),this.options.closeOnMove&&C.on("move",this._onClose),C.on("remove",this.remove),this._update(),C._addPopup(this),this._focusFirstElement(),this._trackPointer?(C.on("mousemove",this._onMouseEvent),C.on("mouseup",this._onMouseEvent),C._canvasContainer.classList.add("mapboxgl-track-pointer")):C.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 C=this._map;return C&&(C.off("move",this._update),C.off("move",this._onClose),C.off("preclick",this._onClose),C.off("click",this._onClose),C.off("remove",this.remove),C.off("mousemove",this._onMouseEvent),C.off("mouseup",this._onMouseEvent),C.off("drag",this._onMouseEvent),C._canvasContainer&&C._canvasContainer.classList.remove("mapboxgl-track-pointer"),C._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(C){this._lngLat=i.aT.convert(C),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(C){return this._altitude=C,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const C=this._map;return C&&(C.off("move",this._update),C.on("mousemove",this._onMouseEvent),C.on("drag",this._onMouseEvent),C._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(C){return this.setDOMContent(document.createTextNode(C))}setHTML(C){const h=document.createDocumentFragment(),x=document.createElement("body");let T;for(x.innerHTML=C;T=x.firstChild,T;)h.appendChild(T);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(C){return this.options.maxWidth=C,this._update(),this}setDOMContent(C){let h=this._content;if(h)for(;h.hasChildNodes();)h.firstChild&&h.removeChild(h.firstChild);else h=this._content=w("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(C),this.options.closeButton){const x=this._closeButton=w("button","mapboxgl-popup-close-button",h);x.type="button",x.setAttribute("aria-label","Close popup"),x.innerHTML='',x.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(C){return this._classList.add(C),this._updateClassList(),this}removeClassName(C){return this._classList.delete(C),this._updateClassList(),this}setOffset(C){return this.options.offset=C,this._update(),this}toggleClassName(C){let h;return this._classList.delete(C)?h=!1:(this._classList.add(C),h=!0),this._updateClassList(),h}_onMouseEvent(C){this._update(C.point)}_getAnchor(C){if(this.options.anchor)return this.options.anchor;const h=this._map,x=this._container,T=this._pos;if(!h||!x||!T)return"bottom";const D=x.offsetWidth,R=x.offsetHeight,z=T.xh.transform.width-D/2;if(T.y+Ch.transform.height-R){if(z)return"bottom-left";if(V)return"bottom-right"}return z?"left":V?"right":"bottom"}_updateClassList(){const C=this._container;if(!C)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"),C.className=h.join(" ")}_update(C){const h=this._map,x=this._content;if(!h||!this._lngLat&&!this._trackPointer||!x)return;let T=this._container;if(T||(T=this._container=w("div","mapboxgl-popup",h.getContainer()),this._tip=w("div","mapboxgl-popup-tip",T),T.appendChild(x)),this.options.maxWidth&&T.style.maxWidth!==this.options.maxWidth&&(T.style.maxWidth=this.options.maxWidth),h.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=DT(this._lngLat,this._pos,h.transform)),!this._trackPointer||C){const D=this._pos=this._trackPointer&&C instanceof i.P?C:h.project(this._lngLat,this._altitude),R=Py(this.options.offset),z=this._anchor=this._getAnchor(R.y),V=Py(this.options.offset,z),X=D.add(V).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${dd[z]} translate(${X.x}px,${X.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 C=this._container.querySelector(am);C&&C.focus()}_onClose(){this.remove()}_setOpacity(C){this._container&&(this._container.style.opacity=`${C}`),this._content&&(this._content.style.pointerEvents=C?"auto":"none")}},Marker:pC,Style:sm,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:Wd,Evented:i.E,config:i.e,prewarm:i.f9,clearPrewarmedResources:i.f8,get accessToken(){return i.e.ACCESS_TOKEN},set accessToken(C){i.e.ACCESS_TOKEN=C},get baseApiUrl(){return i.e.API_URL},set baseApiUrl(C){i.e.API_URL=C},get workerCount(){return i.fi.workerCount},set workerCount(C){i.fi.workerCount=C},get maxParallelImageRequests(){return i.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(C){i.e.MAX_PARALLEL_IMAGE_REQUESTS=C},clearStorage(C){i.fh(C)},get workerUrl(){return i.fg.workerUrl},set workerUrl(C){i.fg.workerUrl=C},get workerClass(){return i.fg.workerClass},set workerClass(C){i.fg.workerClass=C},get workerParams(){return i.fg.workerParams},set workerParams(C){i.fg.workerParams=C},get dracoUrl(){return i.ff()},set dracoUrl(C){i.fe(C)},get meshoptUrl(){return i.fd()},set meshoptUrl(C){i.fc(C)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(tBe);var Wxt=tBe.exports;const Fc=vo(Wxt);function gs({className:t,...s}){return e.jsx("div",{className:It("animate-pulse rounded-md bg-muted",t),...s})}const u5e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},h5e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Gxt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Kxt({listings:t,isLoading:s}){const r=Or(),n=M.useRef(null),a=M.useRef(null),o=M.useRef([]),[l,i]=M.useState(""),[d,u]=M.useState(!0);return M.useEffect(()=>{(async()=>{u(!0);try{const{data:v}=await K.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();v!=null&&v.value&&i(v.value)}catch(v){console.error("Error fetching mapbox token:",v)}u(!1)})()},[]),M.useEffect(()=>{if(!n.current||!l||a.current)return;Fc.accessToken=l;const g=t.filter(b=>b.latitude!=null&&b.longitude!=null);let v=[-98.5795,39.8283],_=4;if(g.length>0){const b=g.reduce((j,N)=>j+N.longitude,0)/g.length,w=g.reduce((j,N)=>j+N.latitude,0)/g.length;v=[b,w],_=g.length===1?12:10}return a.current=new Fc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:v}),a.current.addControl(new Fc.NavigationControl,"top-right"),()=>{var b;(b=a.current)==null||b.remove(),a.current=null}},[l]),M.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(v=>v.remove()),o.current=[];const g=t.filter(v=>v.latitude!=null&&v.longitude!=null);if(g.forEach(v=>{var I,L,F;const _=u5e[v.status]||"#10B981",b=((I=v.photos)==null?void 0:I.find($=>$.is_primary))||((L=v.photos)==null?void 0:L[0]),j=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${v.slug||v.id}`:`/public/listing/${v.slug||v.id}`,N=document.createElement("div");N.className="cursor-pointer",N.innerHTML=`
`;const S=new Fc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${Gxt(v.price)}
${v.property_address||""}
${v.city}, ${v.state}
${h5e[v.status]||v.status} ${v.bedrooms?`${v.bedrooms} bed`:""} ${v.bathrooms?`${v.bathrooms} bath`:""}
${(F=v.agent)!=null&&F.name?`
Listed by ${v.agent.name}
`:""}
Click to view details →
`),A=new Fc.Marker(N).setLngLat([v.longitude,v.latitude]).setPopup(S).addTo(a.current);o.current.push(A)}),g.length>1){const v=new Fc.LngLatBounds;g.forEach(_=>v.extend([_.longitude,_.latitude])),a.current.fitBounds(v,{padding:60,maxZoom:13})}else g.length===1&&a.current.flyTo({center:[g[0].longitude,g[0].latitude],zoom:12})},[t,l]),M.useEffect(()=>(window.__navigateToPublicListing__=g=>{r(g)},()=>{delete window.__navigateToPublicListing__}),[r]),d||s?e.jsx(gs,{className:"w-full h-[500px] rounded-lg"}):!l||t.filter(g=>g.latitude!=null&&g.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(u5e).map(([g,v])=>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:v}}),e.jsx("span",{className:"text-xs text-gray-600",children:h5e[g]})]},g))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function PI(t,[s,r]){return Math.min(r,Math.max(s,t))}function lL(t){const s=M.useRef({value:t,previous:t});return M.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var Zxt=[" ","Enter","ArrowUp","ArrowDown"],Yxt=[" ","Enter"],jN="Select",[loe,coe,Xxt]=W6(jN),[oM]=Cc(jN,[Xxt,iy]),doe=iy(),[Qxt,I_]=oM(jN),[Jxt,eyt]=oM(jN),rBe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:u,name:f,autoComplete:g,disabled:v,required:_,form:b}=t,w=doe(s),[j,N]=M.useState(null),[S,A]=M.useState(null),[I,L]=M.useState(!1),F=E_(u),[$,q]=uu({prop:n,defaultProp:a??!1,onChange:o,caller:jN}),[H,U]=uu({prop:l,defaultProp:i,onChange:d,caller:jN}),Q=M.useRef(null),se=j?b||!!j.closest("form"):!0,[te,Y]=M.useState(new Set),ce=Array.from(te).map(oe=>oe.props.value).join(";");return e.jsx(Y6,{...w,children:e.jsxs(Qxt,{required:_,scope:s,trigger:j,onTriggerChange:N,valueNode:S,onValueNodeChange:A,valueNodeHasChildren:I,onValueNodeHasChildrenChange:L,contentId:Bd(),value:H,onValueChange:U,open:$,onOpenChange:q,dir:F,triggerPointerDownPosRef:Q,disabled:v,children:[e.jsx(loe.Provider,{scope:s,children:e.jsx(Jxt,{scope:t.__scopeSelect,onNativeOptionAdd:M.useCallback(oe=>{Y(le=>new Set(le).add(oe))},[]),onNativeOptionRemove:M.useCallback(oe=>{Y(le=>{const de=new Set(le);return de.delete(oe),de})},[]),children:r})}),se?e.jsxs(CBe,{"aria-hidden":!0,required:_,tabIndex:-1,name:f,autoComplete:g,value:H,onChange:oe=>U(oe.target.value),disabled:v,form:b,children:[H===void 0?e.jsx("option",{value:""}):null,Array.from(te)]},ce):null]})})};rBe.displayName=jN;var nBe="SelectTrigger",aBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=doe(r),l=I_(nBe,r),i=l.disabled||n,d=Sa(s,l.onTriggerChange),u=coe(r),f=M.useRef("touch"),[g,v,_]=TBe(w=>{const j=u().filter(A=>!A.disabled),N=j.find(A=>A.value===l.value),S=ABe(j,w,N);S!==void 0&&l.onValueChange(S.value)}),b=w=>{i||(l.onOpenChange(!0),_()),w&&(l.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return e.jsx(J3,{asChild:!0,...o,children:e.jsx(Qr.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":MBe(l.value)?"":void 0,...a,ref:d,onClick:Sr(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&b(w)}),onPointerDown:Sr(a.onPointerDown,w=>{f.current=w.pointerType;const j=w.target;j.hasPointerCapture(w.pointerId)&&j.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(b(w),w.preventDefault())}),onKeyDown:Sr(a.onKeyDown,w=>{const j=g.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&v(w.key),!(j&&w.key===" ")&&Zxt.includes(w.key)&&(b(),w.preventDefault())})})})});aBe.displayName=nBe;var iBe="SelectValue",oBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,d=I_(iBe,r),{onValueNodeHasChildrenChange:u}=d,f=o!==void 0,g=Sa(s,d.onValueNodeChange);return Hc(()=>{u(f)},[u,f]),e.jsx(Qr.span,{...i,ref:g,style:{pointerEvents:"none"},children:MBe(d.value)?e.jsx(e.Fragment,{children:l}):o})});oBe.displayName=iBe;var tyt="SelectIcon",lBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(Qr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});lBe.displayName=tyt;var syt="SelectPortal",cBe=t=>e.jsx(Z3,{asChild:!0,...t});cBe.displayName=syt;var kN="SelectContent",dBe=M.forwardRef((t,s)=>{const r=I_(kN,t.__scopeSelect),[n,a]=M.useState();if(Hc(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?xm.createPortal(e.jsx(uBe,{scope:t.__scopeSelect,children:e.jsx(loe.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(hBe,{...t,ref:s})});dBe.displayName=kN;var ig=10,[uBe,L_]=oM(kN),ryt="SelectContentImpl",nyt=m_("SelectContent.RemoveScroll"),hBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:d,align:u,alignOffset:f,arrowPadding:g,collisionBoundary:v,collisionPadding:_,sticky:b,hideWhenDetached:w,avoidCollisions:j,...N}=t,S=I_(kN,r),[A,I]=M.useState(null),[L,F]=M.useState(null),$=Sa(s,Pe=>I(Pe)),[q,H]=M.useState(null),[U,Q]=M.useState(null),se=coe(r),[te,Y]=M.useState(!1),ce=M.useRef(!1);M.useEffect(()=>{if(A)return eoe(A)},[A]),Xie();const oe=M.useCallback(Pe=>{const[Fe,...Ie]=se().map(Le=>Le.ref.current),[Ve]=Ie.slice(-1),dt=document.activeElement;for(const Le of Pe)if(Le===dt||(Le==null||Le.scrollIntoView({block:"nearest"}),Le===Fe&&L&&(L.scrollTop=0),Le===Ve&&L&&(L.scrollTop=L.scrollHeight),Le==null||Le.focus(),document.activeElement!==dt))return},[se,L]),le=M.useCallback(()=>oe([q,A]),[oe,q,A]);M.useEffect(()=>{te&&le()},[te,le]);const{onOpenChange:de,triggerPointerDownPosRef:xe}=S;M.useEffect(()=>{if(A){let Pe={x:0,y:0};const Fe=Ve=>{var dt,Le;Pe={x:Math.abs(Math.round(Ve.pageX)-(((dt=xe.current)==null?void 0:dt.x)??0)),y:Math.abs(Math.round(Ve.pageY)-(((Le=xe.current)==null?void 0:Le.y)??0))}},Ie=Ve=>{Pe.x<=10&&Pe.y<=10?Ve.preventDefault():A.contains(Ve.target)||de(!1),document.removeEventListener("pointermove",Fe),xe.current=null};return xe.current!==null&&(document.addEventListener("pointermove",Fe),document.addEventListener("pointerup",Ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Fe),document.removeEventListener("pointerup",Ie,{capture:!0})}}},[A,de,xe]),M.useEffect(()=>{const Pe=()=>de(!1);return window.addEventListener("blur",Pe),window.addEventListener("resize",Pe),()=>{window.removeEventListener("blur",Pe),window.removeEventListener("resize",Pe)}},[de]);const[be,ye]=TBe(Pe=>{const Fe=se().filter(dt=>!dt.disabled),Ie=Fe.find(dt=>dt.ref.current===document.activeElement),Ve=ABe(Fe,Pe,Ie);Ve&&setTimeout(()=>Ve.ref.current.focus())}),ve=M.useCallback((Pe,Fe,Ie)=>{const Ve=!ce.current&&!Ie;(S.value!==void 0&&S.value===Fe||Ve)&&(H(Pe),Ve&&(ce.current=!0))},[S.value]),ke=M.useCallback(()=>A==null?void 0:A.focus(),[A]),Ge=M.useCallback((Pe,Fe,Ie)=>{const Ve=!ce.current&&!Ie;(S.value!==void 0&&S.value===Fe||Ve)&&Q(Pe)},[S.value]),Ne=n==="popper"?mge:mBe,Ae=Ne===mge?{side:i,sideOffset:d,align:u,alignOffset:f,arrowPadding:g,collisionBoundary:v,collisionPadding:_,sticky:b,hideWhenDetached:w,avoidCollisions:j}:{};return e.jsx(uBe,{scope:r,content:A,viewport:L,onViewportChange:F,itemRefCallback:ve,selectedItem:q,onItemLeave:ke,itemTextRefCallback:Ge,focusSelectedItem:le,selectedItemText:U,position:n,isPositioned:te,searchRef:be,children:e.jsx(sL,{as:nyt,allowPinchZoom:!0,children:e.jsx(eL,{asChild:!0,trapped:S.open,onMountAutoFocus:Pe=>{Pe.preventDefault()},onUnmountAutoFocus:Sr(a,Pe=>{var Fe;(Fe=S.trigger)==null||Fe.focus({preventScroll:!0}),Pe.preventDefault()}),children:e.jsx(C_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Pe=>Pe.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(Ne,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:Pe=>Pe.preventDefault(),...N,...Ae,onPlaced:()=>Y(!0),ref:$,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Sr(N.onKeyDown,Pe=>{const Fe=Pe.ctrlKey||Pe.altKey||Pe.metaKey;if(Pe.key==="Tab"&&Pe.preventDefault(),!Fe&&Pe.key.length===1&&ye(Pe.key),["ArrowUp","ArrowDown","Home","End"].includes(Pe.key)){let Ve=se().filter(dt=>!dt.disabled).map(dt=>dt.ref.current);if(["ArrowUp","End"].includes(Pe.key)&&(Ve=Ve.slice().reverse()),["ArrowUp","ArrowDown"].includes(Pe.key)){const dt=Pe.target,Le=Ve.indexOf(dt);Ve=Ve.slice(Le+1)}setTimeout(()=>oe(Ve)),Pe.preventDefault()}})})})})})})});hBe.displayName=ryt;var ayt="SelectItemAlignedPosition",mBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=I_(kN,r),l=L_(kN,r),[i,d]=M.useState(null),[u,f]=M.useState(null),g=Sa(s,$=>f($)),v=coe(r),_=M.useRef(!1),b=M.useRef(!0),{viewport:w,selectedItem:j,selectedItemText:N,focusSelectedItem:S}=l,A=M.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&w&&j&&N){const $=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),H=o.valueNode.getBoundingClientRect(),U=N.getBoundingClientRect();if(o.dir!=="rtl"){const dt=U.left-q.left,Le=H.left-dt,Rt=$.left-Le,fe=$.width+Rt,Qe=Math.max(fe,q.width),at=window.innerWidth-ig,rt=PI(Le,[ig,Math.max(ig,at-Qe)]);i.style.minWidth=fe+"px",i.style.left=rt+"px"}else{const dt=q.right-U.right,Le=window.innerWidth-H.right-dt,Rt=window.innerWidth-$.right-Le,fe=$.width+Rt,Qe=Math.max(fe,q.width),at=window.innerWidth-ig,rt=PI(Le,[ig,Math.max(ig,at-Qe)]);i.style.minWidth=fe+"px",i.style.right=rt+"px"}const Q=v(),se=window.innerHeight-ig*2,te=w.scrollHeight,Y=window.getComputedStyle(u),ce=parseInt(Y.borderTopWidth,10),oe=parseInt(Y.paddingTop,10),le=parseInt(Y.borderBottomWidth,10),de=parseInt(Y.paddingBottom,10),xe=ce+oe+te+de+le,be=Math.min(j.offsetHeight*5,xe),ye=window.getComputedStyle(w),ve=parseInt(ye.paddingTop,10),ke=parseInt(ye.paddingBottom,10),Ge=$.top+$.height/2-ig,Ne=se-Ge,Ae=j.offsetHeight/2,Pe=j.offsetTop+Ae,Fe=ce+oe+Pe,Ie=xe-Fe;if(Fe<=Ge){const dt=Q.length>0&&j===Q[Q.length-1].ref.current;i.style.bottom="0px";const Le=u.clientHeight-w.offsetTop-w.offsetHeight,Rt=Math.max(Ne,Ae+(dt?ke:0)+Le+le),fe=Fe+Rt;i.style.height=fe+"px"}else{const dt=Q.length>0&&j===Q[0].ref.current;i.style.top="0px";const Rt=Math.max(Ge,ce+w.offsetTop+(dt?ve:0)+Ae)+Ie;i.style.height=Rt+"px",w.scrollTop=Fe-Ge+w.offsetTop}i.style.margin=`${ig}px 0`,i.style.minHeight=be+"px",i.style.maxHeight=se+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[v,o.trigger,o.valueNode,i,u,w,j,N,o.dir,n]);Hc(()=>A(),[A]);const[I,L]=M.useState();Hc(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const F=M.useCallback($=>{$&&b.current===!0&&(A(),S==null||S(),b.current=!1)},[A,S]);return e.jsx(oyt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:F,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:e.jsx(Qr.div,{...a,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});mBe.displayName=ayt;var iyt="SelectPopperPosition",mge=M.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=ig,...o}=t,l=doe(r);return e.jsx(X6,{...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)"}})});mge.displayName=iyt;var[oyt,I1e]=oM(kN,{}),pge="SelectViewport",pBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=L_(pge,r),l=I1e(pge,r),i=Sa(s,o.onViewportChange),d=M.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(loe.Slot,{scope:r,children:e.jsx(Qr.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Sr(a.onScroll,u=>{const f=u.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:v}=l;if(v!=null&&v.current&&g){const _=Math.abs(d.current-f.scrollTop);if(_>0){const b=window.innerHeight-ig*2,w=parseFloat(g.style.minHeight),j=parseFloat(g.style.height),N=Math.max(w,j);if(N0?I:0,g.style.justifyContent="flex-end")}}}d.current=f.scrollTop})})})]})});pBe.displayName=pge;var fBe="SelectGroup",[lyt,cyt]=oM(fBe),dyt=M.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Bd();return e.jsx(lyt,{scope:r,id:a,children:e.jsx(Qr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});dyt.displayName=fBe;var gBe="SelectLabel",xBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=cyt(gBe,r);return e.jsx(Qr.div,{id:a.id,...n,ref:s})});xBe.displayName=gBe;var Qre="SelectItem",[uyt,yBe]=oM(Qre),vBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=I_(Qre,r),d=L_(Qre,r),u=i.value===n,[f,g]=M.useState(o??""),[v,_]=M.useState(!1),b=Sa(s,S=>{var A;return(A=d.itemRefCallback)==null?void 0:A.call(d,S,n,a)}),w=Bd(),j=M.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(uyt,{scope:r,value:n,disabled:a,textId:w,isSelected:u,onItemTextChange:M.useCallback(S=>{g(A=>A||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(loe.ItemSlot,{scope:r,value:n,disabled:a,textValue:f,children:e.jsx(Qr.div,{role:"option","aria-labelledby":w,"data-highlighted":v?"":void 0,"aria-selected":u&&v,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:b,onFocus:Sr(l.onFocus,()=>_(!0)),onBlur:Sr(l.onBlur,()=>_(!1)),onClick:Sr(l.onClick,()=>{j.current!=="mouse"&&N()}),onPointerUp:Sr(l.onPointerUp,()=>{j.current==="mouse"&&N()}),onPointerDown:Sr(l.onPointerDown,S=>{j.current=S.pointerType}),onPointerMove:Sr(l.onPointerMove,S=>{var A;j.current=S.pointerType,a?(A=d.onItemLeave)==null||A.call(d):j.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Sr(l.onPointerLeave,S=>{var A;S.currentTarget===document.activeElement&&((A=d.onItemLeave)==null||A.call(d))}),onKeyDown:Sr(l.onKeyDown,S=>{var I;((I=d.searchRef)==null?void 0:I.current)!==""&&S.key===" "||(Yxt.includes(S.key)&&N(),S.key===" "&&S.preventDefault())})})})})});vBe.displayName=Qre;var gE="SelectItemText",_Be=M.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=I_(gE,r),i=L_(gE,r),d=yBe(gE,r),u=eyt(gE,r),[f,g]=M.useState(null),v=Sa(s,N=>g(N),d.onItemTextChange,N=>{var S;return(S=i.itemTextRefCallback)==null?void 0:S.call(i,N,d.value,d.disabled)}),_=f==null?void 0:f.textContent,b=M.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:w,onNativeOptionRemove:j}=u;return Hc(()=>(w(b),()=>j(b)),[w,j,b]),e.jsxs(e.Fragment,{children:[e.jsx(Qr.span,{id:d.textId,...o,ref:v}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?xm.createPortal(o.children,l.valueNode):null]})});_Be.displayName=gE;var bBe="SelectItemIndicator",wBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return yBe(bBe,r).isSelected?e.jsx(Qr.span,{"aria-hidden":!0,...n,ref:s}):null});wBe.displayName=bBe;var fge="SelectScrollUpButton",jBe=M.forwardRef((t,s)=>{const r=L_(fge,t.__scopeSelect),n=I1e(fge,t.__scopeSelect),[a,o]=M.useState(!1),l=Sa(s,n.onScrollButtonChange);return Hc(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollTop>0;o(u)};const d=r.viewport;return i(),d.addEventListener("scroll",i),()=>d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(NBe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});jBe.displayName=fge;var gge="SelectScrollDownButton",kBe=M.forwardRef((t,s)=>{const r=L_(gge,t.__scopeSelect),n=I1e(gge,t.__scopeSelect),[a,o]=M.useState(!1),l=Sa(s,n.onScrollButtonChange);return Hc(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollHeight-d.clientHeight,f=Math.ceil(d.scrollTop)d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(NBe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});kBe.displayName=gge;var NBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=L_("SelectScrollButton",r),l=M.useRef(null),i=coe(r),d=M.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return M.useEffect(()=>()=>d(),[d]),Hc(()=>{var f;const u=i().find(g=>g.ref.current===document.activeElement);(f=u==null?void 0:u.ref.current)==null||f.scrollIntoView({block:"nearest"})},[i]),e.jsx(Qr.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Sr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Sr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Sr(a.onPointerLeave,()=>{d()})})}),hyt="SelectSeparator",SBe=M.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Qr.div,{"aria-hidden":!0,...n,ref:s})});SBe.displayName=hyt;var xge="SelectArrow",myt=M.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=doe(r),o=I_(xge,r),l=L_(xge,r);return o.open&&l.position==="popper"?e.jsx(Q6,{...a,...n,ref:s}):null});myt.displayName=xge;var pyt="SelectBubbleInput",CBe=M.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=M.useRef(null),o=Sa(n,a),l=lL(s);return M.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&f){const g=new Event("change",{bubbles:!0});f.call(i,s),i.dispatchEvent(g)}},[l,s]),e.jsx(Qr.select,{...r,style:{...k8e,...r.style},ref:o,defaultValue:s})});CBe.displayName=pyt;function MBe(t){return t===""||t===void 0}function TBe(t){const s=Bc(t),r=M.useRef(""),n=M.useRef(0),a=M.useCallback(l=>{const i=r.current+l;s(i),function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))}(i)},[s]),o=M.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return M.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function ABe(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=fyt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function fyt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var gyt=rBe,EBe=aBe,xyt=oBe,yyt=lBe,vyt=cBe,PBe=dBe,_yt=pBe,IBe=xBe,LBe=vBe,byt=_Be,wyt=wBe,DBe=jBe,OBe=kBe,RBe=SBe;const tr=gyt,rr=xyt,Js=M.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(EBe,{ref:n,className:It("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[s,e.jsx(yyt,{asChild:!0,children:e.jsx(tl,{className:"h-4 w-4 opacity-50"})})]}));Js.displayName=EBe.displayName;const FBe=M.forwardRef(({className:t,...s},r)=>e.jsx(DBe,{ref:r,className:It("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Tg,{className:"h-4 w-4"})}));FBe.displayName=DBe.displayName;const zBe=M.forwardRef(({className:t,...s},r)=>e.jsx(OBe,{ref:r,className:It("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(tl,{className:"h-4 w-4"})}));zBe.displayName=OBe.displayName;const er=M.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(vyt,{children:e.jsxs(PBe,{ref:a,className:It("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[e.jsx(FBe,{}),e.jsx(_yt,{className:It("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(zBe,{})]})}));er.displayName=PBe.displayName;const jyt=M.forwardRef(({className:t,...s},r)=>e.jsx(IBe,{ref:r,className:It("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));jyt.displayName=IBe.displayName;const At=M.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(LBe,{ref:n,className:It("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(wyt,{children:e.jsx(ma,{className:"h-4 w-4"})})}),e.jsx(byt,{children:s})]}));At.displayName=LBe.displayName;const kyt=M.forwardRef(({className:t,...s},r)=>e.jsx(RBe,{ref:r,className:It("-mx-1 my-1 h-px bg-muted",t),...s}));kyt.displayName=RBe.displayName;const Nyt=t=>Tt({queryKey:["public-listings",t],queryFn:async()=>{let s=K.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}}),BBe=t=>Tt({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=K.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}),$Be=()=>Bt({mutationFn:async({listingId:t,agentId:s,firstName:r,lastName:n,email:a,phone:o,shareToken:l})=>{let i=null,d=null;if(l){const{data:v}=await K.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();v&&(i=v.id,d=v.sharing_agent_id)}const{data:u,error:f}=await K.from("listing_leads").insert({listing_id:t,agent_id:d||s,first_name:r,last_name:n,email:a,phone:o,share_id:i,referred_by_agent_id:d}).select().single();if(f)throw f;const{error:g}=await K.functions.invoke("process-listing-lead",{body:{leadId:u.id}});return g&&console.error("Error processing lead:",g),u}}),Syt=()=>Bt({mutationFn:async t=>{const{error:s}=await K.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),Cyt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},m5e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},Myt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function qBe(){const[t,s]=M.useState(""),[r,n]=M.useState(!1),[a,o]=M.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=Nyt({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}),d=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(g),u=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},f=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(Gh,{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(yo,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:eBe,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(${Hxt})`},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(xn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(Re,{placeholder:"Enter an address, neighborhood, city, or ZIP code",value:t,onChange:g=>s(g.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(Z,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(xn,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(Z,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(fP,{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(tr,{value:a.status||"all",onValueChange:g=>o({...a,status:g==="all"?"":g}),children:[e.jsx(Js,{className:"bg-white",children:e.jsx(rr,{placeholder:"Any status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"Any status"}),Object.entries(m5e).map(([g,v])=>e.jsx(At,{value:g,children:v},g))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),e.jsxs(tr,{value:a.propertyType||"all",onValueChange:g=>o({...a,propertyType:g==="all"?"":g}),children:[e.jsx(Js,{className:"bg-white",children:e.jsx(rr,{placeholder:"Any type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"Any type"}),Object.entries(Myt).map(([g,v])=>e.jsx(At,{value:g,children:v},g))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Min Price"}),e.jsx(Re,{type:"number",placeholder:"No min",value:a.minPrice,onChange:g=>o({...a,minPrice:g.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(Re,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:g=>o({...a,maxPrice:g.target.value}),className:"bg-white"})]})]}),f&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(Z,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(Vr,{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(Kxt,{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((g,v)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(gs,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(gs,{className:"h-7 w-28"}),e.jsx(gs,{className:"h-4 w-full"}),e.jsx(gs,{className:"h-4 w-3/4"})]})]},v))}):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(g=>{var w,j,N;const v=((w=g.photos)==null?void 0:w.find(S=>S.is_primary))||((j=g.photos)==null?void 0:j[0]),b=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${g.slug||g.id}`:`/public/listing/${g.slug||g.id}`;return e.jsx(yo,{to:b,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:[v?e.jsx("img",{src:v.photo_url,alt:g.property_address||g.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(Hn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(nt,{className:`absolute top-2 left-2 ${Cyt[g.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:m5e[g.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:S=>S.preventDefault(),children:e.jsx(Oi,{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:d(g.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[g.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:g.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),g.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:g.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),g.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:g.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),g.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:g.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[g.city,", ",g.state]}),g.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:g.agent.name}),((N=g.agent.brokerage)==null?void 0:N.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:g.agent.brokerage.name})]})]})]})},g.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(Hn,{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:f?"Try adjusting your search or filters":"Check back soon for new listings"}),f&&e.jsx(Z,{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:P1e,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 De=M.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));De.displayName="Card";const $t=M.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("flex flex-col space-y-1.5 p-6",t),...s}));$t.displayName="CardHeader";const Vt=M.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:It("text-2xl font-semibold leading-none tracking-tight",t),...s}));Vt.displayName="CardTitle";const _r=M.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:It("text-sm text-muted-foreground",t),...s}));_r.displayName="CardDescription";const Oe=M.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("p-6 pt-0",t),...s}));Oe.displayName="CardContent";const CP=M.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("flex items-center p-6 pt-0",t),...s}));CP.displayName="CardFooter";var Tyt="Label",UBe=M.forwardRef((t,s)=>e.jsx(Qr.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())}}));UBe.displayName=Tyt;var VBe=UBe;const Ayt=VN("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_e=M.forwardRef(({className:t,...s},r)=>e.jsx(VBe,{ref:r,className:It(Ayt(),t),...s}));_e.displayName=VBe.displayName;const Jre="/assets/levelup-logo-color-D3mY9gCJ.png";function Eyt(){const t=sh(),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(qBe,{}):n.startsWith("public/")?null:e.jsx(Pyt,{slug:n})}function Pyt({slug:t}){return e.jsx(Dyt,{slug:t})}const Iyt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Lyt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},p5e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Dyt({slug:t}){var H,U;const{data:s,isLoading:r}=BBe(t),n=$Be(),[a,o]=M.useState(""),[l,i]=M.useState(""),[d,u]=M.useState(""),[f,g]=M.useState(""),[v,_]=M.useState(!1),[b,w]=M.useState(!1),[j,N]=M.useState(null),S=Q=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Q),A=async Q=>{if(Q.preventDefault(),!(!a.trim()||!d.trim()||!s)){_(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:d.trim(),phone:f.trim()}),w(!0),ge.success("Thanks! The agent will be in touch soon.")}catch(se){console.error("Lead submission error:",se),ge.error(`Failed to submit: ${se.message||"Please try again"}`)}finally{_(!1)}}},I=(s==null?void 0:s.photos)||[],L=I.find(Q=>Q.is_primary)||I[0],F=()=>{j!==null&&N(j===0?I.length-1:j-1)},$=()=>{j!==null&&N(j===I.length-1?0:j+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(gs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(gs,{className:"h-10 w-48 mb-6"}),e.jsx(gs,{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(gs,{className:"h-12 w-48"}),e.jsx(gs,{className:"h-6 w-full"}),e.jsx(gs,{className:"h-6 w-3/4"})]}),e.jsx(gs,{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:Jre,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Hn,{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(Z,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const q=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(Gh,{children:[e.jsxs("title",{children:[q," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${p5e[s.property_type]} in ${s.city}, ${s.state}. ${((H=s.description)==null?void 0:H.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),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:Jre,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(Ba,{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((Q,se)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>N(se+1),children:[e.jsx("img",{src:Q.photo_url,alt:`Photo ${se+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),se===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"]})]},Q.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(nt,{className:`${Iyt[s.status]} text-white border-0`,children:Lyt[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:S(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Pi,{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(q1,{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(f0,{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(Ux,{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(nn,{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(nt,{variant:"secondary",children:[e.jsx(_a,{className:"h-3 w-3 mr-1"}),p5e[s.property_type]]}),s.lot_size&&e.jsxs(nt,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(nt,{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(Z,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:[e.jsx(mo,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((U=s.agent.brokerage)==null?void 0:U.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(De,{className:"border-primary",children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:b?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(Ar,{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:A,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Re,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:Q=>o(Q.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Re,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:Q=>i(Q.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email *"}),e.jsx(Re,{id:"email",type:"email",placeholder:"you@example.com",value:d,onChange:Q=>u(Q.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:f,onChange:Q=>g(Q.target.value)})]}),e.jsx(Z,{type:"submit",className:"w-full",disabled:v,children:v?"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(bs,{open:j!==null,onOpenChange:()=>N(null),children:e.jsxs(_s,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ss,{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(Vr,{className:"h-5 w-5"})}),j!==null&&I[j]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[j].photo_url,alt:`Photo ${j+1}`,className:"w-full max-h-[80vh] object-contain"}),I.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:F,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(ec,{className:"h-6 w-6"})}),e.jsx("button",{onClick:$,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(ei,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[j+1," / ",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 uoe({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 HBe=t=>Tt({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await K.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await K.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 K.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 K.from("profiles").select("avatar_url").eq("id",s.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:d}=await K.storage.from("avatars").list(`${s.user_id}`);if(d&&d.length>0){const{data:u}=K.storage.from("avatars").getPublicUrl(`${s.user_id}/${d[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}),Oyt=()=>Tt({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await K.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),Ryt=t=>Tt({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),WBe=()=>{const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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"]}),ge.success("Agent card created")},onError:s=>ge.error(s.message)})},GBe=()=>{const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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"]}),ge.success("Agent card updated")},onError:s=>ge.error(s.message)})},to=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await K.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:{}})},Fyt=async(t,s)=>{const{error:r}=await K.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},KBe=t=>Tt({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.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 K.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(d=>d.interaction_type==="card_view").length)||0,l=(s==null?void 0:s.filter(d=>d.interaction_type==="button_click").length)||0,i=(s==null?void 0:s.filter(d=>d.interaction_type==="contact_saved").length)||0;return{views:o,clicks:l,saves:i,leads:n||[],interactions:s||[]}},enabled:!!t});function hoe({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=M.useState(""),[i,d]=M.useState(""),[u,f]=M.useState(""),[g,v]=M.useState(""),[_,b]=M.useState(""),[w,j]=M.useState(!1),N=async S=>{if(S.preventDefault(),!o.trim()){ge.error("Please enter your name");return}j(!0);try{await Fyt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:g||void 0}),to(r,"lead_submitted",n),K.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:g||void 0}}).catch(A=>console.error("Card lead notify failed:",A)),ge.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(""),d(""),f(""),v(""),b("")}catch{ge.error("Something went wrong. Please try again.")}finally{j(!1)}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(Kr,{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(_e,{htmlFor:"lead-name",children:"Name *"}),e.jsx(Re,{id:"lead-name",value:o,onChange:S=>l(S.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(Re,{id:"lead-phone",type:"tel",value:u,onChange:S=>f(S.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lead-email",children:"Email"}),e.jsx(Re,{id:"lead-email",type:"email",value:i,onChange:S=>d(S.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select one"})}),e.jsxs(er,{children:[e.jsx(At,{value:"buy",children:"Buy a home"}),e.jsx(At,{value:"sell",children:"Sell my home"}),e.jsx(At,{value:"both",children:"Buy & Sell"}),e.jsx(At,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(Re,{id:"lead-message",value:_,onChange:S=>b(S.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(Z,{type:"submit",className:"w-full rounded-2xl",disabled:w,children:w?"Sending...":"Submit"})]})]})})}const zyt=t=>Tt({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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}),Byt=t=>Tt({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),$yt=()=>{const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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]}),ge.success("Block added")},onError:s=>ge.error(s.message)})},qyt=()=>{const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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"]}),ge.success("Block updated")},onError:s=>ge.error(s.message)})},Uyt=()=>{const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),ge.success("Block removed")},onError:s=>ge.error(s.message)})};function Vyt(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 Hyt(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 Wyt={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 Gyt({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=Hyt(r.video_url),o=n||!!a,l=n?Vyt(r.video_url):a||r.video_url;return e.jsx("div",{className:Wyt[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 Kyt={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 Zyt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=M.useState(0);if(n.length===0)return null;const l=Kyt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(d5,{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(d=>(d-1+n.length)%n.length),className:l.nav,children:e.jsx(ec,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((d,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(d=>(d+1)%n.length),className:l.nav,children:e.jsx(ei,{className:"h-4 w-4"})})]})]})}const Yyt={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 Xyt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=Yyt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const Qyt={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 Jyt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=Qyt[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:()=>to(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(un,{className:`h-4 w-4 ${o.icon}`})]},i))})}const yge={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 e0t({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 t0t={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 s0t({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=t0t[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 d=yge[l.platform.toLowerCase()];return!d||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>to(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:e.jsx(e0t,{path:d.icon,color:d.color})},i)})})]})}function moe({cardId:t,variant:s}){const{data:r}=zyt(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(Gyt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(Zyt,{block:l,variant:s},l.id);case"specialties":return e.jsx(Xyt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(Jyt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(s0t,{block:o,cardId:t,variant:s})]})}async function r0t(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 n0t(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 poe(t){const{first:s,last:r}=n0t(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 r0t(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),ge.success("Contact saved!")}function a0t({card:t}){var N;const[s,r]=M.useState(!1),[n,a]=M.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,A)=>{to(t.id,"button_click",S),A()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:ge.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:ge.error("Phone number not available")}),f=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:ge.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),to(t.id,"button_click","book"))},v=()=>{var S,A;to(t.id,"contact_saved"),poe({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(to(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),ge.success("Link copied!")},b=()=>{a("referral"),r(!0),to(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),to(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(mn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(ba,{src:t.avatar_url||void 0,alt:o}),e.jsx(pn,{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(Z,{onClick:d,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(ga,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(Z,{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(ho,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(Z,{onClick:f,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(Ar,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(Z,{onClick:g,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(nn,{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(Gn,{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(uoe,{card:t,variant:"standard"}),e.jsx(moe,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(Z,{variant:"ghost",onClick:v,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Ei,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(Z,{variant:"ghost",onClick:()=>{to(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(Gn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(Z,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(xr,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(Z,{variant:"ghost",onClick:w,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(pc,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(Z,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(nd,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,A)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>to(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(hoe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function i0t({card:t}){var N;const[s,r]=M.useState(!1),[n,a]=M.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,A)=>{to(t.id,"button_click",S),A()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:ge.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:ge.error("Phone number not available")}),f=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:ge.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),to(t.id,"button_click","book"))},v=()=>{var S,A;to(t.id,"contact_saved"),poe({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(to(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),ge.success("Link copied!")},b=()=>{a("referral"),r(!0),to(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),to(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(mn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(ba,{src:t.avatar_url||void 0,alt:o}),e.jsx(pn,{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:ga,label:"Call",handler:d},{icon:ho,label:"Text",handler:u},{icon:Ar,label:"Email",handler:f}].map(({icon:S,label:A,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(S,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:A})]},A))}),e.jsxs("button",{onClick:g,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(nn,{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(Gn,{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(uoe,{card:t,variant:"luxury"}),e.jsx(moe,{cardId:t.id,variant:"luxury"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:v,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Ei,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{to(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(Gn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&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(xr,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(pc,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),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(nd,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,A)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>to(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(hoe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function o0t({card:t}){var A,I,L,F;const[s,r]=M.useState(!1),[n,a]=M.useState("booking"),o=((A=t.profile)==null?void 0:A.name)||"Agent",l=o.split(" ").map($=>$[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:((F=t.bold_theme_colors)==null?void 0:F.button)||"#ff5722"},d=($,q)=>{const H=parseInt($.replace("#",""),16),U=Math.max(0,(H>>16)-q),Q=Math.max(0,(H>>8&255)-q),se=Math.max(0,(H&255)-q);return`#${(U<<16|Q<<8|se).toString(16).padStart(6,"0")}`};d(i.accent,25),d(i.dark,-20),d(i.button,25);const u=($,q)=>{to(t.id,"button_click",$),q()},f=()=>u("call",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`tel:${t.profile.phone}`:ge.error("Phone number not available")}),g=()=>u("text",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`sms:${t.profile.phone}`:ge.error("Phone number not available")}),v=()=>u("email",()=>{var $;($=t.profile)!=null&&$.email?window.location.href=`mailto:${t.profile.email}`:ge.error("Email not available")}),_=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),to(t.id,"button_click","book"))},b=()=>{var $,q;to(t.id,"contact_saved"),poe({name:o,phone:($=t.profile)==null?void 0:$.phone,email:(q=t.profile)==null?void 0:q.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},w=async()=>{if(to(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),ge.success("Link copied!")},j=()=>{a("referral"),r(!0),to(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),to(t.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(mn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(ba,{src:t.avatar_url||void 0,alt:o}),e.jsx(pn,{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:ga,label:"Call",handler:f},{icon:ho,label:"Text",handler:g},{icon:Ar,label:"Email",handler:v}].map(({icon:$,label:q,handler:H})=>e.jsxs("button",{onClick:H,className:"flex flex-col items-center gap-1.5 py-4 text-white rounded-2xl transition-opacity font-bold hover:opacity-85",style:{backgroundColor:i.dark},children:[e.jsx($,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:q})]},q))}),e.jsxs("button",{onClick:_,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(nn,{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(Gn,{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(uoe,{card:t,variant:"bold"}),e.jsx(moe,{cardId:t.id,variant:"bold"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:b,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(Ei,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{to(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(Gn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(xr,{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(pc,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(nd,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map(($,q)=>e.jsx("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>to(t.id,"button_click",`social_${$.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:S[$.platform.toLowerCase()]||"🔗"},q))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(hoe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function l0t({card:t}){var N;const[s,r]=M.useState(!1),[n,a]=M.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,A)=>{to(t.id,"button_click",S),A()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:ge.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:ge.error("Phone number not available")}),f=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:ge.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),to(t.id,"button_click","book"))},v=()=>{var S,A;to(t.id,"contact_saved"),poe({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(to(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),ge.success("Link copied!")},b=()=>{a("referral"),r(!0),to(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),to(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(mn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(ba,{src:t.avatar_url||void 0,alt:o}),e.jsx(pn,{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:ga,label:"Call",handler:d},{icon:ho,label:"Text",handler:u},{icon:Ar,label:"Email",handler:f}].map(({icon:S,label:A,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(S,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:A})]},A))}),e.jsxs("button",{onClick:g,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(nn,{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(Gn,{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(uoe,{card:t,variant:"classic"}),e.jsx(moe,{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:v,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Ei,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{to(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(Gn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&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(xr,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(pc,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),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(nd,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,A)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>to(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:j[S.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(hoe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function L1e({card:t}){switch(t.theme){case"luxury":return e.jsx(i0t,{card:t});case"bold":return e.jsx(o0t,{card:t});case"classic":return e.jsx(l0t,{card:t});case"standard":default:return e.jsx(a0t,{card:t})}}function c0t(){const t=sh();M.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(d0t,{slug:s})}function d0t({slug:t}){return e.jsx(u0t,{slug:t})}function u0t({slug:t}){var o;const{data:s,isLoading:r,error:n}=HBe(t);if(M.useEffect(()=>{s!=null&&s.id&&to(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(gs,{className:"h-28 w-28 rounded-full"}),e.jsx(gs,{className:"h-6 w-48"}),e.jsx(gs,{className:"h-4 w-36"})]}),e.jsx(gs,{className:"h-12 w-full"}),e.jsx(gs,{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(Gh,{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(L1e,{card:s})]})}function ZBe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=M.useState(n||""),[d,u]=M.useState(a||""),[f,g]=M.useState(o||""),[v,_]=M.useState(""),[b,w]=M.useState(""),[j,N]=M.useState(!1),[S,A]=M.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){ge.error("Please enter your name");return}N(!0);try{const{error:F}=await K.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:d.trim()||null,phone:f.trim()||null,intent:v||null,message:b.trim()||null});if(F)throw F;try{await K.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{}K.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:d.trim()||void 0,phone:f.trim()||void 0,intent:v||void 0,message:b.trim()||void 0}}).catch($=>console.error("Presentation lead notify failed:",$)),A(!0)}catch{ge.error("Something went wrong. Please try again.")}finally{N(!1)}};return S?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ma,{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(_e,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(Re,{id:"pres-lead-name",value:l,onChange:L=>i(L.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(Re,{id:"pres-lead-phone",type:"tel",value:f,onChange:L=>g(L.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(Re,{id:"pres-lead-email",type:"email",value:d,onChange:L=>u(L.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(tr,{value:v,onValueChange:_,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select one"})}),e.jsxs(er,{children:[e.jsx(At,{value:"buy",children:"Buy a home"}),e.jsx(At,{value:"sell",children:"Sell my home"}),e.jsx(At,{value:"both",children:"Buy & Sell"}),e.jsx(At,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(Re,{id:"pres-lead-message",value:b,onChange:L=>w(L.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(Z,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:j,children:j?"Sending...":s})]})}function h0t(){const t=sh();M.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(m0t,{shareToken:s})}function m0t({shareToken:t}){var b;const[s,r]=M.useState(null),[n,a]=M.useState(!0),[o,l]=M.useState(0),[i,d]=M.useState(!1);M.useEffect(()=>{u()},[t]);const u=async()=>{const{data:w,error:j}=await K.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(j||!w){d(!0),a(!1);return}const{data:N}=await K.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let S;if(N!=null&&N.brokerage_id){const{data:I}=await K.from("brokerages").select("name").eq("id",N.brokerage_id).single();S=(I==null?void 0:I.name)||void 0}let A=null;if(w.contact_id){const{data:I}=await K.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();A=I}r({...w,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:S,contact_name:A?[A.first_name,A.last_name].filter(Boolean).join(" "):void 0,contact_email:(A==null?void 0:A.email)||void 0,contact_phone:(A==null?void 0:A.phone)||void 0}),a(!1);try{await K.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{}},f=async()=>{if(s){try{await K.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")}},g=w=>{const j=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(j)return`https://www.youtube.com/embed/${j[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const A=w.replace("/play/","/embed/"),I=A.includes("?")?"&":"?";return`${A}${I}responsive=true`}if(w.includes("iframe.mediadelivery.net")){const A=w.includes("?")?"&":"?";return`${w}${A}responsive=true`}const N=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(N)return`https://www.loom.com/embed/${N[1]}`;const S=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return S?`https://iframe.mediadelivery.net/embed/${S[1]}/${S[2]}?responsive=true`:w};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(gs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(gs,{className:"h-64 w-full"}),e.jsx(gs,{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 v=s.sections.filter(w=>w.is_visible!==!1),_=v[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:[_!=null&&_.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: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"})}):_!=null&&_.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:_.image_url,alt:_.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:_==null?void 0:_.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:_==null?void 0:_.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:_==null?void 0:_.description})]}),(_==null?void 0:_.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:_.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:v.map((w,j)=>e.jsx("button",{onClick:()=>l(j),className:It("w-full text-left p-4 rounded-xl border transition-all",o===j?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(j+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},j))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(b=s.cta_url)!=null&&b.trim()?e.jsxs(Z,{size:"lg",onClick:f,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(un,{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(ZBe,{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 p0t(){const{user:t}=Qs();return Tt({queryKey:["open-houses",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.from("open_houses").select("*").order("event_date",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function f0t(t){const{user:s}=Qs(),r=ds();return M.useEffect(()=>{if(!t)return;const n=K.channel(`visitors-${t}`).on("postgres_changes",{event:"INSERT",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()=>{K.removeChannel(n)}},[t,r]),Tt({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await K.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 g0t(){const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{data:n,error:a}=await K.from("open_houses").insert({...r,agent_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),dn({title:"Open house created!"})},onError:r=>{dn({title:"Error",description:r.message,variant:"destructive"})}})}function YBe(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{error:n}=await K.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 x0t(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),dn({title:"Open house deleted"})}})}function XBe(t){return Tt({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await K.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 K.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 QBe(){return Bt({mutationFn:async t=>{const{error:s}=await K.from("open_house_visitors").insert(t);if(s)throw s}})}var foe="Switch",[y0t]=Cc(foe),[v0t,_0t]=y0t(foe),JBe=M.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:u,form:f,...g}=t,[v,_]=M.useState(null),b=Sa(s,A=>_(A)),w=M.useRef(!1),j=v?f||!!v.closest("form"):!0,[N,S]=uu({prop:a,defaultProp:o??!1,onChange:u,caller:foe});return e.jsxs(v0t,{scope:r,checked:N,disabled:i,children:[e.jsx(Qr.button,{type:"button",role:"switch","aria-checked":N,"aria-required":l,"data-state":r9e(N),"data-disabled":i?"":void 0,disabled:i,value:d,...g,ref:b,onClick:Sr(t.onClick,A=>{S(I=>!I),j&&(w.current=A.isPropagationStopped(),w.current||A.stopPropagation())})}),j&&e.jsx(s9e,{control:v,bubbles:!w.current,name:n,value:d,checked:N,required:l,disabled:i,form:f,style:{transform:"translateX(-100%)"}})]})});JBe.displayName=foe;var e9e="SwitchThumb",t9e=M.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=_0t(e9e,r);return e.jsx(Qr.span,{"data-state":r9e(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});t9e.displayName=e9e;var b0t="SwitchBubbleInput",s9e=M.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=M.useRef(null),i=Sa(l,o),d=lL(r),u=Z6(s);return M.useEffect(()=>{const f=l.current;if(!f)return;const g=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(g,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(f,r),f.dispatchEvent(b)}},[d,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}})});s9e.displayName=b0t;function r9e(t){return t?"checked":"unchecked"}var n9e=JBe,w0t=t9e;const qr=M.forwardRef(({className:t,...s},r)=>e.jsx(n9e,{className:It("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...s,ref:r,children:e.jsx(w0t,{className:It("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));qr.displayName=n9e.displayName;function Kn(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 Zo(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function hl(t,s){const r=Kn(t);return isNaN(s)?Zo(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function $h(t,s){const r=Kn(t);if(isNaN(s))return Zo(t,NaN);if(!s)return r;const n=r.getDate(),a=Zo(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 a9e(t,s){const r=+Kn(t);return Zo(t,r+s)}const D1e=6048e5,j0t=864e5,goe=6e4,cL=36e5,k0t=1e3,_8=43200,f5e=1440;function g5e(t,s){return a9e(t,s*cL)}let N0t={};function D_(){return N0t}function Ju(t,s){var i,d,u,f;const r=D_(),n=(s==null?void 0:s.weekStartsOn)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??r.weekStartsOn??((f=(u=r.locale)==null?void 0:u.options)==null?void 0:f.weekStartsOn)??0,a=Kn(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function qh(t){const s=Kn(t);return s.setHours(0,0,0,0),s}function x_(t){const s=Kn(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 op(t,s){const r=qh(t),n=qh(s),a=+r-x_(r),o=+n-x_(n);return Math.round((a-o)/j0t)}function S0t(t){const s=i9e(t),r=Zo(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),z0(r)}function C4(t,s){return a9e(t,s*goe)}function vk(t,s){const r=s*7;return hl(t,r)}function C0t(t,s){return $h(t,s*12)}function M0t(t){let s;return t.forEach(function(r){const n=Kn(r);(s===void 0||s{const n=Kn(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function Hse(t,s){const r=Kn(t),n=Kn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function O1e(t){return Zo(t,Date.now())}function ll(t,s){const r=qh(t),n=qh(s);return+r==+n}function R1e(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function vge(t){if(!R1e(t)&&typeof t!="number")return!1;const s=Kn(t);return!isNaN(Number(s))}function r3(t,s){const r=Kn(t),n=Kn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function A0t(t,s,r){const n=Ju(t,r),a=Ju(s,r),o=+n-x_(n),l=+a-x_(a);return Math.round((o-l)/D1e)}function zg(t,s){const r=Kn(t),n=Kn(s),a=x5e(r,n),o=Math.abs(op(r,n));r.setDate(r.getDate()-a*o);const l=+(x5e(r,n)===-a),i=a*(o-l);return i===0?0:i}function x5e(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 o9e(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function l9e(t,s){return+Kn(t)-+Kn(s)}function E0t(t,s,r){const n=l9e(t,s)/cL;return o9e(r==null?void 0:r.roundingMethod)(n)}function P0t(t){const s=Kn(t);return s.setHours(23,59,59,999),s}function dL(t){const s=Kn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function I0t(t){const s=Kn(t);return+P0t(s)==+dL(s)}function L0t(t,s){const r=Kn(t),n=Kn(s),a=Hse(r,n),o=Math.abs(r3(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=Hse(r,n)===-a;I0t(Kn(t))&&o===1&&Hse(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function D0t(t,s,r){const n=l9e(t,s)/1e3;return o9e(r==null?void 0:r.roundingMethod)(n)}function O0t(t,s){const r=Kn(t.start),n=Kn(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 d=[];for(;+l<=o;)d.push(Kn(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?d.reverse():d}function Bh(t){const s=Kn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function c9e(t){const s=Kn(t),r=Zo(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function xoe(t,s){var i,d,u,f;const r=D_(),n=(s==null?void 0:s.weekStartsOn)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??r.weekStartsOn??((f=(u=r.locale)==null?void 0:u.options)==null?void 0:f.weekStartsOn)??0,a=Kn(t),o=a.getDay(),l=(o{let n;const a=R0t[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 jhe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const z0t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},B0t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},$0t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},q0t={date:jhe({formats:z0t,defaultWidth:"full"}),time:jhe({formats:B0t,defaultWidth:"full"}),dateTime:jhe({formats:$0t,defaultWidth:"full"})},U0t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},V0t=(t,s,r,n)=>U0t[t];function RA(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 H0t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},W0t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},G0t={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"]},K0t={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"]},Z0t={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"}},Y0t={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"}},X0t=(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"},Q0t={ordinalNumber:X0t,era:RA({values:H0t,defaultWidth:"wide"}),quarter:RA({values:W0t,defaultWidth:"wide",argumentCallback:t=>t-1}),month:RA({values:G0t,defaultWidth:"wide"}),day:RA({values:K0t,defaultWidth:"wide"}),dayPeriod:RA({values:Z0t,defaultWidth:"wide",formattingValues:Y0t,defaultFormattingWidth:"wide"})};function FA(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],d=Array.isArray(i)?evt(i,g=>g.test(l)):J0t(i,g=>g.test(l));let u;u=t.valueCallback?t.valueCallback(d):d,u=r.valueCallback?r.valueCallback(u):u;const f=s.slice(l.length);return{value:u,rest:f}}}function J0t(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function evt(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 svt=/^(\d+)(th|st|nd|rd)?/i,rvt=/\d+/i,nvt={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},avt={any:[/^b/i,/^(a|c)/i]},ivt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ovt={any:[/1/i,/2/i,/3/i,/4/i]},lvt={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},cvt={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]},dvt={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},uvt={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]},hvt={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},mvt={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}},pvt={ordinalNumber:tvt({matchPattern:svt,parsePattern:rvt,valueCallback:t=>parseInt(t,10)}),era:FA({matchPatterns:nvt,defaultMatchWidth:"wide",parsePatterns:avt,defaultParseWidth:"any"}),quarter:FA({matchPatterns:ivt,defaultMatchWidth:"wide",parsePatterns:ovt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:FA({matchPatterns:lvt,defaultMatchWidth:"wide",parsePatterns:cvt,defaultParseWidth:"any"}),day:FA({matchPatterns:dvt,defaultMatchWidth:"wide",parsePatterns:uvt,defaultParseWidth:"any"}),dayPeriod:FA({matchPatterns:hvt,defaultMatchWidth:"any",parsePatterns:mvt,defaultParseWidth:"any"})},yoe={code:"en-US",formatDistance:F0t,formatLong:q0t,formatRelative:V0t,localize:Q0t,match:pvt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function fvt(t){const s=Kn(t);return op(s,c9e(s))+1}function F1e(t){const s=Kn(t),r=+z0(s)-+S0t(s);return Math.round(r/D1e)+1}function z1e(t,s){var f,g,v,_;const r=Kn(t),n=r.getFullYear(),a=D_(),o=(s==null?void 0:s.firstWeekContainsDate)??((g=(f=s==null?void 0:s.locale)==null?void 0:f.options)==null?void 0:g.firstWeekContainsDate)??a.firstWeekContainsDate??((_=(v=a.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=Zo(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Ju(l,s),d=Zo(t,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const u=Ju(d,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function gvt(t,s){var i,d,u,f;const r=D_(),n=(s==null?void 0:s.firstWeekContainsDate)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.firstWeekContainsDate)??r.firstWeekContainsDate??((f=(u=r.locale)==null?void 0:u.options)==null?void 0:f.firstWeekContainsDate)??1,a=z1e(t,s),o=Zo(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Ju(o,s)}function B1e(t,s){const r=Kn(t),n=+Ju(r,s)-+gvt(r,s);return Math.round(n/D1e)+1}function Go(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const $v={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return Go(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):Go(r+1,2)},d(t,s){return Go(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 Go(t.getHours()%12||12,s.length)},H(t,s){return Go(t.getHours(),s.length)},m(t,s){return Go(t.getMinutes(),s.length)},s(t,s){return Go(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Go(a,s.length)}},GC={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},y5e={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 $v.y(t,s)},Y:function(t,s,r,n){const a=z1e(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return Go(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):Go(o,s.length)},R:function(t,s){const r=i9e(t);return Go(r,s.length)},u:function(t,s){const r=t.getFullYear();return Go(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 Go(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 Go(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 $v.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 Go(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=B1e(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):Go(a,s.length)},I:function(t,s,r){const n=F1e(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):Go(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):$v.d(t,s)},D:function(t,s,r){const n=fvt(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Go(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 Go(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 Go(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 Go(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=GC.noon:n===0?a=GC.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=GC.evening:n>=12?a=GC.afternoon:n>=4?a=GC.morning:a=GC.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 $v.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):$v.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Go(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):Go(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):$v.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):$v.s(t,s)},S:function(t,s){return $v.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return _5e(n);case"XXXX":case"XX":return ak(n);case"XXXXX":case"XXX":default:return ak(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return _5e(n);case"xxxx":case"xx":return ak(n);case"xxxxx":case"xxx":default:return ak(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+v5e(n,":");case"OOOO":default:return"GMT"+ak(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+v5e(n,":");case"zzzz":default:return"GMT"+ak(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return Go(n,s.length)},T:function(t,s,r){const n=t.getTime();return Go(n,s.length)}};function v5e(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+Go(o,2)}function _5e(t,s){return t%60===0?(t>0?"-":"+")+Go(Math.abs(t)/60,2):ak(t,s)}function ak(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Go(Math.trunc(n/60),2),o=Go(n%60,2);return r+a+s+o}const b5e=(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"})}},u9e=(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"})}},xvt=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return b5e(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}}",b5e(n,s)).replace("{{time}}",u9e(a,s))},_ge={p:u9e,P:xvt},yvt=/^D+$/,vvt=/^Y+$/,_vt=["D","DD","YY","YYYY"];function h9e(t){return yvt.test(t)}function m9e(t){return vvt.test(t)}function bge(t,s,r){const n=bvt(t,s,r);if(console.warn(n),_vt.includes(t))throw new RangeError(n)}function bvt(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 wvt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,jvt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,kvt=/^'([^]*?)'?$/,Nvt=/''/g,Svt=/[a-zA-Z]/;function js(t,s,r){var f,g,v,_,b,w,j,N;const n=D_(),a=(r==null?void 0:r.locale)??n.locale??yoe,o=(r==null?void 0:r.firstWeekContainsDate)??((g=(f=r==null?void 0:r.locale)==null?void 0:f.options)==null?void 0:g.firstWeekContainsDate)??n.firstWeekContainsDate??((_=(v=n.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((w=(b=r==null?void 0:r.locale)==null?void 0:b.options)==null?void 0:w.weekStartsOn)??n.weekStartsOn??((N=(j=n.locale)==null?void 0:j.options)==null?void 0:N.weekStartsOn)??0,i=Kn(t);if(!vge(i))throw new RangeError("Invalid time value");let d=s.match(jvt).map(S=>{const A=S[0];if(A==="p"||A==="P"){const I=_ge[A];return I(S,a.formatLong)}return S}).join("").match(wvt).map(S=>{if(S==="''")return{isToken:!1,value:"'"};const A=S[0];if(A==="'")return{isToken:!1,value:Cvt(S)};if(y5e[A])return{isToken:!0,value:S};if(A.match(Svt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+A+"`");return{isToken:!1,value:S}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return d.map(S=>{if(!S.isToken)return S.value;const A=S.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&m9e(A)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&h9e(A))&&bge(A,s,String(t));const I=y5e[A[0]];return I(i,A,a.localize,u)}).join("")}function Cvt(t){const s=t.match(kvt);return s?s[1].replace(Nvt,"'"):t}function Mvt(t,s,r){const n=D_(),a=(r==null?void 0:r.locale)??n.locale??yoe,o=2520,l=Hse(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 d,u;l>0?(d=Kn(s),u=Kn(t)):(d=Kn(t),u=Kn(s));const f=D0t(u,d),g=(x_(u)-x_(d))/1e3,v=Math.round((f-g)/60);let _;if(v<2)return r!=null&&r.includeSeconds?f<5?a.formatDistance("lessThanXSeconds",5,i):f<10?a.formatDistance("lessThanXSeconds",10,i):f<20?a.formatDistance("lessThanXSeconds",20,i):f<40?a.formatDistance("halfAMinute",0,i):f<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):v===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",v,i);if(v<45)return a.formatDistance("xMinutes",v,i);if(v<90)return a.formatDistance("aboutXHours",1,i);if(vn.getTime()}function SN(t,s){const r=Kn(t),n=Kn(s);return+r<+n}function Dvt(t){return+Kn(t)>Date.now()}function Ovt(t,s){const r=s instanceof Date?Zo(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 Rvt=10;class p9e{constructor(){_n(this,"subPriority",0)}validate(s,r){return!0}}class Fvt extends p9e{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 zvt extends p9e{constructor(){super(...arguments);_n(this,"priority",Rvt);_n(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Zo(r,Ovt(r,Date))}}class Fo{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new Fvt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class Bvt extends Fo{constructor(){super(...arguments);_n(this,"priority",140);_n(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 sd={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}/},Ax={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 rd(t,s){return t&&{value:s(t.value),rest:t.rest}}function wc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function Ex(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*cL+o*goe+l*k0t),rest:s.slice(r[0].length)}}function f9e(t){return wc(sd.anyDigitsSigned,t)}function Wc(t,s){switch(t){case 1:return wc(sd.singleDigit,s);case 2:return wc(sd.twoDigits,s);case 3:return wc(sd.threeDigits,s);case 4:return wc(sd.fourDigits,s);default:return wc(new RegExp("^\\d{1,"+t+"}"),s)}}function ene(t,s){switch(t){case 1:return wc(sd.singleDigitSigned,s);case 2:return wc(sd.twoDigitsSigned,s);case 3:return wc(sd.threeDigitsSigned,s);case 4:return wc(sd.fourDigitsSigned,s);default:return wc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function $1e(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 g9e(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 x9e(t){return t%400===0||t%4===0&&t%100!==0}class $vt extends Fo{constructor(){super(...arguments);_n(this,"priority",130);_n(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 rd(Wc(4,r),o);case"yo":return rd(a.ordinalNumber(r,{unit:"year"}),o);default:return rd(Wc(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=g9e(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 qvt extends Fo{constructor(){super(...arguments);_n(this,"priority",130);_n(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 rd(Wc(4,r),o);case"Yo":return rd(a.ordinalNumber(r,{unit:"year"}),o);default:return rd(Wc(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=z1e(r,o);if(a.isTwoDigitYear){const d=g9e(a.year,l);return r.setFullYear(d,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Ju(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),Ju(r,o)}}class Uvt extends Fo{constructor(){super(...arguments);_n(this,"priority",130);_n(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return ene(n==="R"?4:n.length,r)}set(r,n,a){const o=Zo(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),z0(o)}}class Vvt extends Fo{constructor(){super(...arguments);_n(this,"priority",130);_n(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return ene(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class Hvt extends Fo{constructor(){super(...arguments);_n(this,"priority",120);_n(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 Wc(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 Wvt extends Fo{constructor(){super(...arguments);_n(this,"priority",120);_n(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 Wc(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 Gvt extends Fo{constructor(){super(...arguments);_n(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);_n(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return rd(wc(sd.month,r),o);case"MM":return rd(Wc(2,r),o);case"Mo":return rd(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 Kvt extends Fo{constructor(){super(...arguments);_n(this,"priority",110);_n(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 rd(wc(sd.month,r),o);case"LL":return rd(Wc(2,r),o);case"Lo":return rd(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 Zvt(t,s,r){const n=Kn(t),a=B1e(n,r)-s;return n.setDate(n.getDate()-a*7),n}class Yvt extends Fo{constructor(){super(...arguments);_n(this,"priority",100);_n(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return wc(sd.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Wc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return Ju(Zvt(r,a,o),o)}}function Xvt(t,s){const r=Kn(t),n=F1e(r)-s;return r.setDate(r.getDate()-n*7),r}class Qvt extends Fo{constructor(){super(...arguments);_n(this,"priority",100);_n(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 wc(sd.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Wc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return z0(Xvt(r,a))}}const Jvt=[31,28,31,30,31,30,31,31,30,31,30,31],e1t=[31,29,31,30,31,30,31,31,30,31,30,31];class t1t extends Fo{constructor(){super(...arguments);_n(this,"priority",90);_n(this,"subPriority",1);_n(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return wc(sd.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Wc(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=x9e(a),l=r.getMonth();return o?n>=1&&n<=e1t[l]:n>=1&&n<=Jvt[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class s1t extends Fo{constructor(){super(...arguments);_n(this,"priority",90);_n(this,"subpriority",1);_n(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 wc(sd.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Wc(n.length,r)}}validate(r,n){const a=r.getFullYear();return x9e(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 q1e(t,s,r){var g,v,_,b;const n=D_(),a=(r==null?void 0:r.weekStartsOn)??((v=(g=r==null?void 0:r.locale)==null?void 0:g.options)==null?void 0:v.weekStartsOn)??n.weekStartsOn??((b=(_=n.locale)==null?void 0:_.options)==null?void 0:b.weekStartsOn)??0,o=Kn(t),l=o.getDay(),d=(s%7+7)%7,u=7-a,f=s<0||s>6?s-(l+u)%7:(d+u)%7-(l+u)%7;return hl(o,f)}class r1t extends Fo{constructor(){super(...arguments);_n(this,"priority",90);_n(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=q1e(r,a,o),r.setHours(0,0,0,0),r}}class n1t extends Fo{constructor(){super(...arguments);_n(this,"priority",90);_n(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 d=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+d};switch(n){case"e":case"ee":return rd(Wc(n.length,r),l);case"eo":return rd(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=q1e(r,a,o),r.setHours(0,0,0,0),r}}class a1t extends Fo{constructor(){super(...arguments);_n(this,"priority",90);_n(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 d=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+d};switch(n){case"c":case"cc":return rd(Wc(n.length,r),l);case"co":return rd(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=q1e(r,a,o),r.setHours(0,0,0,0),r}}function i1t(t,s){const r=Kn(t),n=Evt(r),a=s-n;return hl(r,a)}class o1t extends Fo{constructor(){super(...arguments);_n(this,"priority",90);_n(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 Wc(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return rd(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 rd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return rd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return rd(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=i1t(r,a),r.setHours(0,0,0,0),r}}class l1t extends Fo{constructor(){super(...arguments);_n(this,"priority",80);_n(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($1e(a),0,0,0),r}}class c1t extends Fo{constructor(){super(...arguments);_n(this,"priority",80);_n(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($1e(a),0,0,0),r}}class d1t extends Fo{constructor(){super(...arguments);_n(this,"priority",80);_n(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($1e(a),0,0,0),r}}class u1t extends Fo{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return wc(sd.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Wc(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 h1t extends Fo{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return wc(sd.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Wc(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class m1t extends Fo{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return wc(sd.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Wc(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 p1t extends Fo{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return wc(sd.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Wc(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 f1t extends Fo{constructor(){super(...arguments);_n(this,"priority",60);_n(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return wc(sd.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Wc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class g1t extends Fo{constructor(){super(...arguments);_n(this,"priority",50);_n(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return wc(sd.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Wc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class x1t extends Fo{constructor(){super(...arguments);_n(this,"priority",30);_n(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return rd(Wc(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class y1t extends Fo{constructor(){super(...arguments);_n(this,"priority",10);_n(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return Ex(Ax.basicOptionalMinutes,r);case"XX":return Ex(Ax.basic,r);case"XXXX":return Ex(Ax.basicOptionalSeconds,r);case"XXXXX":return Ex(Ax.extendedOptionalSeconds,r);case"XXX":default:return Ex(Ax.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Zo(r,r.getTime()-x_(r)-a)}}class v1t extends Fo{constructor(){super(...arguments);_n(this,"priority",10);_n(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return Ex(Ax.basicOptionalMinutes,r);case"xx":return Ex(Ax.basic,r);case"xxxx":return Ex(Ax.basicOptionalSeconds,r);case"xxxxx":return Ex(Ax.extendedOptionalSeconds,r);case"xxx":default:return Ex(Ax.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Zo(r,r.getTime()-x_(r)-a)}}class _1t extends Fo{constructor(){super(...arguments);_n(this,"priority",40);_n(this,"incompatibleTokens","*")}parse(r){return f9e(r)}set(r,n,a){return[Zo(r,a*1e3),{timestampIsSet:!0}]}}class b1t extends Fo{constructor(){super(...arguments);_n(this,"priority",20);_n(this,"incompatibleTokens","*")}parse(r){return f9e(r)}set(r,n,a){return[Zo(r,a),{timestampIsSet:!0}]}}const w1t={G:new Bvt,y:new $vt,Y:new qvt,R:new Uvt,u:new Vvt,Q:new Hvt,q:new Wvt,M:new Gvt,L:new Kvt,w:new Yvt,I:new Qvt,d:new t1t,D:new s1t,E:new r1t,e:new n1t,c:new a1t,i:new o1t,a:new l1t,b:new c1t,B:new d1t,h:new u1t,H:new h1t,K:new m1t,k:new p1t,m:new f1t,s:new g1t,S:new x1t,X:new y1t,x:new v1t,t:new _1t,T:new b1t},j1t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,k1t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,N1t=/^'([^]*?)'?$/,S1t=/''/g,C1t=/\S/,M1t=/[a-zA-Z]/;function U1e(t,s,r,n){var w,j,N,S;const a=Avt(),o=a.locale??yoe,l=a.firstWeekContainsDate??((j=(w=a.locale)==null?void 0:w.options)==null?void 0:j.firstWeekContainsDate)??1,i=a.weekStartsOn??((S=(N=a.locale)==null?void 0:N.options)==null?void 0:S.weekStartsOn)??0;if(s==="")return t===""?Kn(r):Zo(r,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new zvt],f=s.match(k1t).map(A=>{const I=A[0];if(I in _ge){const L=_ge[I];return L(A,o.formatLong)}return A}).join("").match(j1t),g=[];for(let A of f){m9e(A)&&bge(A,s,t),h9e(A)&&bge(A,s,t);const I=A[0],L=w1t[I];if(L){const{incompatibleTokens:F}=L;if(Array.isArray(F)){const q=g.find(H=>F.includes(H.token)||H.token===I);if(q)throw new RangeError(`The format string mustn't contain \`${q.fullToken}\` and \`${A}\` at the same time`)}else if(L.incompatibleTokens==="*"&&g.length>0)throw new RangeError(`The format string mustn't contain \`${A}\` and any other token at the same time`);g.push({token:I,fullToken:A});const $=L.run(t,A,o.match,d);if(!$)return Zo(r,NaN);u.push($.setter),t=$.rest}else{if(I.match(M1t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(A==="''"?A="'":I==="'"&&(A=T1t(A)),t.indexOf(A)===0)t=t.slice(A.length);else return Zo(r,NaN)}}if(t.length>0&&C1t.test(t))return Zo(r,NaN);const v=u.map(A=>A.priority).sort((A,I)=>I-A).filter((A,I,L)=>L.indexOf(A)===I).map(A=>u.filter(I=>I.priority===A).sort((I,L)=>L.subPriority-I.subPriority)).map(A=>A[0]);let _=Kn(r);if(isNaN(_.getTime()))return Zo(r,NaN);const b={};for(const A of v){if(!A.validate(_,d))return Zo(r,NaN);const I=A.set(_,b,d);Array.isArray(I)?(_=I[0],Object.assign(b,I[1])):_=I}return Zo(r,_)}function T1t(t){return t.match(N1t)[1].replace(S1t,"'")}function Wx(t){return+Kn(t)o-l);return r>=n&&r<=a}function Wse(t,s){return hl(t,-s)}function kh(t,s){const n=O1t(t);let a;if(n.date){const d=R1t(n.date,2);a=F1t(d.restDateString,d.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const o=a.getTime();let l=0,i;if(n.time&&(l=z1t(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=B1t(n.timezone),isNaN(i))return new Date(NaN)}else{const d=new Date(o+l),u=new Date(0);return u.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),u.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),u}return new Date(o+l+i)}const b8={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},I1t=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,L1t=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,D1t=/^([+-])(\d{2})(?::?(\d{2}))?$/;function O1t(t){const s={},r=t.split(b8.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],b8.timeZoneDelimiter.test(s.date)&&(s.date=t.split(b8.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=b8.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function R1t(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 F1t(t,s){if(s===null)return new Date(NaN);const r=t.match(I1t);if(!r)return new Date(NaN);const n=!!r[4],a=zA(r[1]),o=zA(r[2])-1,l=zA(r[3]),i=zA(r[4]),d=zA(r[5])-1;if(n)return H1t(s,i,d)?$1t(s,i,d):new Date(NaN);{const u=new Date(0);return!U1t(s,o,l)||!V1t(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function zA(t){return t?parseInt(t):1}function z1t(t){const s=t.match(L1t);if(!s)return NaN;const r=khe(s[1]),n=khe(s[2]),a=khe(s[3]);return W1t(r,n,a)?r*cL+n*goe+a*1e3:NaN}function khe(t){return t&&parseFloat(t.replace(",","."))||0}function B1t(t){if(t==="Z")return 0;const s=t.match(D1t);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return G1t(n,a)?r*(n*cL+a*goe):NaN}function $1t(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 q1t=[31,null,31,30,31,30,31,31,30,31,30,31];function y9e(t){return t%400===0||t%4===0&&t%100!==0}function U1t(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(q1t[s]||(y9e(t)?29:28))}function V1t(t,s){return s>=1&&s<=(y9e(t)?366:365)}function H1t(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function W1t(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function G1t(t,s){return s>=0&&s<=59}function Nhe(t,s){const r=Kn(t),n=r.getFullYear(),a=r.getDate(),o=Zo(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=Tvt(o);return r.setMonth(s,Math.min(a,l)),r}function MP(t,s){const r=Kn(t);return r.setHours(s),r}function TP(t,s){const r=Kn(t);return r.setMinutes(s),r}function j5e(t,s){const r=Kn(t);return isNaN(+r)?Zo(t,NaN):(r.setFullYear(s),r)}function v9e(t,s){return $h(t,-s)}var Eo;(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})(Eo||(Eo={}));var k5e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(k5e||(k5e={}));const sa=Eo.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Qv=t=>{switch(typeof t){case"undefined":return sa.undefined;case"string":return sa.string;case"number":return Number.isNaN(t)?sa.nan:sa.number;case"boolean":return sa.boolean;case"function":return sa.function;case"bigint":return sa.bigint;case"symbol":return sa.symbol;case"object":return Array.isArray(t)?sa.array:t===null?sa.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?sa.promise:typeof Map<"u"&&t instanceof Map?sa.map:typeof Set<"u"&&t instanceof Set?sa.set:typeof Date<"u"&&t instanceof Date?sa.date:sa.object;default:return sa.unknown}},tn=Eo.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 Qx 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,d=0;for(;dr.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()}}Qx.create=t=>new Qx(t);const wge=(t,s)=>{let r;switch(t.code){case tn.invalid_type:t.received===sa.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case tn.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Eo.jsonStringifyReplacer)}`;break;case tn.unrecognized_keys:r=`Unrecognized key(s) in object: ${Eo.joinValues(t.keys,", ")}`;break;case tn.invalid_union:r="Invalid input";break;case tn.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Eo.joinValues(t.options)}`;break;case tn.invalid_enum_value:r=`Invalid enum value. Expected ${Eo.joinValues(t.options)}, received '${t.received}'`;break;case tn.invalid_arguments:r="Invalid function arguments";break;case tn.invalid_return_type:r="Invalid function return type";break;case tn.invalid_date:r="Invalid date";break;case tn.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}"`:Eo.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case tn.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 tn.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 tn.custom:r="Invalid input";break;case tn.invalid_intersection_types:r="Intersection results could not be merged";break;case tn.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case tn.not_finite:r="Number must be finite";break;default:r=s.defaultError,Eo.assertNever(t)}return{message:r}};let K1t=wge;function Z1t(){return K1t}const Y1t=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 d=n.filter(u=>!!u).slice().reverse();for(const u of d)i=u(l,{data:s,defaultError:i}).message;return{...a,path:o,message:i}};function $n(t,s){const r=Z1t(),n=Y1t({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===wge?void 0:wge].filter(a=>!!a)});t.common.issues.push(n)}class bp{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 ji;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 bp.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 ji;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 ji=Object.freeze({status:"aborted"}),xE=t=>({status:"dirty",value:t}),wf=t=>({status:"valid",value:t}),N5e=t=>t.status==="aborted",S5e=t=>t.status==="dirty",n3=t=>t.status==="valid",sne=t=>typeof Promise<"u"&&t instanceof Promise;var ha;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(ha||(ha={}));class y_{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 C5e=(t,s)=>{if(n3(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 Qx(t.common.issues);return this._error=r,this._error}}};function Wi(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:d}=t;return l.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??n??i.defaultError}:l.code!=="invalid_type"?{message:i.defaultError}:{message:d??r??i.defaultError}},description:a}}class Co{get description(){return this._def.description}_getType(s){return Qv(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:Qv(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new bp,ctx:{common:s.parent.common,data:s.data,parsedType:Qv(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(sne(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:Qv(s)},a=this._parseSync({data:s,path:n.path,parent:n});return C5e(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:Qv(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return n3(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=>n3(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:Qv(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(sne(a)?a:Promise.resolve(a));return C5e(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:tn.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(d=>d?!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 o3({schema:this,typeName:ki.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 s_.create(this,this._def)}nullable(){return l3.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Gx.create(this)}promise(){return ine.create(this,this._def)}or(s){return nne.create([this,s],this._def)}and(s){return ane.create(this,s,this._def)}transform(s){return new o3({...Wi(this._def),schema:this,typeName:ki.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Sge({...Wi(this._def),innerType:this,defaultValue:r,typeName:ki.ZodDefault})}brand(){return new v_t({typeName:ki.ZodBranded,type:this,...Wi(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Cge({...Wi(this._def),innerType:this,catchValue:r,typeName:ki.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return V1e.create(this,s)}readonly(){return Mge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const X1t=/^c[^\s-]{8,}$/i,Q1t=/^[0-9a-z]+$/,J1t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,e_t=/^[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,t_t=/^[a-z0-9_-]{21}$/i,s_t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,r_t=/^[-+]?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)?)??$/,n_t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,a_t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let She;const i_t=/^(?:(?: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])$/,o_t=/^(?:(?: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])$/,l_t=/^(([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]))$/,c_t=/^(([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])$/,d_t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,u_t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,_9e="((\\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])))",h_t=new RegExp(`^${_9e}$`);function b9e(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 m_t(t){return new RegExp(`^${b9e(t)}$`)}function p_t(t){let s=`${_9e}T${b9e(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 f_t(t,s){return!!((s==="v4"||!s)&&i_t.test(t)||(s==="v6"||!s)&&l_t.test(t))}function g_t(t,s){if(!s_t.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 x_t(t,s){return!!((s==="v4"||!s)&&o_t.test(t)||(s==="v6"||!s)&&c_t.test(t))}class M1 extends Co{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==sa.string){const o=this._getOrReturnCtx(s);return $n(o,{code:tn.invalid_type,expected:sa.string,received:o.parsedType}),ji}const n=new bp;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),$n(a,{code:tn.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:tn.invalid_string,...ha.errToObj(n)})}_addCheck(s){return new M1({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...ha.errToObj(s)})}url(s){return this._addCheck({kind:"url",...ha.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...ha.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...ha.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...ha.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...ha.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...ha.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...ha.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...ha.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...ha.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...ha.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...ha.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...ha.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,...ha.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,...ha.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...ha.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...ha.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...ha.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...ha.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...ha.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...ha.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...ha.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...ha.errToObj(r)})}nonempty(s){return this.min(1,ha.errToObj(s))}trim(){return new M1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new M1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new M1({...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 M1({checks:[],typeName:ki.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Wi(t)});function y_t(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 a3 extends Co{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)!==sa.number){const o=this._getOrReturnCtx(s);return $n(o,{code:tn.invalid_type,expected:sa.number,received:o.parsedType}),ji}let n;const a=new bp;for(const o of this._def.checks)o.kind==="int"?Eo.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),$n(n,{code:tn.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),$n(n,{code:tn.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?y_t(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),$n(n,{code:tn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),$n(n,{code:tn.not_finite,message:o.message}),a.dirty()):Eo.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,ha.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ha.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ha.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ha.toString(r))}setLimit(s,r,n,a){return new a3({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ha.toString(a)}]})}_addCheck(s){return new a3({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:ha.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ha.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ha.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ha.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ha.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ha.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:ha.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ha.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ha.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"&&Eo.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 a3({checks:[],typeName:ki.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Wi(t)});class II extends Co{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)!==sa.bigint)return this._getInvalidInput(s);let n;const a=new bp;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),$n(n,{code:tn.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),$n(n,{code:tn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Eo.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return $n(r,{code:tn.invalid_type,expected:sa.bigint,received:r.parsedType}),ji}gte(s,r){return this.setLimit("min",s,!0,ha.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ha.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ha.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ha.toString(r))}setLimit(s,r,n,a){return new II({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ha.toString(a)}]})}_addCheck(s){return new II({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ha.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ha.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ha.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ha.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ha.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 II({checks:[],typeName:ki.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Wi(t)});class jge extends Co{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==sa.boolean){const n=this._getOrReturnCtx(s);return $n(n,{code:tn.invalid_type,expected:sa.boolean,received:n.parsedType}),ji}return wf(s.data)}}jge.create=t=>new jge({typeName:ki.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Wi(t)});class rne extends Co{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==sa.date){const o=this._getOrReturnCtx(s);return $n(o,{code:tn.invalid_type,expected:sa.date,received:o.parsedType}),ji}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return $n(o,{code:tn.invalid_date}),ji}const n=new bp;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),$n(a,{code:tn.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Eo.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new rne({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:ha.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:ha.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 rne({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:ki.ZodDate,...Wi(t)});class M5e extends Co{_parse(s){if(this._getType(s)!==sa.symbol){const n=this._getOrReturnCtx(s);return $n(n,{code:tn.invalid_type,expected:sa.symbol,received:n.parsedType}),ji}return wf(s.data)}}M5e.create=t=>new M5e({typeName:ki.ZodSymbol,...Wi(t)});class T5e extends Co{_parse(s){if(this._getType(s)!==sa.undefined){const n=this._getOrReturnCtx(s);return $n(n,{code:tn.invalid_type,expected:sa.undefined,received:n.parsedType}),ji}return wf(s.data)}}T5e.create=t=>new T5e({typeName:ki.ZodUndefined,...Wi(t)});class A5e extends Co{_parse(s){if(this._getType(s)!==sa.null){const n=this._getOrReturnCtx(s);return $n(n,{code:tn.invalid_type,expected:sa.null,received:n.parsedType}),ji}return wf(s.data)}}A5e.create=t=>new A5e({typeName:ki.ZodNull,...Wi(t)});class E5e extends Co{constructor(){super(...arguments),this._any=!0}_parse(s){return wf(s.data)}}E5e.create=t=>new E5e({typeName:ki.ZodAny,...Wi(t)});class P5e extends Co{constructor(){super(...arguments),this._unknown=!0}_parse(s){return wf(s.data)}}P5e.create=t=>new P5e({typeName:ki.ZodUnknown,...Wi(t)});class v_ extends Co{_parse(s){const r=this._getOrReturnCtx(s);return $n(r,{code:tn.invalid_type,expected:sa.never,received:r.parsedType}),ji}}v_.create=t=>new v_({typeName:ki.ZodNever,...Wi(t)});class I5e extends Co{_parse(s){if(this._getType(s)!==sa.undefined){const n=this._getOrReturnCtx(s);return $n(n,{code:tn.invalid_type,expected:sa.void,received:n.parsedType}),ji}return wf(s.data)}}I5e.create=t=>new I5e({typeName:ki.ZodVoid,...Wi(t)});class Gx extends Co{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==sa.array)return $n(r,{code:tn.invalid_type,expected:sa.array,received:r.parsedType}),ji;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&($n(r,{code:tn.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 y_(r,l,r.path,i)))).then(l=>bp.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new y_(r,l,r.path,i)));return bp.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new Gx({...this._def,minLength:{value:s,message:ha.toString(r)}})}max(s,r){return new Gx({...this._def,maxLength:{value:s,message:ha.toString(r)}})}length(s,r){return new Gx({...this._def,exactLength:{value:s,message:ha.toString(r)}})}nonempty(s){return this.min(1,s)}}Gx.create=(t,s)=>new Gx({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ki.ZodArray,...Wi(s)});function l4(t){if(t instanceof xd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=s_.create(l4(n))}return new xd({...t._def,shape:()=>s})}else return t instanceof Gx?new Gx({...t._def,type:l4(t.element)}):t instanceof s_?s_.create(l4(t.unwrap())):t instanceof l3?l3.create(l4(t.unwrap())):t instanceof CN?CN.create(t.items.map(s=>l4(s))):t}class xd extends Co{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=Eo.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==sa.object){const u=this._getOrReturnCtx(s);return $n(u,{code:tn.invalid_type,expected:sa.object,received:u.parsedType}),ji}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof v_&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const d=[];for(const u of l){const f=o[u],g=a.data[u];d.push({key:{status:"valid",value:u},value:f._parse(new y_(a,g,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof v_){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of i)d.push({key:{status:"valid",value:f},value:{status:"valid",value:a.data[f]}});else if(u==="strict")i.length>0&&($n(a,{code:tn.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 f of i){const g=a.data[f];d.push({key:{status:"valid",value:f},value:u._parse(new y_(a,g,a.path,f)),alwaysSet:f in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of d){const g=await f.key,v=await f.value;u.push({key:g,value:v,alwaysSet:f.alwaysSet})}return u}).then(u=>bp.mergeObjectSync(n,u)):bp.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(s){return ha.errToObj,new xd({...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:ha.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new xd({...this._def,unknownKeys:"strip"})}passthrough(){return new xd({...this._def,unknownKeys:"passthrough"})}extend(s){return new xd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new xd({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:ki.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new xd({...this._def,catchall:s})}pick(s){const r={};for(const n of Eo.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new xd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of Eo.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new xd({...this._def,shape:()=>r})}deepPartial(){return l4(this)}partial(s){const r={};for(const n of Eo.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new xd({...this._def,shape:()=>r})}required(s){const r={};for(const n of Eo.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof s_;)o=o._def.innerType;r[n]=o}return new xd({...this._def,shape:()=>r})}keyof(){return w9e(Eo.objectKeys(this.shape))}}xd.create=(t,s)=>new xd({shape:()=>t,unknownKeys:"strip",catchall:v_.create(),typeName:ki.ZodObject,...Wi(s)});xd.strictCreate=(t,s)=>new xd({shape:()=>t,unknownKeys:"strict",catchall:v_.create(),typeName:ki.ZodObject,...Wi(s)});xd.lazycreate=(t,s)=>new xd({shape:t,unknownKeys:"strip",catchall:v_.create(),typeName:ki.ZodObject,...Wi(s)});class nne extends Co{_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 Qx(i.ctx.common.issues));return $n(r,{code:tn.invalid_union,unionErrors:l}),ji}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 d of n){const u={...r,common:{...r.common,issues:[]},parent:null},f=d._parseSync({data:r.data,path:r.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!o&&(o={result:f,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(d=>new Qx(d));return $n(r,{code:tn.invalid_union,unionErrors:i}),ji}}get options(){return this._def.options}}nne.create=(t,s)=>new nne({options:t,typeName:ki.ZodUnion,...Wi(s)});function kge(t,s){const r=Qv(t),n=Qv(s);if(t===s)return{valid:!0,data:t};if(r===sa.object&&n===sa.object){const a=Eo.objectKeys(s),o=Eo.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const d=kge(t[i],s[i]);if(!d.valid)return{valid:!1};l[i]=d.data}return{valid:!0,data:l}}else if(r===sa.array&&n===sa.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(N5e(o)||N5e(l))return ji;const i=kge(o.value,l.value);return i.valid?((S5e(o)||S5e(l))&&r.dirty(),{status:r.value,value:i.data}):($n(n,{code:tn.invalid_intersection_types}),ji)};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}))}}ane.create=(t,s,r)=>new ane({left:t,right:s,typeName:ki.ZodIntersection,...Wi(r)});class CN extends Co{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==sa.array)return $n(n,{code:tn.invalid_type,expected:sa.array,received:n.parsedType}),ji;if(n.data.lengththis._def.items.length&&($n(n,{code:tn.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((l,i)=>{const d=this._def.items[i]||this._def.rest;return d?d._parse(new y_(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>bp.mergeArray(r,l)):bp.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new CN({...this._def,rest:s})}}CN.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new CN({items:t,typeName:ki.ZodTuple,rest:null,...Wi(s)})};class L5e extends Co{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!==sa.map)return $n(n,{code:tn.invalid_type,expected:sa.map,received:n.parsedType}),ji;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],u)=>({key:a._parse(new y_(n,i,n.path,[u,"key"])),value:o._parse(new y_(n,d,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of l){const u=await d.key,f=await d.value;if(u.status==="aborted"||f.status==="aborted")return ji;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),i.set(u.value,f.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const d of l){const u=d.key,f=d.value;if(u.status==="aborted"||f.status==="aborted")return ji;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),i.set(u.value,f.value)}return{status:r.value,value:i}}}}L5e.create=(t,s,r)=>new L5e({valueType:s,keyType:t,typeName:ki.ZodMap,...Wi(r)});class LI extends Co{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==sa.set)return $n(n,{code:tn.invalid_type,expected:sa.set,received:n.parsedType}),ji;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&($n(n,{code:tn.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(d){const u=new Set;for(const f of d){if(f.status==="aborted")return ji;f.status==="dirty"&&r.dirty(),u.add(f.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((d,u)=>o._parse(new y_(n,d,n.path,u)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(s,r){return new LI({...this._def,minSize:{value:s,message:ha.toString(r)}})}max(s,r){return new LI({...this._def,maxSize:{value:s,message:ha.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}LI.create=(t,s)=>new LI({valueType:t,minSize:null,maxSize:null,typeName:ki.ZodSet,...Wi(s)});class D5e extends Co{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})}}D5e.create=(t,s)=>new D5e({getter:t,typeName:ki.ZodLazy,...Wi(s)});class Nge extends Co{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return $n(r,{received:r.data,code:tn.invalid_literal,expected:this._def.value}),ji}return{status:"valid",value:s.data}}get value(){return this._def.value}}Nge.create=(t,s)=>new Nge({value:t,typeName:ki.ZodLiteral,...Wi(s)});function w9e(t,s){return new i3({values:t,typeName:ki.ZodEnum,...Wi(s)})}class i3 extends Co{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return $n(r,{expected:Eo.joinValues(n),received:r.parsedType,code:tn.invalid_type}),ji}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 $n(r,{received:r.data,code:tn.invalid_enum_value,options:n}),ji}return wf(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 i3.create(s,{...this._def,...r})}exclude(s,r=this._def){return i3.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}i3.create=w9e;class O5e extends Co{_parse(s){const r=Eo.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==sa.string&&n.parsedType!==sa.number){const a=Eo.objectValues(r);return $n(n,{expected:Eo.joinValues(a),received:n.parsedType,code:tn.invalid_type}),ji}if(this._cache||(this._cache=new Set(Eo.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Eo.objectValues(r);return $n(n,{received:n.data,code:tn.invalid_enum_value,options:a}),ji}return wf(s.data)}get enum(){return this._def.values}}O5e.create=(t,s)=>new O5e({values:t,typeName:ki.ZodNativeEnum,...Wi(s)});class ine extends Co{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==sa.promise&&r.common.async===!1)return $n(r,{code:tn.invalid_type,expected:sa.promise,received:r.parsedType}),ji;const n=r.parsedType===sa.promise?r.data:Promise.resolve(r.data);return wf(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}ine.create=(t,s)=>new ine({type:t,typeName:ki.ZodPromise,...Wi(s)});class o3 extends Co{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ki.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=>{$n(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 ji;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?ji:d.status==="dirty"||r.value==="dirty"?xE(d.value):d});{if(r.value==="aborted")return ji;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?ji:i.status==="dirty"||r.value==="dirty"?xE(i.value):i}}if(a.type==="refinement"){const l=i=>{const d=a.refinement(i,o);if(n.common.async)return Promise.resolve(d);if(d 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"?ji:(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"?ji:(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(!n3(l))return ji;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=>n3(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):ji);Eo.assertNever(a)}}o3.create=(t,s,r)=>new o3({schema:t,typeName:ki.ZodEffects,effect:s,...Wi(r)});o3.createWithPreprocess=(t,s,r)=>new o3({schema:s,effect:{type:"preprocess",transform:t},typeName:ki.ZodEffects,...Wi(r)});class s_ extends Co{_parse(s){return this._getType(s)===sa.undefined?wf(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}s_.create=(t,s)=>new s_({innerType:t,typeName:ki.ZodOptional,...Wi(s)});class l3 extends Co{_parse(s){return this._getType(s)===sa.null?wf(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}l3.create=(t,s)=>new l3({innerType:t,typeName:ki.ZodNullable,...Wi(s)});class Sge extends Co{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===sa.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Sge.create=(t,s)=>new Sge({innerType:t,typeName:ki.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Wi(s)});class Cge extends Co{_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 sne(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Qx(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Qx(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Cge.create=(t,s)=>new Cge({innerType:t,typeName:ki.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Wi(s)});class R5e extends Co{_parse(s){if(this._getType(s)!==sa.nan){const n=this._getOrReturnCtx(s);return $n(n,{code:tn.invalid_type,expected:sa.nan,received:n.parsedType}),ji}return{status:"valid",value:s.data}}}R5e.create=t=>new R5e({typeName:ki.ZodNaN,...Wi(t)});class v_t extends Co{_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 V1e extends Co{_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"?ji:o.status==="dirty"?(r.dirty(),xE(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"?ji: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 V1e({in:s,out:r,typeName:ki.ZodPipeline})}}class Mge extends Co{_parse(s){const r=this._def.innerType._parse(s),n=a=>(n3(a)&&(a.value=Object.freeze(a.value)),a);return sne(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Mge.create=(t,s)=>new Mge({innerType:t,typeName:ki.ZodReadonly,...Wi(s)});var ki;(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"})(ki||(ki={}));const Ko=M1.create,AP=a3.create,__t=jge.create;v_.create;Gx.create;const O_=xd.create;nne.create;ane.create;CN.create;const c3=Nge.create,j9e=i3.create;ine.create;s_.create;l3.create;function b_t(){const s=sh().pathname.slice(1);return M.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),!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(w_t,{slug:s})}function w_t({slug:t}){return e.jsx(N_t,{slug:t})}const j_t=O_({first_name:Ko().trim().min(1,"First name is required").max(50),last_name:Ko().trim().max(50).optional(),email:Ko().trim().email("Please enter a valid email").max(255).optional().or(c3("")),phone:Ko().trim().max(20).optional().or(c3(""))}),k_t=[{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 N_t({slug:t}){var $;const{data:s,isLoading:r,error:n}=XBe(t),a=QBe(),[o,l]=M.useState("welcome"),[i,d]=M.useState({first_name:"",last_name:"",email:"",phone:""}),[u,f]=M.useState(!1),[g,v]=M.useState(!1),[_,b]=M.useState(""),[w,j]=M.useState(""),N=q=>{if(!q)return"";const[H,U]=q.split(":"),Q=parseInt(H),se=Q>=12?"PM":"AM";return`${Q>12?Q-12:Q||12}:${U} ${se}`},S=()=>{j("");const q=j_t.safeParse(i);if(!q.success){j(q.error.issues[0].message);return}if(!i.email&&!i.phone){j("Please provide either an email or phone number");return}l("intent")},A=async q=>{try{await a.mutateAsync({open_house_id:s.id,first_name:i.first_name.trim(),last_name:i.last_name.trim()||void 0,email:i.email.trim()||void 0,phone:i.phone.trim()||void 0,visitor_intent:q,wants_market_updates:u,has_agent:g,working_with_agent_name:g&&_.trim()?_.trim():void 0}),l("done")}catch{j("Something went wrong. Please try again.")}};if(r)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(n||!s)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(Hn,{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 I=s.profiles,L=(($=I==null?void 0:I.name)==null?void 0:$.split(" ").map(q=>q[0]).join("").slice(0,2))||"?",F=s.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(Gh,{children:[e.jsxs("title",{children:[F?"Community Event":"Open House"," | ",s.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(mn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(ba,{src:(I==null?void 0:I.avatar_url)||"",alt:(I==null?void 0:I.name)||""}),e.jsx(pn,{className:"bg-white/10 text-white text-lg",children:L})]}),e.jsx("p",{className:"text-white/60 text-sm",children:I==null?void 0:I.name}),(I==null?void 0:I.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:I.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[s.photo_url&&e.jsxs("div",{className:"relative w-full h-48 overflow-hidden",children:[e.jsx("img",{src:s.photo_url,alt:s.property_address,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/60 to-transparent"})]}),e.jsx("div",{className:`${s.photo_url?"px-6 py-4":"px-6 py-5"} bg-gradient-to-r from-slate-800 to-slate-700`,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:F?e.jsx(_a,{className:"h-5 w-5 text-white"}):e.jsx(Hn,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:s.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[s.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pi,{className:"h-3 w-3"}),s.city,s.state?`, ${s.state}`:""," ",s.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),js(new Date(s.event_date+"T00:00:00"),"MMM d, yyyy")]}),s.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),N(s.start_time),s.end_time?` – ${N(s.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[o==="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:s.agent_greeting||"Please sign in below."})]}),e.jsxs(Z,{onClick:()=>l("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(Ai,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),o==="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:()=>l("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ba,{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(_e,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Re,{value:i.first_name,onChange:q=>d(H=>({...H,first_name:q.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Re,{value:i.last_name,onChange:q=>d(H=>({...H,last_name:q.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Re,{type:"email",value:i.email,onChange:q=>d(H=>({...H,email:q.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Re,{type:"tel",value:i.phone,onChange:q=>d(H=>({...H,phone:q.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:u,onChange:q=>f(q.target.checked),className:"rounded border-slate-300"}),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:g?"Yes":"No"}),e.jsx(qr,{checked:g,onCheckedChange:v})]})]}),g&&e.jsx(Re,{value:_,onChange:q=>b(q.target.value),placeholder:"Agent's name",className:"h-10 rounded-xl border-slate-200 text-sm"})]}),w&&e.jsx("p",{className:"text-red-500 text-sm",children:w}),e.jsxs(Z,{onClick:S,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Ai,{className:"h-5 w-5 ml-2"})]})]}),o==="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:()=>l("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ba,{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:k_t.map(q=>e.jsxs("button",{onClick:()=>A(q.value),disabled:a.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:q.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:q.label})]},q.value))}),w&&e.jsx("p",{className:"text-red-500 text-sm text-center",children:w})]}),o==="done"&&e.jsx(S_t,{firstName:i.first_name,agentName:I==null?void 0:I.name,agentCardSlug:s.auto_forward_to_card?s.agent_card_slug:null,disclosurePdfUrl:s.auto_forward_to_card?null:s.disclosure_pdf_url,isCommunity:F})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function S_t({firstName:t,agentName:s,agentCardSlug:r,disclosurePdfUrl:n,isCommunity:a}){const[o,l]=M.useState(5),[i,d]=M.useState(!1);return M.useEffect(()=>{if(!r||i)return;const u=setInterval(()=>{l(f=>f<=1?(clearInterval(u),window.location.href=`https://cards.relevelup.com/${r}`,0):f-1)},1e3);return()=>clearInterval(u)},[r,i]),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(Ma,{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, ",t,". ",a?"Enjoy the event!":"Enjoy the open house!"]})]}),s&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:s})]}),r&&!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-400 animate-pulse",children:["Redirecting to ",s?`${s}'s`:"your agent's"," card in ",o,"s…"]}),e.jsx("button",{onClick:()=>d(!0),className:"text-xs text-slate-500 underline hover:text-slate-700",children:"Stay on this page"})]}),n&&e.jsxs("div",{className:"pt-2 space-y-2",children:[e.jsx("p",{className:"text-sm text-slate-600 font-medium",children:"Seller's Disclosures"}),e.jsxs("div",{className:"flex gap-2 justify-center",children:[e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-700 text-sm font-medium transition-colors",children:[e.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),"View"]}),e.jsxs("a",{href:n,download:!0,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-xl bg-slate-900 hover:bg-slate-800 text-white text-sm font-medium transition-colors",children:[e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Download"]})]})]})]})}function C_t({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(Hn,{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(Pi,{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(ga,{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(Ar,{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(mc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function M_t({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 d=new URL(o).searchParams.get("v");return d?`https://www.youtube.com/embed/${d}`:null}if(o.includes("youtu.be/")){const d=(l=o.split("youtu.be/")[1])==null?void 0:l.split("?")[0];return d?`https://www.youtube.com/embed/${d}`:null}if(o.includes("loom.com/share/")){const d=(i=o.split("loom.com/share/")[1])==null?void 0:i.split("?")[0];return d?`https://www.loom.com/embed/${d}`: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(Ai,{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 F5e(t){const s=t.split(/[-/T]/);return new Date(Number(s[0]),Number(s[1])-1,Number(s[2]))}function E_t(t,s){const r=js(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 P_t(t,s){const r=js(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 I_t({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:X4,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:xn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Hn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:nn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,d,u)=>{const f=F5e(d);if(u==="google")window.open(E_t(i,f),"_blank");else{const g=P_t(i,f),v=document.createElement("a");v.href=g,v.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,v.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:d,icon:u,color:f})=>{const g=F5e(d),v=Wx(g)&&!Ld(g),_=Ld(g),b=!v&&!_;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${f}`,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 ${_?"text-emerald-600":v?"text-slate-400":"text-slate-800"}`,children:[js(g,"MMM d, yyyy"),_&&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"})]})]}),v&&e.jsx("span",{className:"text-xs text-slate-400",children:"✓"}),b&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>l(i,d,"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(V1,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>l(i,d,"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 L_t({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 K.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(Un,{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(Ei,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function D_t({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($c,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(af,{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:js(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 O_t({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,w;const[l,i]=M.useState({first_name:((b=t.client_name)==null?void 0:b.split(" ")[0])||"",last_name:((w=t.client_name)==null?void 0:w.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[d,u]=M.useState({}),[f,g]=M.useState(!1),v=Bt({mutationFn:async()=>{const{error:j}=await K.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(d).length>0?d:null,spouse_first_name:f&&l.spouse_first_name||null,spouse_last_name:f&&l.spouse_last_name||null,spouse_email:f&&l.spouse_email||null,spouse_phone:f&&l.spouse_phone||null});if(j)throw j},onSuccess:o,onError:j=>{console.error("[PortalOnboarding] Submit failed:",j),ge.error("Something went wrong. Please try again.")}}),_=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"}),_&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(Pi,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:_.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),v.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(Re,{required:!0,value:l.first_name,onChange:j=>i(N=>({...N,first_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Re,{value:l.last_name,onChange:j=>i(N=>({...N,last_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Re,{type:"email",value:l.email,onChange:j=>i(N=>({...N,email:j.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Re,{type:"tel",value:l.phone,onChange:j=>i(N=>({...N,phone:j.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(j=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,preferred_contact_method:j.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===j.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.label},j.value))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(j=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,client_role:j})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===j?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.charAt(0).toUpperCase()+j.slice(1)},j))})]}),n.map(j=>e.jsxs("div",{children:[e.jsxs(_e,{className:"text-xs text-slate-600",children:[j.question_text," ",j.is_required&&"*"]}),j.field_type==="text"&&e.jsx(Re,{required:j.is_required,value:d[j.id]||"",onChange:N=>u(S=>({...S,[j.id]:N.target.value})),className:"mt-1 rounded-xl"}),j.field_type==="textarea"&&e.jsx("textarea",{required:j.is_required,value:d[j.id]||"",onChange:N=>u(S=>({...S,[j.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"}),j.field_type==="dropdown"&&e.jsxs("select",{required:j.is_required,value:d[j.id]||"",onChange:N=>u(S=>({...S,[j.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..."}),(j.options||[]).map(N=>e.jsx("option",{value:N,children:N},N))]}),j.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(S=>({...S,[j.id]:N})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[j.id]===N?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:N},N))})]},j.id)),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:j=>i(N=>({...N,notes:j.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>g(!f),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:f?"− Remove spouse/partner":"+ Add spouse/partner"}),f&&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(_e,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(Re,{value:l.spouse_first_name,onChange:j=>i(N=>({...N,spouse_first_name:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Re,{value:l.spouse_last_name,onChange:j=>i(N=>({...N,spouse_last_name:j.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Re,{type:"email",value:l.spouse_email,onChange:j=>i(N=>({...N,spouse_email:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Re,{type:"tel",value:l.spouse_phone,onChange:j=>i(N=>({...N,spouse_phone:j.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(Z,{type:"submit",disabled:v.isPending||!l.first_name,className:"w-full h-12 rounded-full text-sm font-semibold bg-slate-900 hover:bg-slate-800",children:v.isPending?"Submitting...":"Access My Portal"})]})]})}function R_t(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function F_t(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 z_t={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. 🎉"}},k9e=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function H1e(t){return k9e.map(s=>{if(s==="Active")return{key:"Active",label:R_t(t),description:F_t(t)};const r=z_t[s];return{key:s,label:r.label,description:r.description}})}function z5e(t){if(!t)return 0;const s=k9e.indexOf(t);return s>=0?s:0}function B_t(t,s){return Tt({queryKey:["client-portal-public",t],queryFn:async()=>{if(!t)return null;const{data:r,error:n}=await K.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 $_t(t){return Tt({queryKey:["client-portal-by-id",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.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 N9e({slug:t}){var te,Y,ce,oe,le,de;const[s,r]=M.useState(!1),[n,a]=M.useState("primary"),[o]=M.useState(()=>{const xe=`portal_fp_${t}`;let be=localStorage.getItem(xe);return be||(be=localStorage.getItem("portal_fp"),be?localStorage.setItem(xe,be):(be=crypto.randomUUID(),localStorage.setItem(xe,be),localStorage.setItem("portal_fp",be))),be});M.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:d}=B_t(t,!0),u=l==null?void 0:l.linked_portal_id,{data:f}=$_t(u),g=(te=l==null?void 0:l.deal_pipeline)==null?void 0:te.owner_user_id,{data:v}=Tt({queryKey:["portal-stages",g],queryFn:async()=>{const{data:xe,error:be}=await K.from("deal_pipeline_stages").select("*").eq("owner_user_id",g).order("sort_order",{ascending:!0});if(be)throw be;return xe},enabled:!!g}),{data:_}=Tt({queryKey:["portal-agent",g],queryFn:async()=>{const{data:xe,error:be}=await K.from("profiles").select("id, name, avatar_url, phone, email").eq("id",g).single();if(be)throw be;return xe},enabled:!!g}),b=n==="linked"&&f?f:l,w=b==null?void 0:b.id,{data:j}=Tt({queryKey:["portal-updates-public",w],queryFn:async()=>{const{data:xe,error:be}=await K.from("portal_updates").select("*").eq("portal_id",w).order("created_at",{ascending:!1});if(be)throw be;return xe},enabled:!!w}),N=(Y=b==null?void 0:b.deal_pipeline)==null?void 0:Y.id,{data:S}=Tt({queryKey:["portal-documents",N],queryFn:async()=>{const{data:xe,error:be}=await K.from("deal_files").select("*").eq("deal_id",N).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(be)throw be;return xe},enabled:!!N}),A=l==null?void 0:l.id,{data:I,isLoading:L}=Tt({queryKey:["portal-onboarding-check",A,o],queryFn:async()=>{const{data:xe,error:be}=await K.from("portal_onboarding_submissions").select("id").eq("portal_id",A).eq("device_fingerprint",o).maybeSingle();if(be)throw be;return xe},enabled:!!A&&!!(l!=null&&l.require_onboarding)}),{data:F}=Tt({queryKey:["portal-custom-questions-public",g],queryFn:async()=>{const{data:xe,error:be}=await K.from("portal_custom_questions").select("*").eq("owner_user_id",g).eq("is_active",!0).order("sort_order",{ascending:!0});if(be)throw be;return xe},enabled:!!g&&!!(l!=null&&l.require_onboarding)}),$=!!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(gs,{className:"h-48 w-full rounded-2xl"}),e.jsx(gs,{className:"h-10 w-48 mx-auto"}),e.jsx(gs,{className:"h-32 w-full rounded-2xl"}),e.jsx(gs,{className:"h-24 w-full rounded-2xl"})]})});if(d||!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("span",{className:"text-2xl",children:"🔒"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),e.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});if(!$){const xe=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(O_t,{portal:l,dealData:xe,agentProfile:_,customQuestions:F||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const q=(ce=l==null?void 0:l.deal_pipeline)==null?void 0:ce.deal_type,H=(oe=f==null?void 0:f.deal_pipeline)==null?void 0:oe.deal_type,U=!!f,Q=xe=>xe==="listing"?"Your Sale":xe==="buy-side"?"Your Purchase":"Transaction",se=xe=>xe==="listing"?e.jsx(Hn,{className:"w-3.5 h-3.5"}):e.jsx(Sm,{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(C_t,{dealData:b==null?void 0:b.deal_pipeline,agentProfile:_,welcomeMessage:b==null?void 0:b.welcome_message,isWon:(de=(le=b==null?void 0:b.deal_pipeline)==null?void 0:le.deal_pipeline_stages)==null?void 0:de.is_won_stage}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[U&&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:[se(q),Q(q)]}),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:[se(H),Q(H)]})]}),e.jsx(q_t,{portal:b,updates:j,documents:S}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(Xu,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),_&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:_.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function q_t({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,d=t.stage_mapping;let u=H1e(i);d&&d.length>0&&(u=d.map((_,b)=>{var w,j;return{key:`custom-${b}`,label:_.label||((w=u[b])==null?void 0:w.label)||`Stage ${b+1}`,description:_.description||((j=u[b])==null?void 0:j.description)||"",video_url:_.video_url||void 0}}));const f=d&&d.length>0?Math.min(z5e(o==null?void 0:o.name),u.length-1):z5e(o==null?void 0:o.name),g=u[f],v=g==null?void 0:g.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(T_t,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(M_t,{journeyStages:u,currentIndex:f}),g&&e.jsx(A_t,{currentStage:g,nextStepText:t.next_step_text,nextStepVideoUrl:v||t.next_step_video_url}),e.jsx(I_t,{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(L_t,{documents:r}),s&&s.length>0&&e.jsx(D_t,{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 U_t(){const s=sh().pathname.slice(1);return M.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(N9e,{slug:s})}const Tge="levelup_affiliate_ref",V_t=30,H_t=()=>{const[t]=Gc();M.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(Tge,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},W_t=()=>{try{const t=localStorage.getItem(Tge);if(!t)return null;const s=JSON.parse(t),r=V_t*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(Tge),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},one="/assets/levelup-logo-header-_ZX7DvlA.png",G_t="/assets/scale-your-team-ku4MPatU.png";function K_t({open:t,onOpenChange:s}){return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{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(_a,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ss,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Kr,{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 Xd={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"]}},Z_t=[{icon:mm,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:El,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:nn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:mc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Un,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:uo,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],Y_t=[{icon:xr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:gn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:ga,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Lh,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Pi,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:ol,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Oi,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Tm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],X_t=[{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."}],Q_t=()=>{const{user:t,loading:s}=Qs(),r=Or(),[n]=Gc();M.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if($&&q){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=M.useState(null),[l,i]=M.useState(null),[d,u]=M.useState(!1),[f,g]=M.useState(""),[v,_]=M.useState(""),[b,w]=M.useState(""),[j,N]=M.useState(!1),[S,A]=M.useState(!1),I=($,q=!1)=>{i({tier:$,skipTrial:q}),u(!0)};H_t(),M.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!s&&t&&!$&&!q&&r("/dashboard")},[t,s,r,location.pathname]),M.useEffect(()=>{n.get("canceled")==="true"&&ge.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const L=async($,q=!1)=>{if(!f){ge.error("Please enter your email address");return}if(!v.trim()){ge.error("Please enter your full name");return}N(!0),o($+(q?"_direct":""));const H=W_t();try{const{data:U,error:Q}=await K.functions.invoke("create-checkout",{body:{tier:$,email:f,name:v.trim(),couponCode:b.trim()||void 0,skipTrial:q,referralCode:H}});if(Q)throw Q;if(U!=null&&U.url)window.open(U.url,"_blank","noopener,noreferrer"),ge.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(U){console.error("Checkout error:",U),ge.error(U.message||"Failed to start checkout. Please try again.")}finally{N(!1),o(null),u(!1),i(null)}},F=()=>{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:one,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(Z,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(Z,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(Z,{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(Z,{size:"lg",onClick:()=>{var $;return($=document.getElementById("free-trial"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",children:["Start Your Free Trial",e.jsx(Ai,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(Z,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#1e3a4c] rounded-full",children:"See What's Included"})]})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Learn how we support agents and empower brokerages to grow—together."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center pt-4",children:[e.jsxs(Z,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("brokerage"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(_a,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(Z,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(mo,{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:Z_t.map(($,q)=>e.jsxs(De,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs($t,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx($.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Vt,{className:"text-xl font-sans",children:$.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:$.description})})]},q))})]})}),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(gn,{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:Y_t.map(($,q)=>e.jsxs(De,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs($t,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx($.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Vt,{className:"text-lg font-semibold text-white",children:$.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:$.description})})]},q))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(Z,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-white text-[#4a6b6d] hover:bg-white/90 shadow-xl transition-all hover:scale-105",children:["Get Agent OS with Your Membership",e.jsx(Ai,{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(_a,{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)=>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(ma,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:$})]},q))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(Z,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(ei,{className:"ml-2 w-5 h-5"})]}),e.jsxs(Z,{size:"lg",variant:"outline",onClick:()=>A(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(nn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:G_t,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:X_t.map(($,q)=>e.jsx(De,{className:"bg-muted/30 border-0",children:e.jsxs(Oe,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(H=>e.jsx(Gn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},H))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',$.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:$.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$.role})]})]})},q))})]})}),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(Z,{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(Ai,{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(De,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs($t,{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(mo,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Vt,{className:"text-xl font-sans",children:Xd.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Xd.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Xd.individual_agent.period})]}),e.jsx(_r,{className:"text-base mt-2",children:Xd.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(Tn,{className:"w-4 h-4"}),Xd.individual_agent.trial]})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Xd.individual_agent.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsxs(CP,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(Z,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("individual_agent"),children:"Start Free Trial"}),e.jsx(Z,{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(De,{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($t,{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(_a,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-xl font-sans",children:Xd.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Xd.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:Xd.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Xd.brokerage_under_25.period})]}),e.jsx(_r,{className:"text-base mt-2",children:Xd.brokerage_under_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Xd.brokerage_under_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx(CP,{className:"pt-4",children:e.jsx(Z,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(De,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs($t,{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(_a,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-xl font-sans",children:Xd.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Xd.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:Xd.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Xd.brokerage_over_25.period})]}),e.jsx(_r,{className:"text-base mt-2",children:Xd.brokerage_over_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Xd.brokerage_over_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx(CP,{className:"pt-4",children:e.jsx(Z,{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(Z,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-10 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105",children:["Start Your Free Trial",e.jsx(Ai,{className:"ml-2 w-5 h-5"})]}),e.jsx(Z,{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:one,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(K_t,{open:S,onOpenChange:A}),e.jsx(bs,{open:d,onOpenChange:u,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(Kr,{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(_e,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Re,{id:"dialog-name",type:"text",placeholder:"John Smith",value:v,onChange:$=>_($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(_e,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Re,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:f,onChange:$=>g($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(_e,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(Re,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:b,onChange:$=>w($.target.value),className:"mt-1"})]})]}),e.jsx(Z,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:F,disabled:j,children:j?"Loading...":"Continue to Checkout"})]})})]})},J_t=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Gh,{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"})]})]})]})]})})]}),ebt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Gh,{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"})]})]})]})]})})]}),tbt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Gh,{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"})]})]})]})]})})]}),sbt=O_({email:Ko().email("Invalid email address"),password:Ko().min(6,"Password must be at least 6 characters")}),rbt=()=>{const{signIn:t,user:s}=Qs(),r=Or(),[n,a]=M.useState(!1),[o,l]=M.useState({}),[i,d]=M.useState(""),[u,f]=M.useState(!1),[g,v]=M.useState(!1);M.useEffect(()=>{s&&r("/dashboard")},[s,r]);const _=async w=>{w.preventDefault(),l({}),a(!0);const j=new FormData(w.currentTarget),N=j.get("email"),S=j.get("password");try{sbt.parse({email:N,password:S}),await t(N,S)}catch(A){if(A instanceof Qx){const I={};A.errors.forEach(L=>{L.path[0]&&(I[L.path[0]]=L.message)}),l(I)}}finally{a(!1)}},b=async()=>{if(!i){ge.error("Please enter your email address");return}f(!0);try{const{error:w}=await K.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(w)throw w;ge.success("Password reset email sent! Check your inbox."),v(!1),d("")}catch(w){ge.error(w.message||"Failed to send reset email")}finally{f(!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(yo,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Ba,{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:eBe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(De,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs($t,{className:"space-y-1 text-center pb-4",children:[e.jsx(Vt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(_r,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(Re,{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(_e,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(Re,{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(Z,{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(bs,{open:g,onOpenChange:v,children:[e.jsx(Si,{asChild:!0,children:e.jsx(Z,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(_s,{className:"bg-white",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(Kr,{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(_e,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(Re,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:w=>d(w.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(Z,{onClick:b,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(yo,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},nbt=()=>{const[t]=Gc(),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(De,{className:"max-w-lg w-full",children:[e.jsxs($t,{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(hi,{className:"w-10 h-10 text-green-500"})}),e.jsx(Vt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(_r,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(Ar,{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."})})]})]})})},S9e=t=>{const[s,r]=M.useState(null),[n,a]=M.useState(!0);return M.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await K.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:d}=K.storage.from("avatars").getPublicUrl(`${t}/${i[0].name}`);r(`${d.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 K.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=K.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},C9e=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await K.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=K.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},abt=t=>{const[s,r]=M.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return M.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await K.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(d=>({...d,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 d=new Date().getTime(),u=new Date(a.subscription_end_date).getTime(),f=Math.ceil((u-d)/(1e3*60*60*24)),g=f<=0;r({isTrial:!0,isExpired:g,expiresAt:a.subscription_end_date,daysLeft:g?0:f,loading:!1})}else if(i){const d=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),f=Math.ceil((u-d)/(1e3*60*60*24)),g=f<=0;r({isTrial:!0,isExpired:g,expiresAt:a.trial_expires_at,daysLeft:g?0:f,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},M9e=()=>{const{data:t,isLoading:s}=Tt({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await K.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")}},B5e="community_last_seen_post_at";function ibt(){const{user:t}=Qs(),s=sh(),[r,n]=M.useState(0),[a,o]=M.useState(null);M.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${B5e}_${t.id}`);o(i)},[t]),M.useEffect(()=>{if(!t)return;(async()=>{let d=K.from("community_posts").select("id",{count:"exact",head:!0});a&&(d=d.gt("created_at",a));const{data:u}=await K.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:f,error:g}=await d;!g&&f!==null&&n(f)})()},[t,a]),M.useEffect(()=>{if(!t)return;const i=K.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async d=>{const u=d.new;if(u.user_id===t.id)return;const f=s.pathname==="/community";f||n(w=>w+1);const{data:g}=await K.from("profiles").select("name").eq("id",u.user_id).single(),v=(g==null?void 0:g.name)||"Someone",_=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),b=_.length>50?_.substring(0,50)+"...":_;f||ge("New Community Post",{description:`${v}: ${b}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{K.removeChannel(i)}},[t,s.pathname]);const l=M.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${B5e}_${t.id}`,i),o(i),n(0)},[t]);return M.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function obt(){const{isAdmin:t}=Qs(),{data:s=0}=Tt({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await K.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 Ug=()=>{const t=vi();return Tt({queryKey:["user-team",t],queryFn:async()=>{const{data:s,error:r}=await K.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 K.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})},uL=ioe,W1e=E1e,lbt=ooe,T9e=M.forwardRef(({className:t,...s},r)=>e.jsx(aM,{className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));T9e.displayName=aM.displayName;const cbt=VN("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"}}),lM=M.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(lbt,{children:[e.jsx(T9e,{}),e.jsxs(iM,{ref:a,className:It(cbt({side:t}),s),...n,children:[r,e.jsxs(oL,{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(Vr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));lM.displayName=iM.displayName;const hL=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-2 text-center sm:text-left",t),...s});hL.displayName="SheetHeader";const mL=M.forwardRef(({className:t,...s},r)=>e.jsx(aL,{ref:r,className:It("text-lg font-semibold text-foreground",t),...s}));mL.displayName=aL.displayName;const dbt=M.forwardRef(({className:t,...s},r)=>e.jsx(iL,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));dbt.displayName=iL.displayName;function ubt(t,s){return M.useReducer((r,n)=>s[r][n]??r,t)}var G1e="ScrollArea",[A9e]=Cc(G1e),[hbt,jf]=A9e(G1e),E9e=M.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=M.useState(null),[u,f]=M.useState(null),[g,v]=M.useState(null),[_,b]=M.useState(null),[w,j]=M.useState(null),[N,S]=M.useState(0),[A,I]=M.useState(0),[L,F]=M.useState(!1),[$,q]=M.useState(!1),H=Sa(s,Q=>d(Q)),U=E_(a);return e.jsx(hbt,{scope:r,type:n,dir:U,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:f,content:g,onContentChange:v,scrollbarX:_,onScrollbarXChange:b,scrollbarXEnabled:L,onScrollbarXEnabledChange:F,scrollbarY:w,onScrollbarYChange:j,scrollbarYEnabled:$,onScrollbarYEnabledChange:q,onCornerWidthChange:S,onCornerHeightChange:I,children:e.jsx(Qr.div,{dir:U,...l,ref:H,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})});E9e.displayName=G1e;var P9e="ScrollAreaViewport",I9e=M.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=jf(P9e,r),i=M.useRef(null),d=Sa(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(Qr.div,{"data-radix-scroll-area-viewport":"",...o,ref:d,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})})]})});I9e.displayName=P9e;var ly="ScrollAreaScrollbar",K1e=M.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=jf(ly,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return M.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(mbt,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(pbt,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(L9e,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(Z1e,{...n,ref:s}):null});K1e.displayName=ly;var mbt=M.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=jf(ly,t.__scopeScrollArea),[o,l]=M.useState(!1);return M.useEffect(()=>{const i=a.scrollArea;let d=0;if(i){const u=()=>{window.clearTimeout(d),l(!0)},f=()=>{d=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",f),()=>{window.clearTimeout(d),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",f)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(od,{present:r||o,children:e.jsx(L9e,{"data-state":o?"visible":"hidden",...n,ref:s})})}),pbt=M.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=jf(ly,t.__scopeScrollArea),o=t.orientation==="horizontal",l=boe(()=>d("SCROLL_END"),100),[i,d]=ubt("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 M.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,d]),M.useEffect(()=>{const u=a.viewport,f=o?"scrollLeft":"scrollTop";if(u){let g=u[f];const v=()=>{const _=u[f];g!==_&&(d("SCROLL"),l()),g=_};return u.addEventListener("scroll",v),()=>u.removeEventListener("scroll",v)}},[a.viewport,o,d,l]),e.jsx(od,{present:r||i!=="hidden",children:e.jsx(Z1e,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Sr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Sr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),L9e=M.forwardRef((t,s)=>{const r=jf(ly,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=M.useState(!1),i=t.orientation==="horizontal",d=boe(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=jf(ly,t.__scopeScrollArea),o=M.useRef(null),l=M.useRef(0),[i,d]=M.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=z9e(i.viewport,i.content),f={...n,sizes:i,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:v=>o.current=v,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:v=>l.current=v};function g(v,_){return _bt(v,l.current,i,_)}return r==="horizontal"?e.jsx(fbt,{...f,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollLeft,_=$5e(v,i,a.dir);o.current.style.transform=`translate3d(${_}px, 0, 0)`}},onWheelScroll:v=>{a.viewport&&(a.viewport.scrollLeft=v)},onDragScroll:v=>{a.viewport&&(a.viewport.scrollLeft=g(v,a.dir))}}):r==="vertical"?e.jsx(gbt,{...f,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollTop,_=$5e(v,i);o.current.style.transform=`translate3d(0, ${_}px, 0)`}},onWheelScroll:v=>{a.viewport&&(a.viewport.scrollTop=v)},onDragScroll:v=>{a.viewport&&(a.viewport.scrollTop=g(v))}}):null}),fbt=M.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=jf(ly,t.__scopeScrollArea),[l,i]=M.useState(),d=M.useRef(null),u=Sa(s,d,o.onScrollbarXChange);return M.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(O9e,{"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":_oe(r)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.x),onDragScroll:f=>t.onDragScroll(f.x),onWheelScroll:(f,g)=>{if(o.viewport){const v=o.viewport.scrollLeft+f.deltaX;t.onWheelScroll(v),$9e(v,g)&&f.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:cne(l.paddingLeft),paddingEnd:cne(l.paddingRight)}})}})}),gbt=M.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=jf(ly,t.__scopeScrollArea),[l,i]=M.useState(),d=M.useRef(null),u=Sa(s,d,o.onScrollbarYChange);return M.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(O9e,{"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":_oe(r)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.y),onDragScroll:f=>t.onDragScroll(f.y),onWheelScroll:(f,g)=>{if(o.viewport){const v=o.viewport.scrollTop+f.deltaY;t.onWheelScroll(v),$9e(v,g)&&f.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:cne(l.paddingTop),paddingEnd:cne(l.paddingBottom)}})}})}),[xbt,D9e]=A9e(ly),O9e=M.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:f,onResize:g,...v}=t,_=jf(ly,r),[b,w]=M.useState(null),j=Sa(s,H=>w(H)),N=M.useRef(null),S=M.useRef(""),A=_.viewport,I=n.content-n.viewport,L=Bc(f),F=Bc(d),$=boe(g,10);function q(H){if(N.current){const U=H.clientX-N.current.left,Q=H.clientY-N.current.top;u({x:U,y:Q})}}return M.useEffect(()=>{const H=U=>{const Q=U.target;(b==null?void 0:b.contains(Q))&&L(U,I)};return document.addEventListener("wheel",H,{passive:!1}),()=>document.removeEventListener("wheel",H,{passive:!1})},[A,b,I,L]),M.useEffect(F,[n,F]),d3(b,$),d3(_.content,$),e.jsx(xbt,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:Bc(o),onThumbPointerUp:Bc(l),onThumbPositionChange:F,onThumbPointerDown:Bc(i),children:e.jsx(Qr.div,{...v,ref:j,style:{position:"absolute",...v.style},onPointerDown:Sr(t.onPointerDown,H=>{H.button===0&&(H.target.setPointerCapture(H.pointerId),N.current=b.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q(H))}),onPointerMove:Sr(t.onPointerMove,q),onPointerUp:Sr(t.onPointerUp,H=>{const U=H.target;U.hasPointerCapture(H.pointerId)&&U.releasePointerCapture(H.pointerId),document.body.style.webkitUserSelect=S.current,_.viewport&&(_.viewport.style.scrollBehavior=""),N.current=null})})})}),lne="ScrollAreaThumb",R9e=M.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=D9e(lne,t.__scopeScrollArea);return e.jsx(od,{present:r||a.hasThumb,children:e.jsx(ybt,{ref:s,...n})})}),ybt=M.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=jf(lne,r),l=D9e(lne,r),{onThumbPositionChange:i}=l,d=Sa(s,g=>l.onThumbChange(g)),u=M.useRef(void 0),f=boe(()=>{u.current&&(u.current(),u.current=void 0)},100);return M.useEffect(()=>{const g=o.viewport;if(g){const v=()=>{if(f(),!u.current){const _=bbt(g,i);u.current=_,i()}};return i(),g.addEventListener("scroll",v),()=>g.removeEventListener("scroll",v)}},[o.viewport,f,i]),e.jsx(Qr.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Sr(t.onPointerDownCapture,g=>{const _=g.target.getBoundingClientRect(),b=g.clientX-_.left,w=g.clientY-_.top;l.onThumbPointerDown({x:b,y:w})}),onPointerUp:Sr(t.onPointerUp,l.onThumbPointerUp)})});R9e.displayName=lne;var Y1e="ScrollAreaCorner",F9e=M.forwardRef((t,s)=>{const r=jf(Y1e,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(vbt,{...t,ref:s}):null});F9e.displayName=Y1e;var vbt=M.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=jf(Y1e,r),[o,l]=M.useState(0),[i,d]=M.useState(0),u=!!(o&&i);return d3(a.scrollbarX,()=>{var g;const f=((g=a.scrollbarX)==null?void 0:g.offsetHeight)||0;a.onCornerHeightChange(f),d(f)}),d3(a.scrollbarY,()=>{var g;const f=((g=a.scrollbarY)==null?void 0:g.offsetWidth)||0;a.onCornerWidthChange(f),l(f)}),u?e.jsx(Qr.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 cne(t){return t?parseInt(t,10):0}function z9e(t,s){const r=t/s;return isNaN(r)?0:r}function _oe(t){const s=z9e(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function _bt(t,s,r,n="ltr"){const a=_oe(r),o=a/2,l=s||o,i=a-l,d=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,f=r.content-r.viewport,g=n==="ltr"?[0,f]:[f*-1,0];return B9e([d,u],g)(t)}function $5e(t,s,r="ltr"){const n=_oe(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=s.scrollbar.size-a,l=s.content-s.viewport,i=o-n,d=r==="ltr"?[0,l]:[l*-1,0],u=PI(t,d);return B9e([0,l],[0,i])(u)}function B9e(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 $9e(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 boe(t,s){const r=Bc(t),n=M.useRef(0);return M.useEffect(()=>()=>window.clearTimeout(n.current),[]),M.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function d3(t,s){const r=Bc(s);Hc(()=>{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 q9e=E9e,wbt=I9e,jbt=F9e;const Fi=M.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(q9e,{ref:n,className:It("relative overflow-hidden",t),...r,children:[e.jsx(wbt,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(woe,{}),e.jsx(jbt,{})]}));Fi.displayName=q9e.displayName;const woe=M.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(K1e,{ref:n,orientation:s,className:It("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:e.jsx(R9e,{className:"relative flex-1 rounded-full bg-border"})}));woe.displayName=K1e.displayName;var joe="Collapsible",[kbt]=Cc(joe),[Nbt,X1e]=kbt(joe),U9e=M.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[d,u]=uu({prop:n,defaultProp:a??!1,onChange:l,caller:joe});return e.jsx(Nbt,{scope:r,disabled:o,contentId:Bd(),open:d,onOpenToggle:M.useCallback(()=>u(f=>!f),[u]),children:e.jsx(Qr.div,{"data-state":J1e(d),"data-disabled":o?"":void 0,...i,ref:s})})});U9e.displayName=joe;var V9e="CollapsibleTrigger",H9e=M.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=X1e(V9e,r);return e.jsx(Qr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":J1e(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Sr(t.onClick,a.onOpenToggle)})});H9e.displayName=V9e;var Q1e="CollapsibleContent",W9e=M.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=X1e(Q1e,t.__scopeCollapsible);return e.jsx(od,{present:r||a.open,children:({present:o})=>e.jsx(Sbt,{...n,ref:s,present:o})})});W9e.displayName=Q1e;var Sbt=M.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=X1e(Q1e,r),[i,d]=M.useState(n),u=M.useRef(null),f=Sa(s,u),g=M.useRef(0),v=g.current,_=M.useRef(0),b=_.current,w=l.open||i,j=M.useRef(w),N=M.useRef(void 0);return M.useEffect(()=>{const S=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(S)},[]),Hc(()=>{const S=u.current;if(S){N.current=N.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const A=S.getBoundingClientRect();g.current=A.height,_.current=A.width,j.current||(S.style.transitionDuration=N.current.transitionDuration,S.style.animationName=N.current.animationName),d(n)}},[l.open,n]),e.jsx(Qr.div,{"data-state":J1e(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!w,...o,ref:f,style:{"--radix-collapsible-content-height":v?`${v}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...t.style},children:w&&a})});function J1e(t){return t?"open":"closed"}var Cbt=U9e;const Eg=Cbt,Pg=H9e,Ig=W9e,Mbt="/assets/levelup-logo-Eif24dqY.png",Tbt="/assets/levelup-logo-icon-C-7iromj.png",Abt="/assets/levelup-logo-mobile-B9skSjUG.png";var pL=t=>t.type==="checkbox",_k=t=>t instanceof Date,wh=t=>t==null;const G9e=t=>typeof t=="object";var id=t=>!wh(t)&&!Array.isArray(t)&&G9e(t)&&!_k(t),K9e=t=>id(t)&&t.target?pL(t.target)?t.target.checked:t.target.value:t,Ebt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,Z9e=(t,s)=>t.has(Ebt(s)),Pbt=t=>{const s=t.constructor&&t.constructor.prototype;return id(s)&&s.hasOwnProperty("isPrototypeOf")},e_e=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Td(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(!(e_e&&(t instanceof Blob||n))&&(r||id(t)))if(s=r?[]:{},!r&&!Pbt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=Td(t[a]));else return t;return s}var koe=t=>/^\w*$/.test(t),ed=t=>t===void 0,t_e=t=>Array.isArray(t)?t.filter(Boolean):[],s_e=t=>t_e(t.replace(/["|']|\]/g,"").split(/\.|\[/)),bn=(t,s,r)=>{if(!s||!id(t))return r;const n=(koe(s)?[s]:s_e(s)).reduce((a,o)=>wh(a)?a:a[o],t);return ed(n)||n===t?ed(t[s])?r:t[s]:n},Jm=t=>typeof t=="boolean",Wo=(t,s,r)=>{let n=-1;const a=koe(s)?[s]:s_e(s),o=a.length,l=o-1;for(;++nut.useContext(r_e),Ibt=t=>{const{children:s,...r}=t;return ut.createElement(r_e.Provider,{value:r},s)};var Y9e=(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]!==yg.all&&(s._proxyFormState[l]=!n||yg.all),r&&(r[l]=!0),t[l]}});return a};const n_e=typeof window<"u"?ut.useLayoutEffect:ut.useEffect;function Lbt(t){const s=Noe(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=ut.useState(r._formState),d=ut.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return n_e(()=>r._subscribe({name:a,formState:d.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),ut.useEffect(()=>{d.current.isValid&&r._setValid(!0)},[r]),ut.useMemo(()=>Y9e(l,r,d.current,!1),[l,r])}var Ix=t=>typeof t=="string",X9e=(t,s,r,n,a)=>Ix(t)?(n&&s.watch.add(t),bn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),bn(r,o))):(n&&(s.watchAll=!0),r),Age=t=>wh(t)||!G9e(t);function n0(t,s,r=new WeakSet){if(Age(t)||Age(s))return t===s;if(_k(t)&&_k(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(_k(l)&&_k(i)||id(l)&&id(i)||Array.isArray(l)&&Array.isArray(i)?!n0(l,i,r):l!==i)return!1}}return!0}function Dbt(t){const s=Noe(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},d=ut.useRef(a),u=ut.useRef(i),f=ut.useRef(void 0);u.current=i;const g=ut.useMemo(()=>r._getWatch(n,d.current),[r,n]),[v,_]=ut.useState(u.current?u.current(g):g);return n_e(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:b=>{if(!o){const w=X9e(n,r._names,b.values||r._formValues,!1,d.current);if(u.current){const j=u.current(w);n0(j,f.current)||(_(j),f.current=j)}else _(w)}}}),[r,o,n,l]),ut.useEffect(()=>r._removeUnmounted()),v}function Obt(t){const s=Noe(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=Z9e(a._names.array,r),d=ut.useMemo(()=>bn(a._formValues,r,bn(a._defaultValues,r,l)),[a,r,l]),u=Dbt({control:a,name:r,defaultValue:d,exact:!0}),f=Lbt({control:a,name:r,exact:!0}),g=ut.useRef(t),v=ut.useRef(a.register(r,{...t.rules,value:u,...Jm(t.disabled)?{disabled:t.disabled}:{}}));g.current=t;const _=ut.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!bn(f.errors,r)},isDirty:{enumerable:!0,get:()=>!!bn(f.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!bn(f.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!bn(f.validatingFields,r)},error:{enumerable:!0,get:()=>bn(f.errors,r)}}),[f,r]),b=ut.useCallback(S=>v.current.onChange({target:{value:K9e(S),name:r},type:dne.CHANGE}),[r]),w=ut.useCallback(()=>v.current.onBlur({target:{value:bn(a._formValues,r),name:r},type:dne.BLUR}),[r,a._formValues]),j=ut.useCallback(S=>{const A=bn(a._fields,r);A&&S&&(A._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:I=>S.setCustomValidity(I),reportValidity:()=>S.reportValidity()})},[a._fields,r]),N=ut.useMemo(()=>({name:r,value:u,...Jm(n)||f.disabled?{disabled:f.disabled||n}:{},onChange:b,onBlur:w,ref:j}),[r,n,f.disabled,b,w,j,u]);return ut.useEffect(()=>{const S=a._options.shouldUnregister||o;a.register(r,{...g.current.rules,...Jm(g.current.disabled)?{disabled:g.current.disabled}:{}});const A=(I,L)=>{const F=bn(a._fields,I);F&&F._f&&(F._f.mount=L)};if(A(r,!0),S){const I=Td(bn(a._options.defaultValues,r));Wo(a._defaultValues,r,I),ed(bn(a._formValues,r))&&Wo(a._formValues,r,I)}return!i&&a.register(r),()=>{(i?S&&!a._state.action:S)?a.unregister(r):A(r,!1)}},[r,a,i,o]),ut.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ut.useMemo(()=>({field:N,formState:f,fieldState:_}),[N,f,_])}const Rbt=t=>t.render(Obt(t));var Q9e=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},EP=t=>Array.isArray(t)?t:[t],q5e=()=>{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=[]}}},dm=t=>id(t)&&!Object.keys(t).length,a_e=t=>t.type==="file",vg=t=>typeof t=="function",une=t=>{if(!e_e)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},J9e=t=>t.type==="select-multiple",i_e=t=>t.type==="radio",Fbt=t=>i_e(t)||pL(t),Che=t=>une(t)&&t.isConnected;function zbt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(vg(t[s]))return!0;return!1};function hne(t,s={}){const r=Array.isArray(t);if(id(t)||r)for(const n in t)Array.isArray(t[n])||id(t[n])&&!e$e(t[n])?(s[n]=Array.isArray(t[n])?[]:{},hne(t[n],s[n])):wh(t[n])||(s[n]=!0);return s}function t$e(t,s,r){const n=Array.isArray(t);if(id(t)||n)for(const a in t)Array.isArray(t[a])||id(t[a])&&!e$e(t[a])?ed(s)||Age(r[a])?r[a]=Array.isArray(t[a])?hne(t[a],[]):{...hne(t[a])}:t$e(t[a],wh(s)?{}:s[a],r[a]):r[a]=!n0(t[a],s[a]);return r}var BA=(t,s)=>t$e(t,s,hne(s));const U5e={value:!1,isValid:!1},V5e={value:!0,isValid:!0};var s$e=t=>{if(Array.isArray(t)){if(t.length>1){const s=t.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:s,isValid:!!s.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!ed(t[0].attributes.value)?ed(t[0].value)||t[0].value===""?V5e:{value:t[0].value,isValid:!0}:V5e:U5e}return U5e},r$e=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>ed(t)?t:s?t===""?NaN:t&&+t:r&&Ix(t)?new Date(t):n?n(t):t;const H5e={isValid:!1,value:null};var n$e=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,H5e):H5e;function W5e(t){const s=t.ref;return a_e(s)?s.files:i_e(s)?n$e(t.refs).value:J9e(s)?[...s.selectedOptions].map(({value:r})=>r):pL(s)?s$e(t.refs).value:r$e(ed(s.value)?t.ref.value:s.value,t)}var $bt=(t,s,r,n)=>{const a={};for(const o of t){const l=bn(s,o);l&&Wo(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},mne=t=>t instanceof RegExp,$A=t=>ed(t)?t:mne(t)?t.source:id(t)?mne(t.value)?t.value.source:t.value:t,G5e=t=>({isOnSubmit:!t||t===yg.onSubmit,isOnBlur:t===yg.onBlur,isOnChange:t===yg.onChange,isOnAll:t===yg.all,isOnTouch:t===yg.onTouched});const K5e="AsyncFunction";var qbt=t=>!!t&&!!t.validate&&!!(vg(t.validate)&&t.validate.constructor.name===K5e||id(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===K5e)),Ubt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Z5e=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const PP=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=bn(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(PP(i,s))break}else if(id(i)&&PP(i,s))break}}};function Y5e(t,s,r){const n=bn(t,r);if(n||koe(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=bn(s,o),i=bn(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 Vbt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return dm(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||yg.all))},Hbt=(t,s,r)=>!t||!s||t===s||EP(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),Wbt=(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,Gbt=(t,s)=>!t_e(bn(t,s)).length&&pd(t,s),Kbt=(t,s,r)=>{const n=EP(bn(t,r));return Wo(n,"root",s[r]),Wo(t,r,n),t},Gse=t=>Ix(t);function X5e(t,s,r="validate"){if(Gse(t)||Array.isArray(t)&&t.every(Gse)||Jm(t)&&!t)return{type:r,message:Gse(t)?t:"",ref:s}}var KC=t=>id(t)&&!mne(t)?t:{value:t,message:""},Q5e=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:u,minLength:f,min:g,max:v,pattern:_,validate:b,name:w,valueAsNumber:j,mount:N}=t._f,S=bn(r,w);if(!N||s.has(w))return{};const A=i?i[0]:l,I=se=>{a&&A.reportValidity&&(A.setCustomValidity(Jm(se)?"":se||""),A.reportValidity())},L={},F=i_e(l),$=pL(l),q=F||$,H=(j||a_e(l))&&ed(l.value)&&ed(S)||une(l)&&l.value===""||S===""||Array.isArray(S)&&!S.length,U=Q9e.bind(null,w,n,L),Q=(se,te,Y,ce=Fy.maxLength,oe=Fy.minLength)=>{const le=se?te:Y;L[w]={type:se?ce:oe,message:le,ref:l,...U(se?ce:oe,le)}};if(o?!Array.isArray(S)||!S.length:d&&(!q&&(H||wh(S))||Jm(S)&&!S||$&&!s$e(i).isValid||F&&!n$e(i).isValid)){const{value:se,message:te}=Gse(d)?{value:!!d,message:d}:KC(d);if(se&&(L[w]={type:Fy.required,message:te,ref:A,...U(Fy.required,te)},!n))return I(te),L}if(!H&&(!wh(g)||!wh(v))){let se,te;const Y=KC(v),ce=KC(g);if(!wh(S)&&!isNaN(S)){const oe=l.valueAsNumber||S&&+S;wh(Y.value)||(se=oe>Y.value),wh(ce.value)||(te=oenew Date(new Date().toDateString()+" "+be),de=l.type=="time",xe=l.type=="week";Ix(Y.value)&&S&&(se=de?le(S)>le(Y.value):xe?S>Y.value:oe>new Date(Y.value)),Ix(ce.value)&&S&&(te=de?le(S)+se.value,ce=!wh(te.value)&&S.length<+te.value;if((Y||ce)&&(Q(Y,se.message,te.message),!n))return I(L[w].message),L}if(_&&!H&&Ix(S)){const{value:se,message:te}=KC(_);if(mne(se)&&!S.match(se)&&(L[w]={type:Fy.pattern,message:te,ref:l,...U(Fy.pattern,te)},!n))return I(te),L}if(b){if(vg(b)){const se=await b(S,r),te=X5e(se,A);if(te&&(L[w]={...te,...U(Fy.validate,te.message)},!n))return I(te.message),L}else if(id(b)){let se={};for(const te in b){if(!dm(se)&&!n)break;const Y=X5e(await b[te](S,r),A,te);Y&&(se={...Y,...U(te,Y.message)},I(Y.message),n&&(L[w]=se))}if(!dm(se)&&(L[w]={ref:A,...se},!n))return L}}return I(!0),L};const Zbt={mode:yg.onSubmit,reValidateMode:yg.onChange,shouldFocusError:!0};function Ybt(t={}){let s={...Zbt,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:vg(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=id(s.defaultValues)||id(s.values)?Td(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:Td(a),l={action:!1,mount:!1,watch:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},d,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let g={...f};const v={array:q5e(),state:q5e()},_=s.criteriaMode===yg.all,b=He=>ct=>{clearTimeout(u),u=setTimeout(He,ct)},w=async He=>{if(!s.disabled&&(f.isValid||g.isValid||He)){const ct=s.resolver?dm((await $()).errors):await H(n,!0);ct!==r.isValid&&v.state.next({isValid:ct})}},j=(He,ct)=>{!s.disabled&&(f.isValidating||f.validatingFields||g.isValidating||g.validatingFields)&&((He||Array.from(i.mount)).forEach(We=>{We&&(ct?Wo(r.validatingFields,We,ct):pd(r.validatingFields,We))}),v.state.next({validatingFields:r.validatingFields,isValidating:!dm(r.validatingFields)}))},N=(He,ct=[],We,Ze,ht=!0,Ke=!0)=>{if(Ze&&We&&!s.disabled){if(l.action=!0,Ke&&Array.isArray(bn(n,He))){const qe=We(bn(n,He),Ze.argA,Ze.argB);ht&&Wo(n,He,qe)}if(Ke&&Array.isArray(bn(r.errors,He))){const qe=We(bn(r.errors,He),Ze.argA,Ze.argB);ht&&Wo(r.errors,He,qe),Gbt(r.errors,He)}if((f.touchedFields||g.touchedFields)&&Ke&&Array.isArray(bn(r.touchedFields,He))){const qe=We(bn(r.touchedFields,He),Ze.argA,Ze.argB);ht&&Wo(r.touchedFields,He,qe)}(f.dirtyFields||g.dirtyFields)&&(r.dirtyFields=BA(a,o)),v.state.next({name:He,isDirty:Q(He,ct),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Wo(o,He,ct)},S=(He,ct)=>{Wo(r.errors,He,ct),v.state.next({errors:r.errors})},A=He=>{r.errors=He,v.state.next({errors:r.errors,isValid:!1})},I=(He,ct,We,Ze)=>{const ht=bn(n,He);if(ht){const Ke=bn(o,He,ed(We)?bn(a,He):We);ed(Ke)||Ze&&Ze.defaultChecked||ct?Wo(o,He,ct?Ke:W5e(ht._f)):Y(He,Ke),l.mount&&w()}},L=(He,ct,We,Ze,ht)=>{let Ke=!1,qe=!1;const Je={name:He};if(!s.disabled){if(!We||Ze){(f.isDirty||g.isDirty)&&(qe=r.isDirty,r.isDirty=Je.isDirty=Q(),Ke=qe!==Je.isDirty);const Lt=n0(bn(a,He),ct);qe=!!bn(r.dirtyFields,He),Lt?pd(r.dirtyFields,He):Wo(r.dirtyFields,He,!0),Je.dirtyFields=r.dirtyFields,Ke=Ke||(f.dirtyFields||g.dirtyFields)&&qe!==!Lt}if(We){const Lt=bn(r.touchedFields,He);Lt||(Wo(r.touchedFields,He,We),Je.touchedFields=r.touchedFields,Ke=Ke||(f.touchedFields||g.touchedFields)&&Lt!==We)}Ke&&ht&&v.state.next(Je)}return Ke?Je:{}},F=(He,ct,We,Ze)=>{const ht=bn(r.errors,He),Ke=(f.isValid||g.isValid)&&Jm(ct)&&r.isValid!==ct;if(s.delayError&&We?(d=b(()=>S(He,We)),d(s.delayError)):(clearTimeout(u),d=null,We?Wo(r.errors,He,We):pd(r.errors,He)),(We?!n0(ht,We):ht)||!dm(Ze)||Ke){const qe={...Ze,...Ke&&Jm(ct)?{isValid:ct}:{},errors:r.errors,name:He};r={...r,...qe},v.state.next(qe)}},$=async He=>{j(He,!0);const ct=await s.resolver(o,s.context,$bt(He||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return j(He),ct},q=async He=>{const{errors:ct}=await $(He);if(He)for(const We of He){const Ze=bn(ct,We);Ze?Wo(r.errors,We,Ze):pd(r.errors,We)}else r.errors=ct;return ct},H=async(He,ct,We={valid:!0})=>{for(const Ze in He){const ht=He[Ze];if(ht){const{_f:Ke,...qe}=ht;if(Ke){const Je=i.array.has(Ke.name),Lt=ht._f&&qbt(ht._f);Lt&&f.validatingFields&&j([Ze],!0);const zt=await Q5e(ht,i.disabled,o,_,s.shouldUseNativeValidation&&!ct,Je);if(Lt&&f.validatingFields&&j([Ze]),zt[Ke.name]&&(We.valid=!1,ct))break;!ct&&(bn(zt,Ke.name)?Je?Kbt(r.errors,zt,Ke.name):Wo(r.errors,Ke.name,zt[Ke.name]):pd(r.errors,Ke.name))}!dm(qe)&&await H(qe,ct,We)}}return We.valid},U=()=>{for(const He of i.unMount){const ct=bn(n,He);ct&&(ct._f.refs?ct._f.refs.every(We=>!Che(We)):!Che(ct._f.ref))&&Pe(He)}i.unMount=new Set},Q=(He,ct)=>!s.disabled&&(He&&ct&&Wo(o,He,ct),!n0(be(),a)),se=(He,ct,We)=>X9e(He,i,{...l.mount?o:ed(ct)?a:Ix(He)?{[He]:ct}:ct},We,ct),te=He=>t_e(bn(l.mount?o:a,He,s.shouldUnregister?bn(a,He,[]):[])),Y=(He,ct,We={})=>{const Ze=bn(n,He);let ht=ct;if(Ze){const Ke=Ze._f;Ke&&(!Ke.disabled&&Wo(o,He,r$e(ct,Ke)),ht=une(Ke.ref)&&wh(ct)?"":ct,J9e(Ke.ref)?[...Ke.ref.options].forEach(qe=>qe.selected=ht.includes(qe.value)):Ke.refs?pL(Ke.ref)?Ke.refs.forEach(qe=>{(!qe.defaultChecked||!qe.disabled)&&(Array.isArray(ht)?qe.checked=!!ht.find(Je=>Je===qe.value):qe.checked=ht===qe.value||!!ht)}):Ke.refs.forEach(qe=>qe.checked=qe.value===ht):a_e(Ke.ref)?Ke.ref.value="":(Ke.ref.value=ht,Ke.ref.type||v.state.next({name:He,values:Td(o)})))}(We.shouldDirty||We.shouldTouch)&&L(He,ht,We.shouldTouch,We.shouldDirty,!0),We.shouldValidate&&xe(He)},ce=(He,ct,We)=>{for(const Ze in ct){if(!ct.hasOwnProperty(Ze))return;const ht=ct[Ze],Ke=He+"."+Ze,qe=bn(n,Ke);(i.array.has(He)||id(ht)||qe&&!qe._f)&&!_k(ht)?ce(Ke,ht,We):Y(Ke,ht,We)}},oe=(He,ct,We={})=>{const Ze=bn(n,He),ht=i.array.has(He),Ke=Td(ct);Wo(o,He,Ke),ht?(v.array.next({name:He,values:Td(o)}),(f.isDirty||f.dirtyFields||g.isDirty||g.dirtyFields)&&We.shouldDirty&&v.state.next({name:He,dirtyFields:BA(a,o),isDirty:Q(He,Ke)})):Ze&&!Ze._f&&!wh(Ke)?ce(He,Ke,We):Y(He,Ke,We),Z5e(He,i)&&v.state.next({...r,name:He}),v.state.next({name:l.mount?He:void 0,values:Td(o)})},le=async He=>{l.mount=!0;const ct=He.target;let We=ct.name,Ze=!0;const ht=bn(n,We),Ke=Lt=>{Ze=Number.isNaN(Lt)||_k(Lt)&&isNaN(Lt.getTime())||n0(Lt,bn(o,We,Lt))},qe=G5e(s.mode),Je=G5e(s.reValidateMode);if(ht){let Lt,zt;const is=ct.type?W5e(ht._f):K9e(He),Kt=He.type===dne.BLUR||He.type===dne.FOCUS_OUT,Qt=!Ubt(ht._f)&&!s.resolver&&!bn(r.errors,We)&&!ht._f.deps||Wbt(Kt,bn(r.touchedFields,We),r.isSubmitted,Je,qe),fs=Z5e(We,i,Kt);Wo(o,We,is),Kt?(ht._f.onBlur&&ht._f.onBlur(He),d&&d(0)):ht._f.onChange&&ht._f.onChange(He);const dr=L(We,is,Kt),bt=!dm(dr)||fs;if(!Kt&&v.state.next({name:We,type:He.type,values:Td(o)}),Qt)return(f.isValid||g.isValid)&&(s.mode==="onBlur"?Kt&&w():Kt||w()),bt&&v.state.next({name:We,...fs?{}:dr});if(!Kt&&fs&&v.state.next({...r}),s.resolver){const{errors:ws}=await $([We]);if(Ke(is),Ze){const ir=Y5e(r.errors,n,We),Rr=Y5e(ws,n,ir.name||We);Lt=Rr.error,We=Rr.name,zt=dm(ws)}}else j([We],!0),Lt=(await Q5e(ht,i.disabled,o,_,s.shouldUseNativeValidation))[We],j([We]),Ke(is),Ze&&(Lt?zt=!1:(f.isValid||g.isValid)&&(zt=await H(n,!0)));Ze&&(ht._f.deps&&xe(ht._f.deps),F(We,zt,Lt,dr))}},de=(He,ct)=>{if(bn(r.errors,ct)&&He.focus)return He.focus(),1},xe=async(He,ct={})=>{let We,Ze;const ht=EP(He);if(s.resolver){const Ke=await q(ed(He)?He:ht);We=dm(Ke),Ze=He?!ht.some(qe=>bn(Ke,qe)):We}else He?(Ze=(await Promise.all(ht.map(async Ke=>{const qe=bn(n,Ke);return await H(qe&&qe._f?{[Ke]:qe}:qe)}))).every(Boolean),!(!Ze&&!r.isValid)&&w()):Ze=We=await H(n);return v.state.next({...!Ix(He)||(f.isValid||g.isValid)&&We!==r.isValid?{}:{name:He},...s.resolver||!He?{isValid:We}:{},errors:r.errors}),ct.shouldFocus&&!Ze&&PP(n,de,He?ht:i.mount),Ze},be=He=>{const ct={...l.mount?o:a};return ed(He)?ct:Ix(He)?bn(ct,He):He.map(We=>bn(ct,We))},ye=(He,ct)=>({invalid:!!bn((ct||r).errors,He),isDirty:!!bn((ct||r).dirtyFields,He),error:bn((ct||r).errors,He),isValidating:!!bn(r.validatingFields,He),isTouched:!!bn((ct||r).touchedFields,He)}),ve=He=>{He&&EP(He).forEach(ct=>pd(r.errors,ct)),v.state.next({errors:He?r.errors:{}})},ke=(He,ct,We)=>{const Ze=(bn(n,He,{_f:{}})._f||{}).ref,ht=bn(r.errors,He)||{},{ref:Ke,message:qe,type:Je,...Lt}=ht;Wo(r.errors,He,{...Lt,...ct,ref:Ze}),v.state.next({name:He,errors:r.errors,isValid:!1}),We&&We.shouldFocus&&Ze&&Ze.focus&&Ze.focus()},Ge=(He,ct)=>vg(He)?v.state.subscribe({next:We=>"values"in We&&He(se(void 0,ct),We)}):se(He,ct,!0),Ne=He=>v.state.subscribe({next:ct=>{Hbt(He.name,ct.name,He.exact)&&Vbt(ct,He.formState||f,rt,He.reRenderRoot)&&He.callback({values:{...o},...r,...ct,defaultValues:a})}}).unsubscribe,Ae=He=>(l.mount=!0,g={...g,...He.formState},Ne({...He,formState:g})),Pe=(He,ct={})=>{for(const We of He?EP(He):i.mount)i.mount.delete(We),i.array.delete(We),ct.keepValue||(pd(n,We),pd(o,We)),!ct.keepError&&pd(r.errors,We),!ct.keepDirty&&pd(r.dirtyFields,We),!ct.keepTouched&&pd(r.touchedFields,We),!ct.keepIsValidating&&pd(r.validatingFields,We),!s.shouldUnregister&&!ct.keepDefaultValue&&pd(a,We);v.state.next({values:Td(o)}),v.state.next({...r,...ct.keepDirty?{isDirty:Q()}:{}}),!ct.keepIsValid&&w()},Fe=({disabled:He,name:ct})=>{(Jm(He)&&l.mount||He||i.disabled.has(ct))&&(He?i.disabled.add(ct):i.disabled.delete(ct))},Ie=(He,ct={})=>{let We=bn(n,He);const Ze=Jm(ct.disabled)||Jm(s.disabled);return Wo(n,He,{...We||{},_f:{...We&&We._f?We._f:{ref:{name:He}},name:He,mount:!0,...ct}}),i.mount.add(He),We?Fe({disabled:Jm(ct.disabled)?ct.disabled:s.disabled,name:He}):I(He,!0,ct.value),{...Ze?{disabled:ct.disabled||s.disabled}:{},...s.progressive?{required:!!ct.required,min:$A(ct.min),max:$A(ct.max),minLength:$A(ct.minLength),maxLength:$A(ct.maxLength),pattern:$A(ct.pattern)}:{},name:He,onChange:le,onBlur:le,ref:ht=>{if(ht){Ie(He,ct),We=bn(n,He);const Ke=ed(ht.value)&&ht.querySelectorAll&&ht.querySelectorAll("input,select,textarea")[0]||ht,qe=Fbt(Ke),Je=We._f.refs||[];if(qe?Je.find(Lt=>Lt===Ke):Ke===We._f.ref)return;Wo(n,He,{_f:{...We._f,...qe?{refs:[...Je.filter(Che),Ke,...Array.isArray(bn(a,He))?[{}]:[]],ref:{type:Ke.type,name:He}}:{ref:Ke}}}),I(He,!1,void 0,Ke)}else We=bn(n,He,{}),We._f&&(We._f.mount=!1),(s.shouldUnregister||ct.shouldUnregister)&&!(Z9e(i.array,He)&&l.action)&&i.unMount.add(He)}}},Ve=()=>s.shouldFocusError&&PP(n,de,i.mount),dt=He=>{Jm(He)&&(v.state.next({disabled:He}),PP(n,(ct,We)=>{const Ze=bn(n,We);Ze&&(ct.disabled=Ze._f.disabled||He,Array.isArray(Ze._f.refs)&&Ze._f.refs.forEach(ht=>{ht.disabled=Ze._f.disabled||He}))},0,!1))},Le=(He,ct)=>async We=>{let Ze;We&&(We.preventDefault&&We.preventDefault(),We.persist&&We.persist());let ht=Td(o);if(v.state.next({isSubmitting:!0}),s.resolver){const{errors:Ke,values:qe}=await $();r.errors=Ke,ht=Td(qe)}else await H(n);if(i.disabled.size)for(const Ke of i.disabled)pd(ht,Ke);if(pd(r.errors,"root"),dm(r.errors)){v.state.next({errors:{}});try{await He(ht,We)}catch(Ke){Ze=Ke}}else ct&&await ct({...r.errors},We),Ve(),setTimeout(Ve);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:dm(r.errors)&&!Ze,submitCount:r.submitCount+1,errors:r.errors}),Ze)throw Ze},Rt=(He,ct={})=>{bn(n,He)&&(ed(ct.defaultValue)?oe(He,Td(bn(a,He))):(oe(He,ct.defaultValue),Wo(a,He,Td(ct.defaultValue))),ct.keepTouched||pd(r.touchedFields,He),ct.keepDirty||(pd(r.dirtyFields,He),r.isDirty=ct.defaultValue?Q(He,Td(bn(a,He))):Q()),ct.keepError||(pd(r.errors,He),f.isValid&&w()),v.state.next({...r}))},fe=(He,ct={})=>{const We=He?Td(He):a,Ze=Td(We),ht=dm(He),Ke=ht?a:Ze;if(ct.keepDefaultValues||(a=We),!ct.keepValues){if(ct.keepDirtyValues){const qe=new Set([...i.mount,...Object.keys(BA(a,o))]);for(const Je of Array.from(qe))bn(r.dirtyFields,Je)?Wo(Ke,Je,bn(o,Je)):oe(Je,bn(Ke,Je))}else{if(e_e&&ed(He))for(const qe of i.mount){const Je=bn(n,qe);if(Je&&Je._f){const Lt=Array.isArray(Je._f.refs)?Je._f.refs[0]:Je._f.ref;if(une(Lt)){const zt=Lt.closest("form");if(zt){zt.reset();break}}}}if(ct.keepFieldsRef)for(const qe of i.mount)oe(qe,bn(Ke,qe));else n={}}o=s.shouldUnregister?ct.keepDefaultValues?Td(a):{}:Td(Ke),v.array.next({values:{...Ke}}),v.state.next({values:{...Ke}})}i={mount:ct.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!f.isValid||!!ct.keepIsValid||!!ct.keepDirtyValues,l.watch=!!s.shouldUnregister,v.state.next({submitCount:ct.keepSubmitCount?r.submitCount:0,isDirty:ht?!1:ct.keepDirty?r.isDirty:!!(ct.keepDefaultValues&&!n0(He,a)),isSubmitted:ct.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:ht?{}:ct.keepDirtyValues?ct.keepDefaultValues&&o?BA(a,o):r.dirtyFields:ct.keepDefaultValues&&He?BA(a,He):ct.keepDirty?r.dirtyFields:{},touchedFields:ct.keepTouched?r.touchedFields:{},errors:ct.keepErrors?r.errors:{},isSubmitSuccessful:ct.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Qe=(He,ct)=>fe(vg(He)?He(o):He,ct),at=(He,ct={})=>{const We=bn(n,He),Ze=We&&We._f;if(Ze){const ht=Ze.refs?Ze.refs[0]:Ze.ref;ht.focus&&(ht.focus(),ct.shouldSelect&&vg(ht.select)&&ht.select())}},rt=He=>{r={...r,...He}},mt={control:{register:Ie,unregister:Pe,getFieldState:ye,handleSubmit:Le,setError:ke,_subscribe:Ne,_runSchema:$,_focusError:Ve,_getWatch:se,_getDirty:Q,_setValid:w,_setFieldArray:N,_setDisabledField:Fe,_setErrors:A,_getFieldArray:te,_reset:fe,_resetDefaultValues:()=>vg(s.defaultValues)&&s.defaultValues().then(He=>{Qe(He,s.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:U,_disableForm:dt,_subjects:v,_proxyFormState:f,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(He){l=He},get _defaultValues(){return a},get _names(){return i},set _names(He){i=He},get _formState(){return r},get _options(){return s},set _options(He){s={...s,...He}}},subscribe:Ae,trigger:xe,register:Ie,handleSubmit:Le,watch:Ge,setValue:oe,getValues:be,reset:Qe,resetField:Rt,clearErrors:ve,unregister:Pe,setError:ke,setFocus:at,getFieldState:ye};return{...mt,formControl:mt}}function Soe(t={}){const s=ut.useRef(void 0),r=ut.useRef(void 0),[n,a]=ut.useState({isDirty:!1,isValidating:!1,isLoading:vg(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:vg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!vg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=Ybt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,n_e(()=>{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]),ut.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),ut.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),ut.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),ut.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),ut.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),ut.useEffect(()=>{t.values&&!n0(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]),ut.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=Y9e(n,o),s.current}const J5e=(t,s,r)=>{if(t&&"reportValidity"in t){const n=bn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},a$e=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?J5e(n.ref,r,t):n.refs&&n.refs.forEach(a=>J5e(a,r,t))}},Xbt=(t,s)=>{s.shouldUseNativeValidation&&a$e(t,s);const r={};for(const n in t){const a=bn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(Qbt(s.names||Object.keys(t),n)){const l=Object.assign({},bn(r,n));Wo(l,"root",o),Wo(r,n,l)}else Wo(r,n,o)}return r},Qbt=(t,s)=>t.some(r=>r.startsWith(s+"."));var Jbt=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(f){return f.errors.forEach(function(g){return t.push(g)})}),s){var d=r[l].types,u=d&&d[n.code];r[l]=Q9e(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},Coe=function(t,s,r){return r===void 0&&(r={}),function(n,a,o){try{return Promise.resolve(function(l,i){try{var d=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(u){return o.shouldUseNativeValidation&&a$e({},o),{errors:{},values:r.raw?n:u}})}catch(u){return i(u)}return d&&d.then?d.then(void 0,i):d}(0,function(l){if(function(i){return Array.isArray(i==null?void 0:i.errors)}(l))return{values:{},errors:Xbt(Jbt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Moe=Ibt,i$e=M.createContext({}),yc=({...t})=>e.jsx(i$e.Provider,{value:{name:t.name},children:e.jsx(Rbt,{...t})}),Toe=()=>{const t=M.useContext(i$e),s=M.useContext(o$e),{getFieldState:r,formState:n}=Noe(),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}},o$e=M.createContext({}),ic=M.forwardRef(({className:t,...s},r)=>{const n=M.useId();return e.jsx(o$e.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:It("space-y-2",t),...s})})});ic.displayName="FormItem";const oc=M.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=Toe();return e.jsx(_e,{ref:r,className:It(n&&"text-destructive",t),htmlFor:a,...s})});oc.displayName="FormLabel";const lc=M.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=Toe();return e.jsx(Dve,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});lc.displayName="FormControl";const Kse=M.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=Toe();return e.jsx("p",{ref:r,id:n,className:It("text-sm text-muted-foreground",t),...s})});Kse.displayName="FormDescription";const Nh=M.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=Toe(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:It("text-sm font-medium text-destructive",t),...r,children:l}):null});Nh.displayName="FormMessage";const Lr=M.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:It("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...s}));Lr.displayName="Textarea";const ewt=O_({category:j9e(["general","technology","crm","marketing"]),subject:Ko().min(5,"Subject must be at least 5 characters").max(200),description:Ko().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),twt={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Ege({trigger:t}){const[s,r]=M.useState(!1),[n,a]=M.useState(!1),{user:o}=Qs(),l=Soe({resolver:Coe(ewt),defaultValues:{category:"general",subject:"",description:""}}),i=async d=>{if(!o){ge.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:u}=await K.from("support_tickets").insert({user_id:o.id,category:d.category,subject:d.subject,description:d.description});if(u)throw u;try{await K.functions.invoke("support-ticket-notify",{body:{category:twt[d.category],subject:d.subject}})}catch(f){console.log("Notification send attempted:",f)}ge.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),ge.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(bs,{open:s,onOpenChange:r,children:[e.jsx(Si,{asChild:!0,children:t||e.jsxs(Z,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(eP,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(_s,{className:"sm:max-w-[500px]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Need Help?"}),e.jsx(Kr,{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(ga,{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(Moe,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(yc,{control:l.control,name:"category",render:({field:d})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Category"}),e.jsxs(tr,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx(lc,{children:e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select a category"})})}),e.jsxs(er,{children:[e.jsx(At,{value:"general",children:"General Support"}),e.jsx(At,{value:"technology",children:"Technology Support"}),e.jsx(At,{value:"crm",children:"CRM Support"}),e.jsx(At,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(Nh,{})]})}),e.jsx(yc,{control:l.control,name:"subject",render:({field:d})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Subject"}),e.jsx(lc,{children:e.jsx(Re,{placeholder:"Brief description of your issue",...d})}),e.jsx(Nh,{})]})}),e.jsx(yc,{control:l.control,name:"description",render:({field:d})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Description"}),e.jsx(lc,{children:e.jsx(Lr,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),e.jsx(Nh,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const swt=()=>{const{user:t}=Qs(),s=Or(),[r,n]=M.useState([]),[a,o]=M.useState(0),[l,i]=M.useState(!1),[d,u]=M.useState(null);M.useEffect(()=>{if(!t)return;const b=`notification_last_read_${t.id}`;let w=d;if(!w){const S=localStorage.getItem(b);S&&(w=S,u(S))}(async()=>{const{data:S,error:A}=await K.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!A&&S){n(S);const I=w?new Date(w):null,L=S.filter(F=>I?new Date(F.created_at)>I:!0);o(L.length)}})();const N=K.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},S=>{const A=S.new;n(L=>[A,...L].slice(0,20));const I=w?new Date(w):null;(!I||new Date(A.created_at)>I)&&o(L=>L+1),Notification.permission==="granted"&&new Notification(A.title,{body:A.body,icon:"/favicon.ico"})}).subscribe();return()=>{K.removeChannel(N)}},[t,d]);const f=b=>{const w=b.toLowerCase();return w.includes("community")||w.includes("post")?ho:w.includes("academy")||w.includes("video")?Cn:w.includes("template")?El:w.includes("event")?nn:w.includes("newsletter")?j0:w.includes("brokerage")?Zu:w.includes("swag")||w.includes("social")?uo:w.includes("toolbox")||w.includes("tool")?Vx:w.includes("brief")?gn:ho},g=b=>{i(!1),b.url&&b.url!=="/"&&s(b.url)},v=()=>{if(!t)return;const b=new Date().toISOString(),w=`notification_last_read_${t.id}`;localStorage.setItem(w,b),u(b),o(0)},_=b=>{i(b),b&&a>0&&v()};return e.jsxs(Du,{open:l,onOpenChange:_,children:[e.jsx(Ou,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(af,{className:"h-5 w-5"}),a>0&&e.jsx(nt,{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(mu,{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(Z,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:v,children:"Mark all read"})]}),e.jsx(Fi,{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(b=>{const w=f(b.title);return e.jsxs(Wa,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>g(b),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(w,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:b.title}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:b.body}),e.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:$d(new Date(b.created_at),{addSuffix:!0})})]})]},b.id)})})]})]})};var e3e=1,rwt=.9,nwt=.8,awt=.17,Mhe=.1,The=.999,iwt=.9999,owt=.99,lwt=/[\\\/_+.#"@\[\(\{&]/,cwt=/[\\\/_+.#"@\[\(\{&]/g,dwt=/[\s-]/,l$e=/[\s-]/g;function Pge(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?e3e:owt;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var d=n.charAt(o),u=r.indexOf(d,a),f=0,g,v,_,b;u>=0;)g=Pge(t,s,r,n,u+1,o+1,l),g>f&&(u===a?g*=e3e:lwt.test(t.charAt(u-1))?(g*=nwt,_=t.slice(a,u-1).match(cwt),_&&a>0&&(g*=Math.pow(The,_.length))):dwt.test(t.charAt(u-1))?(g*=rwt,b=t.slice(a,u-1).match(l$e),b&&a>0&&(g*=Math.pow(The,b.length))):(g*=awt,a>0&&(g*=Math.pow(The,u-a))),t.charAt(u)!==s.charAt(o)&&(g*=iwt)),(gg&&(g=v*Mhe)),g>f&&(f=g),u=r.indexOf(d,u+1);return l[i]=f,f}function t3e(t){return t.toLowerCase().replace(l$e," ")}function uwt(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,Pge(t,s,t3e(t),t3e(s),0,0,{})}var qA='[cmdk-group=""]',Ahe='[cmdk-group-items=""]',hwt='[cmdk-group-heading=""]',c$e='[cmdk-item=""]',s3e=`${c$e}:not([aria-disabled="true"])`,Ige="cmdk-item-select",c4="data-value",mwt=(t,s,r)=>uwt(t,s,r),d$e=M.createContext(void 0),fL=()=>M.useContext(d$e),u$e=M.createContext(void 0),o_e=()=>M.useContext(u$e),h$e=M.createContext(void 0),m$e=M.forwardRef((t,s)=>{let r=d4(()=>{var ve,ke;return{search:"",value:(ke=(ve=t.value)!=null?ve:t.defaultValue)!=null?ke:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=d4(()=>new Set),a=d4(()=>new Map),o=d4(()=>new Map),l=d4(()=>new Set),i=p$e(t),{label:d,children:u,value:f,onValueChange:g,filter:v,shouldFilter:_,loop:b,disablePointerSelection:w=!1,vimBindings:j=!0,...N}=t,S=Bd(),A=Bd(),I=Bd(),L=M.useRef(null),F=kwt();MN(()=>{if(f!==void 0){let ve=f.trim();r.current.value=ve,$.emit()}},[f]),MN(()=>{F(6,te)},[]);let $=M.useMemo(()=>({subscribe:ve=>(l.current.add(ve),()=>l.current.delete(ve)),snapshot:()=>r.current,setState:(ve,ke,Ge)=>{var Ne,Ae,Pe,Fe;if(!Object.is(r.current[ve],ke)){if(r.current[ve]=ke,ve==="search")se(),U(),F(1,Q);else if(ve==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ie=document.getElementById(I);Ie?Ie.focus():(Ne=document.getElementById(S))==null||Ne.focus()}if(F(7,()=>{var Ie;r.current.selectedItemId=(Ie=Y())==null?void 0:Ie.id,$.emit()}),Ge||F(5,te),((Ae=i.current)==null?void 0:Ae.value)!==void 0){let Ie=ke??"";(Fe=(Pe=i.current).onValueChange)==null||Fe.call(Pe,Ie);return}}$.emit()}},emit:()=>{l.current.forEach(ve=>ve())}}),[]),q=M.useMemo(()=>({value:(ve,ke,Ge)=>{var Ne;ke!==((Ne=o.current.get(ve))==null?void 0:Ne.value)&&(o.current.set(ve,{value:ke,keywords:Ge}),r.current.filtered.items.set(ve,H(ke,Ge)),F(2,()=>{U(),$.emit()}))},item:(ve,ke)=>(n.current.add(ve),ke&&(a.current.has(ke)?a.current.get(ke).add(ve):a.current.set(ke,new Set([ve]))),F(3,()=>{se(),U(),r.current.value||Q(),$.emit()}),()=>{o.current.delete(ve),n.current.delete(ve),r.current.filtered.items.delete(ve);let Ge=Y();F(4,()=>{se(),(Ge==null?void 0:Ge.getAttribute("id"))===ve&&Q(),$.emit()})}),group:ve=>(a.current.has(ve)||a.current.set(ve,new Set),()=>{o.current.delete(ve),a.current.delete(ve)}),filter:()=>i.current.shouldFilter,label:d||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:I,labelId:A,listInnerRef:L}),[]);function H(ve,ke){var Ge,Ne;let Ae=(Ne=(Ge=i.current)==null?void 0:Ge.filter)!=null?Ne:mwt;return ve?Ae(ve,r.current.search,ke):0}function U(){if(!r.current.search||i.current.shouldFilter===!1)return;let ve=r.current.filtered.items,ke=[];r.current.filtered.groups.forEach(Ne=>{let Ae=a.current.get(Ne),Pe=0;Ae.forEach(Fe=>{let Ie=ve.get(Fe);Pe=Math.max(Ie,Pe)}),ke.push([Ne,Pe])});let Ge=L.current;ce().sort((Ne,Ae)=>{var Pe,Fe;let Ie=Ne.getAttribute("id"),Ve=Ae.getAttribute("id");return((Pe=ve.get(Ve))!=null?Pe:0)-((Fe=ve.get(Ie))!=null?Fe:0)}).forEach(Ne=>{let Ae=Ne.closest(Ahe);Ae?Ae.appendChild(Ne.parentElement===Ae?Ne:Ne.closest(`${Ahe} > *`)):Ge.appendChild(Ne.parentElement===Ge?Ne:Ne.closest(`${Ahe} > *`))}),ke.sort((Ne,Ae)=>Ae[1]-Ne[1]).forEach(Ne=>{var Ae;let Pe=(Ae=L.current)==null?void 0:Ae.querySelector(`${qA}[${c4}="${encodeURIComponent(Ne[0])}"]`);Pe==null||Pe.parentElement.appendChild(Pe)})}function Q(){let ve=ce().find(Ge=>Ge.getAttribute("aria-disabled")!=="true"),ke=ve==null?void 0:ve.getAttribute(c4);$.setState("value",ke||void 0)}function se(){var ve,ke,Ge,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 Pe of n.current){let Fe=(ke=(ve=o.current.get(Pe))==null?void 0:ve.value)!=null?ke:"",Ie=(Ne=(Ge=o.current.get(Pe))==null?void 0:Ge.keywords)!=null?Ne:[],Ve=H(Fe,Ie);r.current.filtered.items.set(Pe,Ve),Ve>0&&Ae++}for(let[Pe,Fe]of a.current)for(let Ie of Fe)if(r.current.filtered.items.get(Ie)>0){r.current.filtered.groups.add(Pe);break}r.current.filtered.count=Ae}function te(){var ve,ke,Ge;let Ne=Y();Ne&&(((ve=Ne.parentElement)==null?void 0:ve.firstChild)===Ne&&((Ge=(ke=Ne.closest(qA))==null?void 0:ke.querySelector(hwt))==null||Ge.scrollIntoView({block:"nearest"})),Ne.scrollIntoView({block:"nearest"}))}function Y(){var ve;return(ve=L.current)==null?void 0:ve.querySelector(`${c$e}[aria-selected="true"]`)}function ce(){var ve;return Array.from(((ve=L.current)==null?void 0:ve.querySelectorAll(s3e))||[])}function oe(ve){let ke=ce()[ve];ke&&$.setState("value",ke.getAttribute(c4))}function le(ve){var ke;let Ge=Y(),Ne=ce(),Ae=Ne.findIndex(Fe=>Fe===Ge),Pe=Ne[Ae+ve];(ke=i.current)!=null&&ke.loop&&(Pe=Ae+ve<0?Ne[Ne.length-1]:Ae+ve===Ne.length?Ne[0]:Ne[Ae+ve]),Pe&&$.setState("value",Pe.getAttribute(c4))}function de(ve){let ke=Y(),Ge=ke==null?void 0:ke.closest(qA),Ne;for(;Ge&&!Ne;)Ge=ve>0?wwt(Ge,qA):jwt(Ge,qA),Ne=Ge==null?void 0:Ge.querySelector(s3e);Ne?$.setState("value",Ne.getAttribute(c4)):le(ve)}let xe=()=>oe(ce().length-1),be=ve=>{ve.preventDefault(),ve.metaKey?xe():ve.altKey?de(1):le(1)},ye=ve=>{ve.preventDefault(),ve.metaKey?oe(0):ve.altKey?de(-1):le(-1)};return M.createElement(Qr.div,{ref:s,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:ve=>{var ke;(ke=N.onKeyDown)==null||ke.call(N,ve);let Ge=ve.nativeEvent.isComposing||ve.keyCode===229;if(!(ve.defaultPrevented||Ge))switch(ve.key){case"n":case"j":{j&&ve.ctrlKey&&be(ve);break}case"ArrowDown":{be(ve);break}case"p":case"k":{j&&ve.ctrlKey&&ye(ve);break}case"ArrowUp":{ye(ve);break}case"Home":{ve.preventDefault(),oe(0);break}case"End":{ve.preventDefault(),xe();break}case"Enter":{ve.preventDefault();let Ne=Y();if(Ne){let Ae=new Event(Ige);Ne.dispatchEvent(Ae)}}}}},M.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:Swt},d),Aoe(t,ve=>M.createElement(u$e.Provider,{value:$},M.createElement(d$e.Provider,{value:q},ve))))}),pwt=M.forwardRef((t,s)=>{var r,n;let a=Bd(),o=M.useRef(null),l=M.useContext(h$e),i=fL(),d=p$e(t),u=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;MN(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let f=f$e(a,o,[t.value,t.children,o],t.keywords),g=o_e(),v=__(F=>F.value&&F.value===f.current),_=__(F=>u||i.filter()===!1?!0:F.search?F.filtered.items.get(a)>0:!0);M.useEffect(()=>{let F=o.current;if(!(!F||t.disabled))return F.addEventListener(Ige,b),()=>F.removeEventListener(Ige,b)},[_,t.onSelect,t.disabled]);function b(){var F,$;w(),($=(F=d.current).onSelect)==null||$.call(F,f.current)}function w(){g.setState("value",f.current,!0)}if(!_)return null;let{disabled:j,value:N,onSelect:S,forceMount:A,keywords:I,...L}=t;return M.createElement(Qr.div,{ref:O0(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!v,"data-disabled":!!j,"data-selected":!!v,onPointerMove:j||i.getDisablePointerSelection()?void 0:w,onClick:j?void 0:b},t.children)}),fwt=M.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Bd(),i=M.useRef(null),d=M.useRef(null),u=Bd(),f=fL(),g=__(_=>a||f.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);MN(()=>f.group(l),[]),f$e(l,i,[t.value,t.heading,d]);let v=M.useMemo(()=>({id:l,forceMount:a}),[a]);return M.createElement(Qr.div,{ref:O0(i,s),...o,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},r&&M.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),Aoe(t,_=>M.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},M.createElement(h$e.Provider,{value:v},_))))}),gwt=M.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=M.useRef(null),o=__(l=>!l.search);return!r&&!o?null:M.createElement(Qr.div,{ref:O0(a,s),...n,"cmdk-separator":"",role:"separator"})}),xwt=M.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=o_e(),l=__(u=>u.search),i=__(u=>u.selectedItemId),d=fL();return M.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),M.createElement(Qr.input,{ref:s,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":i,id:d.inputId,type:"text",value:a?t.value:l,onChange:u=>{a||o.setState("search",u.target.value),r==null||r(u.target.value)}})}),ywt=M.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=M.useRef(null),l=M.useRef(null),i=__(u=>u.selectedItemId),d=fL();return M.useEffect(()=>{if(l.current&&o.current){let u=l.current,f=o.current,g,v=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let _=u.offsetHeight;f.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return v.observe(u),()=>{cancelAnimationFrame(g),v.unobserve(u)}}},[]),M.createElement(Qr.div,{ref:O0(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},Aoe(t,u=>M.createElement("div",{ref:O0(l,d.listInnerRef),"cmdk-list-sizer":""},u)))}),vwt=M.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return M.createElement(ioe,{open:r,onOpenChange:n},M.createElement(ooe,{container:l},M.createElement(aM,{"cmdk-overlay":"",className:a}),M.createElement(iM,{"aria-label":t.label,"cmdk-dialog":"",className:o},M.createElement(m$e,{ref:s,...i}))))}),_wt=M.forwardRef((t,s)=>__(r=>r.filtered.count===0)?M.createElement(Qr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),bwt=M.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return M.createElement(Qr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Aoe(t,l=>M.createElement("div",{"aria-hidden":!0},l)))}),Pm=Object.assign(m$e,{List:ywt,Item:pwt,Input:xwt,Group:fwt,Separator:gwt,Dialog:vwt,Empty:_wt,Loading:bwt});function wwt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function jwt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function p$e(t){let s=M.useRef(t);return MN(()=>{s.current=t}),s}var MN=typeof window>"u"?M.useEffect:M.useLayoutEffect;function d4(t){let s=M.useRef();return s.current===void 0&&(s.current=t()),s}function __(t){let s=o_e(),r=()=>t(s.snapshot());return M.useSyncExternalStore(s.subscribe,r,r)}function f$e(t,s,r,n=[]){let a=M.useRef(),o=fL();return MN(()=>{var l;let i=(()=>{var u;for(let f of r){if(typeof f=="string")return f.trim();if(typeof f=="object"&&"current"in f)return f.current?(u=f.current.textContent)==null?void 0:u.trim():a.current}})(),d=n.map(u=>u.trim());o.value(t,i,d),(l=s.current)==null||l.setAttribute(c4,i),a.current=i}),a}var kwt=()=>{let[t,s]=M.useState(),r=d4(()=>new Map);return MN(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function Nwt(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Aoe({asChild:t,children:s},r){return t&&M.isValidElement(s)?M.cloneElement(Nwt(s),{ref:s.ref},r(s.props.children)):r(s)}var Swt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const gf=M.forwardRef(({className:t,...s},r)=>e.jsx(Pm,{ref:r,className:It("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));gf.displayName=Pm.displayName;const Cwt=({children:t,...s})=>e.jsx(bs,{...s,children:e.jsx(_s,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(gf,{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})})}),xf=M.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(xn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Pm.Input,{ref:r,className:It("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));xf.displayName=Pm.Input.displayName;const yf=M.forwardRef(({className:t,...s},r)=>e.jsx(Pm.List,{ref:r,className:It("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));yf.displayName=Pm.List.displayName;const vf=M.forwardRef((t,s)=>e.jsx(Pm.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));vf.displayName=Pm.Empty.displayName;const _f=M.forwardRef(({className:t,...s},r)=>e.jsx(Pm.Group,{ref:r,className:It("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));_f.displayName=Pm.Group.displayName;const Mwt=M.forwardRef(({className:t,...s},r)=>e.jsx(Pm.Separator,{ref:r,className:It("-mx-1 h-px bg-border",t),...s}));Mwt.displayName=Pm.Separator.displayName;const _m=M.forwardRef(({className:t,...s},r)=>e.jsx(Pm.Item,{ref:r,className:It("group relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-primary/80 data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50",t),...s}));_m.displayName=Pm.Item.displayName;const Twt={event:{label:"Events",icon:jc,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:El,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Yu,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Vx,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:gn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},r3e=()=>{const[t,s]=M.useState(!1),[r,n]=M.useState(""),[a,o]=M.useState([]),[l,i]=M.useState(!1),d=Or();M.useEffect(()=>{const v=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[]);const u=M.useCallback(async v=>{if(!v.trim()){o([]);return}i(!0);const _=`%${v}%`;try{const[b,w,j,N,S]=await Promise.all([K.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),K.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${_},description.ilike.${_}`).limit(5),K.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),K.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${_},description.ilike.${_}`).limit(5),K.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5)]),A=[];b.data&&b.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"event",date:I.event_date,path:`/event/${I.id}`})}),w.data&&w.data.forEach(I=>{A.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),j.data&&j.data.forEach(I=>{A.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=>{A.push({id:I.id,title:I.name,description:I.description,type:"toolbox",date:I.publish_date,path:`/toolbox/${I.id}`})}),S.data&&S.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"social-swag",date:I.publish_date,path:`/social-swag/${I.id}`})}),o(A)}catch(b){console.error("Search error:",b)}finally{i(!1)}},[]);M.useEffect(()=>{const v=setTimeout(()=>{u(r)},300);return()=>clearTimeout(v)},[r,u]);const f=v=>{s(!1),n(""),d(v)},g=a.reduce((v,_)=>(v[_.type]||(v[_.type]=[]),v[_.type].push(_),v),{});return e.jsxs(e.Fragment,{children:[e.jsxs(Z,{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(xn,{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(Cwt,{open:t,onOpenChange:s,children:[e.jsx(xf,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(yf,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(vf,{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(g).map(([v,_])=>{const b=Twt[v],w=b.icon;return e.jsx(_f,{heading:b.label,children:_.map(j=>e.jsxs(_m,{value:`${j.type}-${j.id}-${j.title}`,onSelect:()=>f(j.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${b.color}`,children:e.jsx(w,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:j.title}),j.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:j.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(nt,{variant:"secondary",className:"text-xs",children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:$d(new Date(j.date),{addSuffix:!0})})]})]},`${j.type}-${j.id}`))},v)})]})]})]})},Awt=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=M.useState(null),o=Or();if(M.useEffect(()=>{const u=()=>{const g=new Date().getTime(),_=new Date(t).getTime()-g;if(_<=0){a({days:0,hours:0,minutes:0});return}const b=Math.floor(_/(1e3*60*60*24)),w=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),j=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:b,hours:w,minutes:j})};u();const f=setInterval(u,6e4);return()=>clearInterval(f)},[t]),!n)return null;const l=n.days===0&&n.hours===0&&n.minutes===0,i=n.days<=1,d=n.days<=3&&!i;return l?e.jsxs("div",{className:It("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jh,{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(Z,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(gn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:It("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":d?"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(Tn,{className:It("h-4 w-4",i?"text-destructive":d?"text-amber-500":"text-primary")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:It("text-sm font-medium",i?"text-destructive":d?"text-amber-600":"text-primary"),children:"Free Trial:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:It("text-xs",i?"text-destructive/70":d?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(Z,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":d?"default":"outline",className:It("text-xs h-7 px-3",d&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(gn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},Ewt=()=>{const t=Or();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(De,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs($t,{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(jh,{className:"h-8 w-8 text-destructive"})}),e.jsx(Vt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(_r,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(De,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(xr,{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(Z,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(gn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(De,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(_a,{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(Z,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(_a,{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(ga,{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(Ar,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},Pwt=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"icon",onClick:s,className:It("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(Ag,{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(au,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var Eoe="Checkbox",[Iwt]=Cc(Eoe),[Lwt,l_e]=Iwt(Eoe);function Dwt(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:d,required:u,value:f="on",internal_do_not_use_render:g}=t,[v,_]=uu({prop:r,defaultProp:a??!1,onChange:d,caller:Eoe}),[b,w]=M.useState(null),[j,N]=M.useState(null),S=M.useRef(!1),A=b?!!l||!!b.closest("form"):!0,I={checked:v,disabled:o,setChecked:_,control:b,setControl:w,name:i,form:l,value:f,hasConsumerStoppedPropagationRef:S,required:u,defaultChecked:r_(a)?!1:a,isFormControl:A,bubbleInput:j,setBubbleInput:N};return e.jsx(Lwt,{scope:s,...I,children:Owt(g)?g(I):n})}var g$e="CheckboxTrigger",x$e=M.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:u,setControl:f,setChecked:g,hasConsumerStoppedPropagationRef:v,isFormControl:_,bubbleInput:b}=l_e(g$e,t),w=Sa(a,f),j=M.useRef(d);return M.useEffect(()=>{const N=o==null?void 0:o.form;if(N){const S=()=>g(j.current);return N.addEventListener("reset",S),()=>N.removeEventListener("reset",S)}},[o,g]),e.jsx(Qr.button,{type:"button",role:"checkbox","aria-checked":r_(d)?"mixed":d,"aria-required":u,"data-state":w$e(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:w,onKeyDown:Sr(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Sr(r,N=>{g(S=>r_(S)?!0:!S),b&&_&&(v.current=N.isPropagationStopped(),v.current||N.stopPropagation())})})});x$e.displayName=g$e;var c_e=M.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:u,form:f,...g}=t;return e.jsx(Dwt,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:f,value:d,internal_do_not_use_render:({isFormControl:v})=>e.jsxs(e.Fragment,{children:[e.jsx(x$e,{...g,ref:s,__scopeCheckbox:r}),v&&e.jsx(b$e,{__scopeCheckbox:r})]})})});c_e.displayName=Eoe;var y$e="CheckboxIndicator",v$e=M.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=l_e(y$e,r);return e.jsx(od,{present:n||r_(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{"data-state":w$e(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});v$e.displayName=y$e;var _$e="CheckboxBubbleInput",b$e=M.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:u,value:f,form:g,bubbleInput:v,setBubbleInput:_}=l_e(_$e,t),b=Sa(r,_),w=lL(o),j=Z6(n);M.useEffect(()=>{const S=v;if(!S)return;const A=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(A,"checked").set,F=!a.current;if(w!==o&&L){const $=new Event("click",{bubbles:F});S.indeterminate=r_(o),L.call(S,r_(o)?!1:o),S.dispatchEvent($)}},[v,w,o,a]);const N=M.useRef(r_(o)?!1:o);return e.jsx(Qr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??N.current,required:i,disabled:d,name:u,value:f,form:g,...s,tabIndex:-1,ref:b,style:{...s.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});b$e.displayName=_$e;function Owt(t){return typeof t=="function"}function r_(t){return t==="indeterminate"}function w$e(t){return r_(t)?"indeterminate":t?"checked":"unchecked"}const $o=M.forwardRef(({className:t,...s},r)=>e.jsx(c_e,{ref:r,className:It("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(v$e,{className:It("flex items-center justify-center text-current"),children:e.jsx(ma,{className:"h-4 w-4"})})}));$o.displayName=c_e.displayName;var d_e="Radio",[Rwt,j$e]=Cc(d_e),[Fwt,zwt]=Rwt(d_e),k$e=M.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:u,...f}=t,[g,v]=M.useState(null),_=Sa(s,j=>v(j)),b=M.useRef(!1),w=g?u||!!g.closest("form"):!0;return e.jsxs(Fwt,{scope:r,checked:a,disabled:l,children:[e.jsx(Qr.button,{type:"button",role:"radio","aria-checked":a,"data-state":M$e(a),"data-disabled":l?"":void 0,disabled:l,value:i,...f,ref:_,onClick:Sr(t.onClick,j=>{a||d==null||d(),w&&(b.current=j.isPropagationStopped(),b.current||j.stopPropagation())})}),w&&e.jsx(C$e,{control:g,bubbles:!b.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});k$e.displayName=d_e;var N$e="RadioIndicator",S$e=M.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=zwt(N$e,r);return e.jsx(od,{present:n||o.checked,children:e.jsx(Qr.span,{"data-state":M$e(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});S$e.displayName=N$e;var Bwt="RadioBubbleInput",C$e=M.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=M.useRef(null),i=Sa(l,o),d=lL(r),u=Z6(s);return M.useEffect(()=>{const f=l.current;if(!f)return;const g=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(g,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(f,r),f.dispatchEvent(b)}},[d,r,n]),e.jsx(Qr.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}})});C$e.displayName=Bwt;function M$e(t){return t?"checked":"unchecked"}var $wt=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Poe="RadioGroup",[qwt]=Cc(Poe,[P_,j$e]),T$e=P_(),A$e=j$e(),[Uwt,Vwt]=qwt(Poe),E$e=M.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:d,dir:u,loop:f=!0,onValueChange:g,...v}=t,_=T$e(r),b=E_(u),[w,j]=uu({prop:o,defaultProp:a??null,onChange:g,caller:Poe});return e.jsx(Uwt,{scope:r,name:n,required:l,disabled:i,value:w,onValueChange:j,children:e.jsx(Qie,{asChild:!0,..._,orientation:d,dir:b,loop:f,children:e.jsx(Qr.div,{role:"radiogroup","aria-required":l,"aria-orientation":d,"data-disabled":i?"":void 0,dir:b,...v,ref:s})})})});E$e.displayName=Poe;var P$e="RadioGroupItem",I$e=M.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=Vwt(P$e,r),l=o.disabled||n,i=T$e(r),d=A$e(r),u=M.useRef(null),f=Sa(s,u),g=o.value===a.value,v=M.useRef(!1);return M.useEffect(()=>{const _=w=>{$wt.includes(w.key)&&(v.current=!0)},b=()=>v.current=!1;return document.addEventListener("keydown",_),document.addEventListener("keyup",b),()=>{document.removeEventListener("keydown",_),document.removeEventListener("keyup",b)}},[]),e.jsx(Jie,{asChild:!0,...i,focusable:!l,active:g,children:e.jsx(k$e,{disabled:l,required:o.required,checked:g,...d,...a,name:o.name,ref:f,onCheck:()=>o.onValueChange(a.value),onKeyDown:Sr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Sr(a.onFocus,()=>{var _;v.current&&((_=u.current)==null||_.click())})})})});I$e.displayName=P$e;var Hwt="RadioGroupIndicator",L$e=M.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=A$e(r);return e.jsx(S$e,{...a,...n,ref:s})});L$e.displayName=Hwt;var D$e=E$e,O$e=I$e,Wwt=L$e;const u_e=M.forwardRef(({className:t,...s},r)=>e.jsx(D$e,{className:It("grid gap-2",t),...s,ref:r}));u_e.displayName=D$e.displayName;const pne=M.forwardRef(({className:t,...s},r)=>e.jsx(O$e,{ref:r,className:It("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(Wwt,{className:"flex items-center justify-center",children:e.jsx(qc,{className:"h-2.5 w-2.5 fill-current text-current"})})}));pne.displayName=O$e.displayName;const Gwt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Qs(),[o,l]=M.useState({}),[i,d]=M.useState({}),[u,f]=M.useState([]);M.useEffect(()=>{s&&a&&t.polls.length>0&&g()},[s,a,t.polls]);const g=async()=>{if(!a)return;const j=t.polls.map(S=>S.id),{data:N}=await K.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",j);if(N){const S={};N.forEach(A=>{S[A.poll_id]||(S[A.poll_id]=[]),S[A.poll_id].push(A.option_id)}),d(S)}},v=(j,N)=>{l(S=>({...S,[j]:N}))},_=(j,N,S)=>{l(A=>{const I=A[j]||[];return S?{...A,[j]:[...I,N]}:{...A,[j]:I.filter(L=>L!==N)}})},b=async j=>{if(!a)return;const N=o[j];if(!N||Array.isArray(N)&&N.length===0){ge.error("Please select an option");return}f(S=>[...S,j]);try{await K.from("levelup_brief_poll_responses").delete().eq("poll_id",j).eq("user_id",a.id);const S=Array.isArray(N)?N:[N],A=S.map(L=>({poll_id:j,option_id:L,user_id:a.id})),{error:I}=await K.from("levelup_brief_poll_responses").insert(A);if(I)throw I;d(L=>({...L,[j]:S})),ge.success("Response submitted!")}catch(S){console.error("Error submitting poll response:",S),ge.error("Failed to submit response")}finally{f(S=>S.filter(A=>A!==j))}},w=j=>(j.includes("mediadelivery.net")||j.includes("bunny"),j);return e.jsx(bs,{open:s,onOpenChange:j=>!j&&r(),children:e.jsxs(_s,{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(Vr,{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(Ag,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(nt,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(Ss,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Fi,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:w(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(j=>e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>window.open(j.url,"_blank"),className:"gap-2",children:[e.jsx(un,{className:"h-4 w-4"}),j.title]},j.id))})]}),t.polls.map(j=>{var A,I;const N=((A=i[j.id])==null?void 0:A.length)>0,S=u.includes(j.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:j.question}),N&&e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Ma,{className:"h-3 w-3"}),"Responded"]})]}),j.poll_type==="single"?e.jsx(u_e,{value:o[j.id]||((I=i[j.id])==null?void 0:I[0])||"",onValueChange:L=>v(j.id,L),className:"space-y-2",children:j.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(pne,{value:L.id,id:L.id}),e.jsx(_e,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id))}):e.jsx("div",{className:"space-y-2",children:j.options.map(L=>{const $=(o[j.id]||i[j.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx($o,{id:L.id,checked:$,onCheckedChange:q=>_(j.id,L.id,q)}),e.jsx(_e,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id)})}),e.jsx(Z,{size:"sm",onClick:()=>b(j.id),disabled:S,children:S?"Submitting...":N?"Update Response":"Submit"})]},j.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(Z,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},Kwt=()=>{const{user:t}=Qs(),[s,r]=M.useState(null),[n,a]=M.useState(!1),[o,l]=M.useState(!0),[i,d]=M.useState(!1),u=M.useCallback(async()=>{if(!t){l(!1);return}try{const{data:b,error:w}=await K.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(w||!b){l(!1);return}const{data:j}=await K.from("levelup_brief_views").select("*").eq("brief_id",b.id).eq("user_id",t.id).maybeSingle(),[N,S]=await Promise.all([K.from("levelup_brief_links").select("*").eq("brief_id",b.id).order("sort_order"),K.from("levelup_brief_polls").select("*").eq("brief_id",b.id).order("sort_order")]),A=[];if(S.data)for(const q of S.data){const{data:H}=await K.from("levelup_brief_poll_options").select("*").eq("poll_id",q.id).order("sort_order");A.push({...q,options:H||[]})}const I={brief:b,links:N.data||[],polls:A};r(I);const L=!!j,F=(j==null?void 0:j.dismissed_at)!=null,$=localStorage.getItem(`brief-dismissed-${b.id}`)==="true";if(F||$)d(!1),a(!1);else if(!L)a(!0),d(!0);else if(b.show_frequency==="every_login")a(!0),d(!0);else if(b.show_frequency==="daily"){const q=new Date(j.viewed_at);(new Date().getTime()-q.getTime())/(1e3*60*60)>=24&&(a(!0),d(!0))}else d(!1)}catch(b){console.error("Error fetching brief:",b)}finally{l(!1)}},[t]);M.useEffect(()=>{u()},[u]);const f=async()=>{if(!(!t||!s))try{const{data:b}=await K.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();b?await K.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",b.id):await K.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(b){console.error("Error marking brief as viewed:",b)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),f()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),d(!1);try{const{data:b,error:w}=await K.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(w&&console.error("Error checking existing brief view:",w),b){const{error:j}=await K.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",b.id).eq("user_id",t.id);j&&console.error("Error updating brief dismiss:",j)}else{const{error:j}=await K.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});j&&console.error("Error inserting brief dismiss:",j)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(b){console.error("Error dismissing brief:",b),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function Zwt(){const[t,s]=M.useState(!1),[r,n]=M.useState(!1),[a,o]=M.useState(null);M.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const g=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(g),s(!0);const v=_=>{_.preventDefault(),o(_)};return window.addEventListener("beforeinstallprompt",v),()=>{window.removeEventListener("beforeinstallprompt",v)}},[]);const l=()=>{localStorage.setItem("install-banner-dismissed","true"),s(!1)},i=async()=>{if(a){await a.prompt();const{outcome:d}=await a.userChoice;d==="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(Ei,{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(mP,{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(Z,{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(Vr,{className:"h-4 w-4"})})]})]})}):null}const Ywt=({children:t,onRefresh:s})=>{const[r,n]=M.useState(!1),[a,o]=M.useState(0),[l,i]=M.useState(!1),d=M.useRef(null),u=M.useRef(0),f=ds(),g=80,v=120,_=M.useCallback(S=>{const A=d.current;A&&A.scrollTop<=0&&(u.current=S.touches[0].clientY,n(!0))},[]),b=M.useCallback(S=>{if(!r||l)return;const A=d.current;if(!A||A.scrollTop>0){n(!1),o(0);return}const L=S.touches[0].clientY-u.current;if(L>0){const $=Math.min(L*.5,v);o($),$>10&&S.preventDefault()}},[r,l]),w=M.useCallback(async()=>{if(r)if(n(!1),a>=g&&!l){i(!0),o(g);try{s?await s():await f.invalidateQueries()}catch(S){console.error("Refresh failed:",S)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,f]),j=Math.min(a/g,1),N=j*180;return e.jsxs("div",{ref:d,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:b,onTouchEnd:w,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:j},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${N}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Ao,{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})]})},R$e=()=>{const{user:t}=Qs(),[s,r]=M.useState(!1),[n,a]=M.useState(!1),[o,l]=M.useState(0),[i,d]=M.useState(!0);M.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{const{data:_}=await K.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(_){a(!0),r(!1),d(!1);return}const{data:b}=await K.from("profiles").select("login_count").eq("id",t.id).single(),w=(b==null?void 0:b.login_count)||0;l(w);const j=sessionStorage.getItem("review-prompt-dismissed");r(w>=4&&!j)}catch(_){console.error("Error checking review eligibility:",_)}finally{d(!1)}})()},[t]);const u=M.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),f=M.useCallback(async(v,_)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:b}=await K.from("membership_reviews").insert({user_id:t.id,rating:v,review_text:_});if(b)throw b;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(b){return console.error("Error submitting review:",b),{success:!1,error:b.message}}},[t]),g=M.useCallback(async()=>{if(t)try{await K.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(v){console.error("Error updating Google review status:",v)}},[t]);return{shouldShowPrompt:s,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:u,submitReview:f,markPostedToGoogle:g}},Xwt="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",Qwt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=R$e(),[o,l]=M.useState(!1),[i,d]=M.useState("review"),[u,f]=M.useState(0),[g,v]=M.useState(0),[_,b]=M.useState(""),[w,j]=M.useState(!1),[N,S]=M.useState(!1);if(s||!t&&!N)return null;const A=async()=>{if(u===0){dn({title:"Please select a rating",variant:"destructive"});return}j(!0);const F=await n(u,_);j(!1),F.success?(S(!0),dn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):dn({title:"Error submitting review",description:F.error,variant:"destructive"})},I=async F=>{F&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),dn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(Xwt,"_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(Gn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(bs,{open:o,onOpenChange:L,children:e.jsx(_s,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(Kr,{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(F=>e.jsx("button",{type:"button",onClick:()=>f(F),onMouseEnter:()=>v(F),onMouseLeave:()=>v(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Gn,{className:It("h-8 w-8 transition-colors",(g||u)>=F?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},F))}),e.jsx(Lr,{placeholder:"Tell us about your experience (optional)",value:_,onChange:F=>b(F.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(Z,{onClick:A,disabled:w||u===0,className:"flex-1",children:w?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(Kr,{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(Z,{variant:"outline",onClick:()=>I(!1),className:"flex-1",children:"No Thanks"}),e.jsx(Z,{onClick:()=>I(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function Jwt(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(!g){l(!1);return}(async()=>{try{const w="vapid_public_key";let j=localStorage.getItem(w);if(!j){const{data:A,error:I}=await K.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(j=(A==null?void 0:A.vapidPublicKey)??null,!j)throw new Error("Missing VAPID public key");localStorage.setItem(w,j)}f(j);const N=await navigator.serviceWorker.register("/push-sw.js");d(N),r(Notification.permission);const S=await N.pushManager.getSubscription();a(!!S)}catch(w){console.error("Error initializing push notifications:",w)}finally{l(!1)}})()},[g]);const v=M.useCallback(async()=>{if(!g||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!u)return ge.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{l(!0);const b=await i.pushManager.getSubscription();if(b){try{await b.unsubscribe()}catch(I){console.warn("Failed to unsubscribe existing push subscription:",I)}const{error:A}=await K.from("push_subscriptions").delete().eq("user_id",t.id);A&&console.warn("Failed to cleanup push_subscriptions rows:",A)}if(Notification.permission!=="granted"){const A=await Notification.requestPermission();if(r(A),A!=="granted")return A==="denied"?ge.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):ge.error("Notification permission was dismissed. Please try again."),!1}const w=Jwt(u);let j;try{j=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w})}catch(A){console.error("PushManager.subscribe() failed:",A);const I=(A==null?void 0:A.message)||String(A);return I.includes("permission")?ge.error("Push permission denied. Check your browser notification settings."):I.includes("key")||I.includes("VAPID")?ge.error("Push configuration error. Please contact support."):I.includes("AbortError")?ge.error("Push subscription was cancelled. Please try again."):ge.error(`Failed to subscribe: ${I}`),!1}const N=j.toJSON(),{error:S}=await K.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(S)throw console.error("Error saving subscription:",S),ge.error("Failed to save notification preferences. Please try again."),S;return a(!0),ge.success("Push notifications enabled!"),!0}catch(b){if(console.error("Error subscribing to push notifications:",b),!(b instanceof Error&&b.message.includes("toast"))){const w=b instanceof Error?b.message:"Unknown error";ge.error("Failed to enable push notifications: "+w)}return!1}finally{l(!1)}},[g,i,t,u]),_=M.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const b=await i.pushManager.getSubscription();return b&&await b.unsubscribe(),await K.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),ge.success("Push notifications disabled"),!0}catch(b){console.error("Error unsubscribing:",b);const w=b instanceof Error?b.message:"Unknown error";return ge.error("Failed to disable push notifications: "+w),!1}finally{l(!1)}},[i,t]);return{isSupported:g,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:v,unsubscribe:_}}const Ehe="push_notification_prompt_dismissed",e2t=()=>{const{user:t}=Qs(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=F$e(),[o,l]=M.useState(!1),[i,d]=M.useState(!1);M.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${Ehe}_${t.id}`))return;const v=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(v)},[t,s,r,n]);const u=async()=>{d(!0);const g=await a();d(!1),g&&(t&&localStorage.setItem(`${Ehe}_${t.id}`,"true"),l(!1))},f=()=>{t&&localStorage.setItem(`${Ehe}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(bs,{open:o,onOpenChange:g=>!g&&f(),children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{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(af,{className:"h-6 w-6 text-primary"})}),e.jsx(Ss,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Kr,{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(Z,{onClick:u,disabled:i,className:"w-full",children:i?"Enabling...":"Enable Notifications"}),e.jsx(Z,{variant:"ghost",onClick:f,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."})]})})},n3e=t=>{let s;const r=new Set,n=(u,f)=>{const g=typeof u=="function"?u(s):u;if(!Object.is(g,s)){const v=s;s=f??(typeof g!="object"||g===null)?g:Object.assign({},s,g),r.forEach(_=>_(s,v))}},a=()=>s,i={setState:n,getState:a,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=s=t(n,a,i);return i},t2t=t=>t?n3e(t):n3e,s2t=t=>t;function r2t(t,s=s2t){const r=ut.useSyncExternalStore(t.subscribe,ut.useCallback(()=>s(t.getState()),[t,s]),ut.useCallback(()=>s(t.getInitialState()),[t,s]));return ut.useDebugValue(r),r}const a3e=t=>{const s=t2t(t),r=n=>r2t(s,n);return Object.assign(r,s),r},n2t=t=>t?a3e(t):a3e;function a2t(t,s){let r;try{r=t()}catch{return}return{getItem:a=>{var o;const l=d=>d===null?null:JSON.parse(d,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 Lge=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return Lge(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return Lge(n)(r)}}}},i2t=(t,s)=>(r,n,a)=>{let o={storage:a2t(()=>localStorage),partialize:w=>w,version:0,merge:(w,j)=>({...j,...w}),...s},l=!1;const i=new Set,d=new Set;let u=o.storage;if(!u)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...w)},n,a);const f=()=>{const w=o.partialize({...n()});return u.setItem(o.name,{state:w,version:o.version})},g=a.setState;a.setState=(w,j)=>(g(w,j),f());const v=t((...w)=>(r(...w),f()),n,a);a.getInitialState=()=>v;let _;const b=()=>{var w,j;if(!u)return;l=!1,i.forEach(S=>{var A;return S((A=n())!=null?A:v)});const N=((j=o.onRehydrateStorage)==null?void 0:j.call(o,(w=n())!=null?w:v))||void 0;return Lge(u.getItem.bind(u))(o.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==o.version){if(o.migrate){const A=o.migrate(S.state,S.version);return A instanceof Promise?A.then(I=>[!0,I]):[!0,A]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var A;const[I,L]=S;if(_=o.merge(L,(A=n())!=null?A:v),r(_,!0),I)return f()}).then(()=>{N==null||N(_,void 0),_=n(),l=!0,d.forEach(S=>S(_))}).catch(S=>{N==null||N(void 0,S)})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>b(),hasHydrated:()=>l,onHydrate:w=>(i.add(w),()=>{i.delete(w)}),onFinishHydration:w=>(d.add(w),()=>{d.delete(w)})},o.skipHydration||b(),_||v},o2t=i2t,Ioe=n2t()(o2t((t,s)=>({cartItems:[],addToCart:(r,n,a=1,o)=>{t(l=>{const i=l.cartItems.findIndex(d=>{var u;return d.product.id===r.id&&((u=d.variant)==null?void 0:u.id)===(n==null?void 0:n.id)});if(i>=0){const d=[...l.cartItems];return d[i].quantity+=a,o&&(d[i].artworkUrl=o),{cartItems:d}}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})})),z$e=M.createContext({onlineUsers:[],totalOnline:0}),l2t=async t=>{try{const{data:s}=await K.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=K.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},c2t=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Qs(),[a,o]=M.useState([]),[l,i]=M.useState(null);M.useEffect(()=>{if(!s)return;const u=K.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const f=u.presenceState(),g=[];Object.entries(f).forEach(([v,_])=>{if(_&&_.length>0){const b=_[0];g.push({id:v,name:b.name||"Unknown",avatarUrl:b.avatarUrl,brokerageId:b.brokerageId,onlineSince:b.onlineSince})}}),o(g)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async f=>{var g;if(f==="SUBSCRIBED"){const{data:v}=await K.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),_=await l2t(s.id);await u.track({name:(v==null?void 0:v.name)||((g=s.email)==null?void 0:g.split("@")[0])||"User",avatarUrl:_,brokerageId:v==null?void 0:v.brokerage_id,onlineSince:new Date().toISOString()})}}),i(u),()=>{u.unsubscribe()}},[s]);const d=a.filter(u=>u.id===(s==null?void 0:s.id)?!1:!!(n||r&&u.brokerageId===r||!r&&!u.brokerageId));return e.jsx(z$e.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:t})},B$e=()=>M.useContext(z$e),i3e="dashboard-sidebar-collapsed",Ms=({children:t,title:s})=>{var Ve;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Qs(),{isAssistant:i,actingAsAgent:d,hasPermission:u}=y1e(),{isImpersonating:f}=x1e(),v=(i&&!!d?40:0)+(f?40:0),{avatarUrl:_}=S9e(r==null?void 0:r.id),{isTrial:b,isExpired:w,expiresAt:j}=abt(r==null?void 0:r.id),{isMarketplaceEnabled:N}=M9e(),{currentBrief:S,shouldShowPopup:A,hasUnseenBrief:I,openBrief:L,closeBrief:F,dismissBrief:$}=Kwt(),{unreadCount:q}=ibt(),{openCount:H}=obt(),{data:U}=Ug(),Q=!!U,te=Ioe(dt=>dt.cartItems).reduce((dt,Le)=>dt+Le.quantity,0),Y=Or(),ce=sh(),[oe,le]=M.useState(null);M.useEffect(()=>{r!=null&&r.id&&K.from("profiles").select("name").eq("id",r.id).single().then(({data:dt})=>{dt!=null&&dt.name&&le(dt.name)})},[r==null?void 0:r.id]);const de=oe||((Ve=r==null?void 0:r.user_metadata)==null?void 0:Ve.name)||(r==null?void 0:r.email)||"User",[xe,be]=M.useState(()=>typeof window<"u"?localStorage.getItem(i3e)==="true":!1);M.useEffect(()=>{localStorage.setItem(i3e,String(xe))},[xe]);const[ye,ve]=M.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,help:!1}),ke=dt=>{ve(Le=>({...Le,[dt]:!Le[dt]}))},Ge=dt=>dt.split(" ").map(Le=>Le[0]).join("").toUpperCase().slice(0,2),Ne=dt=>ce.pathname===dt,Ae=dt=>dt.some(Le=>ce.pathname===Le),Pe=({path:dt,icon:Le,label:Rt,badgeCount:fe})=>{const Qe=e.jsxs(Z,{variant:"ghost",size:"sm",className:It("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Ne(dt)&&"bg-sidebar-accent text-sidebar-accent-foreground",xe?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>Y(dt),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Le,{className:"h-4 w-4 shrink-0"}),xe&&fe!=null&&fe>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!xe&&Rt,!xe&&fe!=null&&fe>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:fe>9?"9+":fe})]});return xe?e.jsxs(Mu,{delayDuration:0,children:[e.jsx(Tu,{asChild:!0,children:Qe}),e.jsxs(au,{side:"right",className:"flex items-center gap-2",children:[Rt,fe!=null&&fe>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:fe>9?"9+":fe})]})]}):Qe},Fe=({id:dt,label:Le,icon:Rt,children:fe,activePaths:Qe,showBetaBadge:at,defaultPath:rt,badgeCount:je})=>{if(xe){const mt=rt||Qe[0];return e.jsxs(Mu,{delayDuration:0,children:[e.jsx(Tu,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"sm",className:It("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Ae(Qe)&&"text-primary"),onClick:()=>Y(mt),children:e.jsxs("div",{className:"relative",children:[e.jsx(Rt,{className:"h-4 w-4"}),je!=null&&je>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(au,{side:"right",className:"flex items-center gap-2",children:[Le,at&&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"}),je!=null&&je>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:je>9?"9+":je})]})]})}return e.jsxs(Eg,{open:ye[dt],onOpenChange:()=>ke(dt),children:[e.jsx(Pg,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ae(Qe)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(Rt,{className:"h-4 w-4"}),Le,at&&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:[je!=null&&je>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:je>9?"9+":je}),e.jsx(tl,{className:It("h-4 w-4 transition-transform duration-200",ye[dt]&&"rotate-180")})]})]})}),e.jsx(Ig,{className:"pl-4 space-y-1 mt-1",children:fe})]})},Ie=({isMobile:dt=!1})=>{const Le=dt?!1:xe;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:It("p-3 border-b border-sidebar-border",Le?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[Le?e.jsx("img",{src:Tbt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:Mbt,alt:"LevelUp",className:"h-8 w-auto"}),!dt&&e.jsxs(Mu,{delayDuration:0,children:[e.jsx(Tu,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>be(!Le),children:e.jsx(ec,{className:It("h-4 w-4 transition-transform duration-300",Le&&"rotate-180")})})}),e.jsx(au,{side:"right",children:Le?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Fi,{className:"flex-1",children:e.jsxs("nav",{className:It("p-3 space-y-1",Le&&"flex flex-col items-center"),children:[e.jsx(Pe,{path:"/dashboard",icon:Zk,label:"Dashboard"}),xe?e.jsxs(Mu,{delayDuration:0,children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/levelup-u"),children:[e.jsx(Yu,{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(au,{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(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/levelup-u"),children:[e.jsx(Yu,{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(Pe,{path:"/events",icon:jc,label:"Events"}),e.jsxs(Fe,{id:"agentos",label:"Agent OS",icon:Y4,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"],showBetaBadge:!0,defaultPath:"/mission-control",children:[u("contacts")&&e.jsx(Pe,{path:"/mission-control",icon:Oi,label:"Mission Control"}),u("contacts")&&e.jsx(Pe,{path:"/mission-control/contacts",icon:xr,label:"Contacts"}),u("contacts")&&e.jsx(Pe,{path:"/mission-control/plans",icon:jc,label:"TouchPlans"}),u("pipeline")&&e.jsx(Pe,{path:"/mission-control/pipeline",icon:Bx,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Pe,{path:"/mission-control/tasks",icon:e0,label:"Tasks"}),u("popbys")&&e.jsx(Pe,{path:"/mission-control/popbys",icon:uo,label:"Popbys"}),u("videos")&&e.jsx(Pe,{path:"/mission-control/video-library",icon:Cn,label:"Video Library"}),u("scorecard")&&e.jsx(Pe,{path:"/mission-control/scorecard",icon:ol,label:"Scorecard"}),u("listings")&&e.jsx(Pe,{path:"/mission-control/listings",icon:_a,label:"Listing Exchange"}),!Le&&e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/smart-drips"),children:[e.jsx(Tm,{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"})]}),Le&&e.jsx(Pe,{path:"/mission-control/smart-drips",icon:Tm,label:"Smart Drips"})]}),e.jsxs(Fe,{id:"tools",label:"Tools",icon:Ym,activePaths:["/apps","/ai-toolkit","/mission-control/my-card","/mission-control/presentations","/mission-control/guest-book","/mission-control/scheduler"],defaultPath:"/apps",children:[e.jsx(Pe,{path:"/apps",icon:Ym,label:"Apps"}),u("digital_card")&&!Le&&e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/mission-control/my-card")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/my-card"),children:[e.jsx(cp,{className:"h-4 w-4"}),"Smart Card",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-destructive text-destructive-foreground",children:"New"})]}),u("digital_card")&&Le&&e.jsx(Pe,{path:"/mission-control/my-card",icon:cp,label:"Smart Card"}),u("presentations")&&!Le&&e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground overflow-hidden",ce.pathname.startsWith("/mission-control/presentations")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/presentations"),children:[e.jsx(lf,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:"Presentations"})]}),u("presentations")&&Le&&e.jsx(Pe,{path:"/mission-control/presentations",icon:lf,label:"Smart Presentations"}),u("guest_book")&&!Le&&e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/mission-control/guest-book")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/guest-book"),children:[e.jsx(nu,{className:"h-4 w-4"}),"Guest Book"]}),u("guest_book")&&Le&&e.jsx(Pe,{path:"/mission-control/guest-book",icon:nu,label:"Guest Book"}),!Le&&e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/mission-control/card-studio")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/card-studio"),children:[e.jsx(Ar,{className:"h-4 w-4"}),"Card Studio"]}),Le&&e.jsx(Pe,{path:"/mission-control/card-studio",icon:Ar,label:"Card Studio"}),a&&!Le&&e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/mission-control/scheduler")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/scheduler"),children:[e.jsx(jc,{className:"h-4 w-4"}),"Scheduler",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-destructive text-destructive-foreground",children:"New"})]}),a&&Le&&e.jsx(Pe,{path:"/mission-control/scheduler",icon:jc,label:"Scheduler"})]}),e.jsxs(Fe,{id:"marketing",label:"Marketing",icon:Ag,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Pe,{path:"/templates",icon:El,label:"Templates"}),e.jsx(Pe,{path:"/social-swag-2",icon:N0,label:"Social Swag"}),e.jsx(Pe,{path:"/newsletters",icon:j0,label:"Newsletters"})]}),e.jsxs(Fe,{id:"learning",label:"Learning",icon:nu,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Pe,{path:"/academy",icon:Yu,label:"Academy"}),e.jsx(Pe,{path:"/toolbox",icon:Vx,label:"Toolbox"})]}),e.jsxs(Fe,{id:"community",label:"Community",icon:ho,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:q,children:[e.jsx(Pe,{path:"/community",icon:xr,label:"Community",badgeCount:q}),e.jsx(Pe,{path:"/wishlist",icon:G1,label:"Wishlist",badgeCount:H}),!Le&&e.jsxs(Z,{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(un,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(Fe,{id:"goods",label:"The Goods",icon:vm,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[N&&!Le&&e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ce.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/marketplace"),children:[e.jsx(vm,{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&&Le&&e.jsx(Pe,{path:"/marketplace",icon:vm,label:"Marketplace"}),e.jsx(Pe,{path:"/reward-store",icon:so,label:"Reward Store"})]}),e.jsxs(Fe,{id:"help",label:"Help & Services",icon:Qy,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Pe,{path:"/support",icon:n5,label:"Support"}),e.jsx(Pe,{path:"/additional-services",icon:gn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!Le&&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"})}),Le?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Pe,{path:"/admin",icon:Pu,label:"Admin Dashboard"})}):e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ce.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/admin"),children:[e.jsx(Pu,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!Le&&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"})}),Le?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(Pe,{path:"/my-brokerage",icon:_a,label:"My Brokerage"}),e.jsx(Pe,{path:"/brokerage-content",icon:nu,label:"Brokerage Content"})]}),Q&&!o&&e.jsx(Pe,{path:"/my-team",icon:xr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{path:"/brokerage/dashboard",icon:Pl,label:"Manage Brokerages"}),e.jsx(Pe,{path:"/brokerage/teams",icon:xr,label:"Teams"}),e.jsx(Pe,{path:"/brokerage-resources",icon:Zu,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/my-brokerage"),children:[e.jsx(_a,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage-content"),children:[e.jsx(nu,{className:"h-4 w-4"}),"Brokerage Content"]})]}),Q&&!o&&e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/my-team"),children:[e.jsx(xr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage/dashboard"),children:[e.jsx(Pl,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage/teams"),children:[e.jsx(xr,{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(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage-resources"),children:[e.jsx(Zu,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(Z,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/profile"),children:[e.jsx(mo,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(Z,{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(i5,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(c2t,{children:e.jsx(HN,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&w&&e.jsx(Ewt,{}),typeof document<"u"&&xm.createPortal(e.jsx("aside",{className:It("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-[2147483647] isolate !pointer-events-auto transition-[width] duration-300",xe?"w-16":"w-52"),style:{top:`${v}px`,height:`calc(100vh - ${v}px)`},children:e.jsx(Ie,{})}),document.body),e.jsxs("div",{className:It("flex-1 flex flex-col overflow-hidden transition-all duration-300",xe?"md:ml-16":"md:ml-52"),style:{height:`calc(100vh - ${v}px)`,marginTop:`${v}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(uL,{children:[e.jsx(W1e,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(JE,{className:"h-5 w-5"})})}),e.jsx(lM,{side:"left",className:"w-52 p-0 bg-card",children:e.jsx(Ie,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:Abt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(r3e,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!w&&j&&e.jsx(Awt,{expiresAt:j,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(r3e,{})}),S&&e.jsx(Pwt,{hasUnseenBrief:I,onClick:L}),N&&e.jsxs(Z,{variant:"ghost",size:"icon",className:"relative",onClick:()=>Y("/marketplace/cart"),children:[e.jsx(vm,{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(swt,{}),e.jsx(Ege,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",de.split(" ")[0],"!"]}),e.jsxs(Du,{children:[e.jsx(Ou,{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(mn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(ba,{src:_||void 0}),e.jsx(pn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Ge(de)})]})})}),e.jsxs(mu,{align:"end",className:"w-48",children:[e.jsxs(Wa,{onClick:()=>Y("/profile"),className:"cursor-pointer",children:[e.jsx(mo,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Wa,{onClick:()=>Y("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(iP,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(g_,{}),e.jsxs(Wa,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(i5,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(Ywt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),S&&e.jsx(Gwt,{brief:S,open:A,onClose:F,onDismiss:$}),e.jsx(Zwt,{}),e.jsx(Qwt,{}),e.jsx(e2t,{})]})]})})})},d2t=()=>{const{user:t}=Qs(),[s,r]=M.useState(!1),[n,a]=M.useState(null),[o,l]=M.useState(""),i=async g=>{var v;if(!(t!=null&&t.email)){ge.error("Please sign in to upgrade");return}r(!0),a(g);try{const{data:_,error:b}=await K.functions.invoke("create-checkout",{body:{tier:g,email:t.email,name:((v=t.user_metadata)==null?void 0:v.full_name)||t.email,couponCode:o.trim()||void 0,skipTrial:!0}});if(b)throw b;if(_!=null&&_.url)window.open(_.url,"_blank","noopener,noreferrer"),ge.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(_){console.error("Checkout error:",_),ge.error(_.message||"Failed to start checkout. Please try again.")}finally{r(!1),a(null)}},d=["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"],f=["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(Ms,{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(_e,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(Re,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:g=>l(g.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[e.jsxs(De,{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($t,{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(xr,{className:"h-7 w-7 text-primary"})}),e.jsx(Vt,{className:"text-xl",children:"Individual Agent"}),e.jsx(_r,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:d.map((g,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ma,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),e.jsxs(Z,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(gn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(De,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs($t,{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(_a,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Vt,{className:"text-xl",children:"Brokerage"}),e.jsx(_r,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:u.map((g,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ma,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),e.jsxs(Z,{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(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_a,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(De,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs($t,{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(_a,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Vt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(_r,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:f.map((g,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ma,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),e.jsxs(Z,{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(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_a,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(De,{className:"bg-muted/50",children:e.jsxs(Oe,{className:"py-6",children:[e.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(ga,{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(Ar,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},u2t=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Qs(),a=Or(),[o,l]=M.useState(""),[i,d]=M.useState(!1),[u,f]=M.useState(!1);M.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),M.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const g=async()=>{if(!o.trim()){ge.error("Please enter a brokerage name");return}const{data:v}=await K.auth.getSession(),_=v.session;if(!t||!_){ge.error("Please sign in again to create your brokerage."),a("/auth");return}d(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!_,userId:t==null?void 0:t.id});const{data:b,error:w}=await K.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:b,error:w}),w)throw w;if(!(b!=null&&b.ok))throw new Error((b==null?void 0:b.error)||"Failed to create brokerage");d(!1),f(!0),ge.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(b){console.error("Error creating brokerage:",b),ge.error(b.message||"Failed to create brokerage"),d(!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(De,{className:"max-w-lg w-full",children:[e.jsxs($t,{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(Rs,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Vt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(_r,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(hi,{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(Rs,{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(De,{className:"max-w-lg w-full",children:[e.jsxs($t,{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(_a,{className:"w-10 h-10 text-primary"})}),e.jsx(Vt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(_r,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Re,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:v=>l(v.target.value),onKeyDown:v=>v.key==="Enter"&&g()}),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(xr,{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(hi,{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(hi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(hi,{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(hi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(Z,{onClick:g,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(Ai,{className:"w-4 h-4 ml-2"})]})]})]})})},o3e=()=>{const t=Or(),[s,r]=M.useState("verifying"),[n,a]=M.useState("");M.useEffect(()=>{(async()=>{try{const{data:{session:i},error:d}=await K.auth.getSession();if(d)throw d;if(i!=null&&i.user){const{data:u}=await K.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 K.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(f){console.log("Trial claim hook (non-critical):",f)}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(De,{className:"w-full max-w-md",children:[e.jsxs($t,{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(Vt,{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(_r,{children:[s==="verifying"&&"Please wait while we verify your account...",s==="success"&&"Redirecting you to complete your profile...",s==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",s==="error"&&n]})]}),(s==="already_claimed"||s==="error")&&e.jsx(Oe,{children:e.jsx(Z,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},h2t=()=>{const t=Or(),[s]=Gc(),[r,n]=M.useState(s.get("code")||""),[a,o]=M.useState(""),[l,i]=M.useState(""),[d,u]=M.useState(""),[f,g]=M.useState(!1),[v,_]=M.useState(!1),[b,w]=M.useState(!1),[j,N]=M.useState(!1),[S,A]=M.useState(null),[I,L]=M.useState(null),[F,$]=M.useState(null),[q,H]=M.useState(null);M.useEffect(()=>{const te=s.get("code");te&&(n(te),U(te))},[s]);const U=async te=>{w(!0);const{data:Y,error:ce}=await K.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||!Y){ge.error("Invalid invite code"),w(!1);return}if(!Y.is_active){ge.error("This invite code is no longer active"),w(!1);return}if(Y.max_uses&&Y.uses_count>=Y.max_uses){ge.error("This invite code has reached its maximum uses"),w(!1);return}if(Y.expires_at&&new Date(Y.expires_at){te.preventDefault(),U(r)},se=async te=>{var Y;if(te.preventDefault(),!d.trim()){ge.error("Please enter your name");return}if(l.length<6){ge.error("Password must be at least 6 characters");return}_(!0);try{const ce=`${window.location.origin}/`,{data:oe,error:le}=await K.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ce,data:{name:d.trim()}}});if(le){le.message.includes("already registered")?ge.error("This email is already registered. Please sign in instead."):ge.error(le.message);return}oe.user&&(await K.rpc("add_default_signup_tag",{user_id:oe.user.id}),I?await K.functions.invoke("assign-brokerage",{body:{userId:oe.user.id,brokerageId:I}}):q?await K.functions.invoke("assign-brokerage",{body:{userId:oe.user.id,trialDays:q}}):await K.functions.invoke("assign-brokerage",{body:{userId:oe.user.id,grandfathered:!0}}),S&&await K.from("invite_codes").update({uses_count:((Y=(await K.from("invite_codes").select("uses_count").eq("id",S).single()).data)==null?void 0:Y.uses_count)+1}).eq("id",S),ge.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(ce){console.error("Signup error:",ce),ge.error("An unexpected error occurred")}finally{_(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsxs($t,{className:"text-center",children:[e.jsx(Vt,{className:"text-2xl font-bold text-primary",children:F?`Join ${F}`:"Join LevelUp"}),e.jsx(_r,{children:j?F?`Create your account to join ${F}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Oe,{children:j?e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Full Name"}),e.jsx(Re,{id:"name",type:"text",placeholder:"John Doe",value:d,onChange:te=>u(te.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Re,{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(_e,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{id:"password",type:f?"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:()=>g(!f),children:f?e.jsx(Nm,{className:"h-4 w-4"}):e.jsx(Na,{className:"h-4 w-4"})})]})]}),e.jsx(Z,{type:"submit",className:"w-full",disabled:v,children:v?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:Q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(Re,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:te=>n(te.target.value),required:!0,autoFocus:!0})]}),e.jsx(Z,{type:"submit",className:"w-full",disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},m2t="/assets/testimonial-avatar-1-BsCQFauB.jpg",p2t="/assets/testimonial-avatar-2-B6VPVc2t.jpg",f2t="/assets/testimonial-avatar-3-GuEFwYUE.jpg",g2t="/assets/testimonial-avatar-4-98iKMtkB.jpg",x2t="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",y2t=[m2t,p2t,f2t,g2t,x2t],v2t=O_({name:Ko().trim().min(2,"Name must be at least 2 characters").max(100),email:Ko().trim().email("Please enter a valid email address").max(255),phone:Ko().trim().min(10,"Please enter a valid phone number").max(20).optional().or(c3("")),brokerage:Ko().trim().max(200).optional().or(c3(""))}),_2t=[{icon:mm,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:El,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:nn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:mc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Un,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:uo,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],b2t=[{icon:xr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:gn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:ga,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Lh,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Pi,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:ol,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Oi,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Tm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],w2t=[{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."}],j2t=()=>{const t=Or(),[s,r]=M.useState(!1),[n,a]=M.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=M.useState({}),i=async d=>{var f,g;d.preventDefault(),l({});const u=v2t.safeParse(n);if(!u.success){const v={};u.error.errors.forEach(_=>{_.path[0]&&(v[_.path[0]]=_.message)}),l(v);return}r(!0);try{const{data:v,error:_}=await K.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((f=n.phone)==null?void 0:f.trim())||void 0,brokerage:((g=n.brokerage)==null?void 0:g.trim())||void 0}});if(_){console.error("Trial signup error:",_),ge.error(_.message||"Something went wrong. Please try again.");return}if(v!=null&&v.error){ge.error(v.error);return}ge.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(v){console.error("Trial signup error:",v),ge.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(Gh,{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:one,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(Z,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var d;return(d=document.getElementById("features"))==null?void 0:d.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(Z,{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(gn,{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(Ma,{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(Ma,{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:y2t.map((d,u)=>e.jsx("img",{src:d,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(d=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},d))}),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(De,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-[#4a6b6d] mb-4",children:e.jsx($x,{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(_e,{htmlFor:"name",children:"Full Name *"}),e.jsx(Re,{id:"name",type:"text",placeholder:"John Smith",value:n.name,onChange:d=>a({...n,name:d.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(_e,{htmlFor:"email",children:"Email Address *"}),e.jsx(Re,{id:"email",type:"email",placeholder:"john@example.com",value:n.email,onChange:d=>a({...n,email:d.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(_e,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:d=>a({...n,phone:d.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(_e,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(Re,{id:"brokerage",type:"text",placeholder:"Your brokerage or team name",value:n.brokerage,onChange:d=>a({...n,brokerage:d.target.value})}),o.brokerage&&e.jsx("p",{className:"text-sm text-destructive",children:o.brokerage})]}),e.jsx(Z,{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(Rs,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Ai,{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:_2t.map((d,u)=>e.jsxs(De,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs($t,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(d.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Vt,{className:"text-xl font-sans",children:d.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:d.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(gn,{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:b2t.map((d,u)=>e.jsxs(De,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs($t,{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(d.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Vt,{className:"text-lg font-semibold text-white",children:d.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:d.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:w2t.map((d,u)=>e.jsx(De,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(f=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},f))}),e.jsxs("p",{className:"text-muted-foreground mb-4 italic",children:['"',d.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:d.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.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(Xu,{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(Tm,{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(xr,{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(De,{className:"bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] border-0 shadow-2xl overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs(Oe,{className:"p-12 text-center relative",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),e.jsx("p",{className:"text-xl text-white/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of successful agents. Start your free 7-day trial today."}),e.jsxs(Z,{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(Ai,{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:P1e,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."})]})})})]})]})},k2t=()=>{const t=Or();return e.jsxs(e.Fragment,{children:[e.jsx(Gh,{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:one,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(Z,{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(De,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8 md:p-12 text-center",children:[e.jsxs("div",{className:"relative inline-block mb-8",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:e.jsx(Ma,{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(bd,{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(Ar,{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(Z,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx(Ai,{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:P1e,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},N2t=O_({viewerName:Ko().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Ko().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Ko().max(20,"Phone must be less than 20 characters").optional(),message:Ko().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function S2t({shareToken:t,agentName:s,hasContact:r}){const[n,a]=M.useState(!1),[o,l]=M.useState(!1),[i,d]=M.useState(null),u=Soe({resolver:Coe(N2t),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),f=async g=>{a(!0),d(null);try{const{data:v,error:_}=await K.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:g.viewerName,viewerEmail:g.viewerEmail,viewerPhone:g.viewerPhone||void 0,message:g.message}});if(_)throw new Error(_.message);if(!(v!=null&&v.success))throw new Error((v==null?void 0:v.error)||"Failed to send reply");l(!0)}catch(v){console.error("Failed to submit reply:",v),d(v.message||"Something went wrong. Please try again.")}finally{a(!1)}};return o?e.jsx(De,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Oe,{className:"py-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:e.jsx(Ma,{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(De,{children:[e.jsxs($t,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(mc,{className:"h-5 w-5 text-primary"}),e.jsx(Vt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(_r,{children:r?`Have a question or want to connect? Send ${s||"them"} a message.`:`Interested? Share your info and ${s||"your agent"} will be in touch.`})]}),e.jsx(Oe,{children:e.jsx(Moe,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(f),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(yc,{control:u.control,name:"viewerName",render:({field:g})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Your Name *"}),e.jsx(lc,{children:e.jsx(Re,{placeholder:"John Smith",...g})}),e.jsx(Nh,{})]})}),e.jsx(yc,{control:u.control,name:"viewerEmail",render:({field:g})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Email *"}),e.jsx(lc,{children:e.jsx(Re,{type:"email",placeholder:"john@example.com",...g})}),e.jsx(Nh,{})]})})]}),!r&&e.jsx(yc,{control:u.control,name:"viewerPhone",render:({field:g})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Phone (optional)"}),e.jsx(lc,{children:e.jsx(Re,{type:"tel",placeholder:"(555) 123-4567",...g})}),e.jsx(Nh,{})]})}),e.jsx(yc,{control:u.control,name:"message",render:({field:g})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Message *"}),e.jsx(lc,{children:e.jsx(Lr,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...g})}),e.jsx(Nh,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(Z,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const C2t=()=>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(Gn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Gn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Gn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Gn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(v0,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),M2t=()=>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(gn,{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(Gn,{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(gn,{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(Gn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Gn,{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(v0,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),T2t=()=>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(wg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(wg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(wg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(wg,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Oi,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Oi,{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(Oi,{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"})]}),A2t=()=>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(dc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(dc,{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(Gn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Gn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),E2t=()=>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(wg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(wg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(Q4,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),P2t=()=>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(Gk,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(Gk,{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(gn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(gn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),I2t=()=>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(Q1,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(Q1,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(Q1,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(S1,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(S1,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(S1,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(S1,{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(Gn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),L2t=()=>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(Oi,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Oi,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),D2t=()=>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(Gn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Gn,{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(Gn,{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(Gn,{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(gn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(bd,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(bd,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),O2t=()=>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(Gn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(gn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(gn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),R2t=()=>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(l0,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(l0,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(l0,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(l0,{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"})]})]})]}),F2t=()=>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(Gn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Gn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(dc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(dc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(v0,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),z2t=()=>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(Lh,{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(bd,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(uo,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),B2t=()=>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(Oi,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Oi,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Oi,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Oi,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Oi,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Oi,{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(Oi,{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(Oi,{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"})]}),$2t=()=>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(X1,{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(X1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(gn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(X1,{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"})]}),q2t=()=>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(Hn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Hn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Sm,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Sm,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Oi,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Oi,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(gn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(bd,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),U2t=()=>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(bd,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(bd,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Sm,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(Hn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(gn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(gn,{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"})]}),V2t=()=>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(Sm,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Sm,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Sm,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(Hn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(bd,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(gn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Gn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),H2t=()=>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(Hn,{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(Sm,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Oi,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(gn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(g0,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),l3e=()=>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"})]}),W2t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Oi,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Oi,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Oi,{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(Oi,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),G2t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(g0,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(gn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(Hn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),K2t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Hk,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(o5,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(Hk,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),UA=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(gn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(bd,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(gn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),c3e=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Hn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(gn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(Hn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),Dge=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(gn,{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(Oi,{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(W2t,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(zE,{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(UA,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(Hk,{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(K2t,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(ol,{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(xr,{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(UA,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(dc,{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(l3e,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Pi,{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(c3e,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(o5,{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(UA,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Lh,{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(z2t,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Oi,{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(B2t,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(X1,{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($2t,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Gn,{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(D2t,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(Q4,{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(E2t,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(wg,{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(T2t,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(dc,{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(A2t,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(v0,{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(C2t,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(dp,{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(M2t,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(dc,{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(F2t,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(Gk,{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(P2t,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Oi,{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(L2t,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(Q1,{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(I2t,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(gn,{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(O2t,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(l0,{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(R2t,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Hn,{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(q2t,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(bd,{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(U2t,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(nn,{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(c3e,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(Uc,{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(UA,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(rN,{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(g0,{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(G2t,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Sm,{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(V2t,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Hn,{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(H2t,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(lu,{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(UA,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(dc,{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(l3e,{})}],Z2t=[{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 Y2t(t){return Dge.filter(s=>s.category===t)}function w5(t){return Dge.find(s=>s.id===t)||Dge[0]}function d3e(){const{shareToken:t,recipientToken:s}=Uo(),[r,n]=M.useState(null),[a,o]=M.useState(null),[l,i]=M.useState(null),[d,u]=M.useState(!0),[f,g]=M.useState(null),[v,_]=M.useState(!0),b=M.useRef(null),w=M.useRef(0),j=M.useRef(0),N=(()=>{const se=new URLSearchParams(window.location.search);return s||se.get("rt")||null})(),S=M.useCallback((se,te=!1)=>{if(!N||se<=0)return;const Y=Math.max(1,Math.round(se));if(Y<=j.current)return;const oe=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(N)}&e=watch&ws=${Y}`;te&&navigator.sendBeacon?navigator.sendBeacon(oe):fetch(oe,{method:"GET",keepalive:te}).catch(()=>{}),j.current=Math.max(j.current,Y)},[N]);M.useEffect(()=>{var de;if(!v||!(r!=null&&r.playback_url)||!N)return;let se=!1;const te=()=>{w.current>0&&S(w.current,!0)},Y=()=>{document.visibilityState==="hidden"&&te()},ce=()=>{te()},oe=()=>{var be;if(se||!b.current||!((be=window.playerjs)!=null&&be.Player))return;const xe=new window.playerjs.Player(b.current);xe.on("timeupdate",ye=>{const ve=Math.floor(Number((ye==null?void 0:ye.seconds)??0));!Number.isFinite(ve)||ve<=0||(w.current=Math.max(w.current,ve))}),xe.on("pause",()=>{w.current>0&&S(w.current)}),xe.on("ended",()=>{w.current>0&&S(w.current,!0)})},le=document.querySelector('script[data-bunny-playerjs="true"]');if((de=window.playerjs)!=null&&de.Player)oe();else if(le)le.addEventListener("load",oe,{once:!0});else{const xe=document.createElement("script");xe.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",xe.async=!0,xe.defer=!0,xe.dataset.bunnyPlayerjs="true",xe.onload=oe,document.body.appendChild(xe)}return document.addEventListener("visibilitychange",Y),window.addEventListener("beforeunload",ce),()=>{se=!0,document.removeEventListener("visibilitychange",Y),window.removeEventListener("beforeunload",ce),te()}},[v,r==null?void 0:r.playback_url,N,S]),M.useEffect(()=>{w.current=0,j.current=0},[N,t]),M.useEffect(()=>{const se=()=>{['[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(oe=>{document.querySelectorAll(oe).forEach(le=>{le.style.display="none"})})};se();const te=[setTimeout(se,500),setTimeout(se,1500),setTimeout(se,3e3)],Y=new MutationObserver(se);return Y.observe(document.body,{childList:!0,subtree:!0}),()=>{te.forEach(clearTimeout),Y.disconnect()}},[]),M.useEffect(()=>{(async()=>{if(!t){g("Invalid share link"),u(!1);return}const{data:te,error:Y}=await K.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(Y||!te){g("Video not found or has been removed"),u(!1);return}n(te);try{await K.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 K.from("profiles").select("id, name, email, phone").eq("id",te.owner_user_id).single();if(ce){o(ce);try{const{data:oe}=await K.storage.from("avatars").list(`${te.owner_user_id}`);if(oe&&oe.length>0){const{data:le}=K.storage.from("avatars").getPublicUrl(`${te.owner_user_id}/${oe[0].name}`);i(le.publicUrl)}}catch{}}}u(!1)})()},[t]);const A=se=>{if(!se)return"0:00";const te=Math.floor(se/60),Y=se%60;return`${te}:${Y.toString().padStart(2,"0")}`},I=se=>se.includes("iframe.mediadelivery.net/play/")?se.replace("/play/","/embed/")+"?autoplay=true&responsive=true":se,L=se=>{if(!se)return"?";const te=se.split(" ");return te.length>=2?`${te[0][0]}${te[1][0]}`.toUpperCase():se.substring(0,2).toUpperCase()},F=w5((r==null?void 0:r.page_template)||"default"),$=(r==null?void 0:r.recipient_name)||null,q=F.headerText($),U=`https://dashboard.relevelup.com/share/video/${t}`;if(d)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(Rs,{className:"h-8 w-8 animate-spin text-primary"})});if(f||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(De,{className:"max-w-md w-full",children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Cn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:f||"This video is no longer available."})]})})});const Q=F.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(Gh,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:F.subText}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:F.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:U}),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:q}),e.jsx("meta",{name:"twitter:description",content:F.subText}),r.preview_url&&e.jsx("meta",{name:"twitter:image",content:r.preview_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:r.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:It("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",F.gradientClasses),children:[Q&&F.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[Q&&e.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:It("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",F.accentColor==="primary"&&"bg-primary/10 text-primary",F.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",F.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",F.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",F.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",F.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",F.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",F.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",F.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",F.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",F.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",F.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",F.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:F.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:q}),e.jsx("p",{className:"text-muted-foreground",children:F.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(mn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(ba,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(pn,{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:Q?"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(Z,{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(ga,{className:"h-4 w-4"})})}),a.email&&e.jsx(Z,{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(Ar,{className:"h-4 w-4"})})})]})]}),e.jsx(De,{className:"overflow-hidden shadow-lg",children:v&&r.playback_url?e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:e.jsx("iframe",{ref:b,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:()=>_(!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:se=>{var Y;se.currentTarget.style.display="none";const te=(Y=se.currentTarget.parentElement)==null?void 0:Y.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(dl,{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:A(r.duration_seconds)})]})}),!Q&&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:v?"Enjoy the video!":"Click to play the video"})]}),!v&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(Z,{size:"lg",onClick:()=>_(!0),className:"gap-2",children:[e.jsx(dl,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(S2t,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function X2t(){return M.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(Dut,{})}function Q2t(){const{token:t}=Uo();return M.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(Rs,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const J2t={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},ejt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},ZC={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function tjt(){var Y,ce,oe,le;const{slugOrId:t}=Uo(),[s]=Gc(),{data:r,isLoading:n}=BBe(t||""),a=$Be(),o=Syt(),l=s.get("ref"),[i,d]=M.useState(""),[u,f]=M.useState(""),[g,v]=M.useState(""),[_,b]=M.useState(""),[w,j]=M.useState(!1),[N,S]=M.useState(!1),[A,I]=M.useState(null),[L,F]=M.useState(!1);M.useEffect(()=>{l&&o.mutate(l)},[l]);const $=de=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(de),q=async de=>{if(de.preventDefault(),!(!i.trim()||!g.trim()||!r)){j(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:g.trim(),phone:_.trim(),shareToken:l}),S(!0),ge.success("Thanks! The agent will be in touch soon.")}catch(xe){console.error("Lead submission error:",xe),ge.error(`Failed to submit: ${xe.message||"Please try again"}`)}finally{j(!1)}}},H=(r==null?void 0:r.photos)||[],U=H.find(de=>de.is_primary)||H[0],Q=()=>{A!==null&&I(A===0?H.length-1:A-1)},se=()=>{A!==null&&I(A===H.length-1?0:A+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(gs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(gs,{className:"h-10 w-48 mb-6"}),e.jsx(gs,{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(gs,{className:"h-12 w-48"}),e.jsx(gs,{className:"h-6 w-full"}),e.jsx(gs,{className:"h-6 w-3/4"})]}),e.jsx(gs,{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(yo,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Jre,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Hn,{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(Z,{asChild:!0,children:e.jsx(yo,{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(Gh,{children:[e.jsxs("title",{children:[te," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${ZC[r.property_type]} in ${r.city}, ${r.state}. ${((Y=r.description)==null?void 0:Y.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:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${ZC[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}`}),U&&e.jsx("meta",{property:"og:image",content:U.photo_url}),U&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${ZC[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:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),U&&e.jsx("meta",{name:"twitter:image",content:U.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||`${ZC[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:H.map(de=>de.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(yo,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Jre,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(yo,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),H.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:U==null?void 0:U.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${ZC[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:H.slice(1,5).map((de,xe)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>I(xe+1),children:[e.jsx("img",{src:de.photo_url,alt:`${r.property_address||r.city} - Photo ${xe+2} of ${H.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),xe===3&&H.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",H.length-5," more"]})]},de.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(nt,{className:`${J2t[r.status]} text-white border-0`,children:ejt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:$(r.price)}),r.property_address&&e.jsx("p",{className:"text-xl font-medium",children:r.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Pi,{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(q1,{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(f0,{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(Ux,{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(nn,{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(nt,{variant:"secondary",children:[e.jsx(_a,{className:"h-3 w-3 mr-1"}),ZC[r.property_type]]}),r.lot_size&&e.jsxs(nt,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(nt,{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(Z,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(un,{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(De,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Oe,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>F(!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(dl,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(Z,{onClick:()=>F(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(dl,{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(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:[e.jsx(mo,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((oe=r.agent.brokerage)==null?void 0:oe.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(De,{className:"border-primary",children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{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(Ar,{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:q,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Re,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:de=>d(de.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Re,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:de=>f(de.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email *"}),e.jsx(Re,{id:"email",type:"email",placeholder:"you@example.com",value:g,onChange:de=>v(de.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:de=>b(de.target.value)})]}),e.jsx(Z,{type:"submit",className:"w-full",disabled:w,children:w?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(bs,{open:A!==null,onOpenChange:()=>I(null),children:e.jsxs(_s,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ss,{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(Vr,{className:"h-5 w-5"})}),A!==null&&H[A]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:H[A].photo_url,alt:`Photo ${A+1}`,className:"w-full max-h-[80vh] object-contain"}),H.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Q,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(ec,{className:"h-6 w-6"})}),e.jsx("button",{onClick:se,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(ei,{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:[A+1," / ",H.length]})]})]})]})}),e.jsx(bs,{open:L,onOpenChange:F,children:e.jsxs(_s,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ss,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>F(!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(Vr,{className:"h-5 w-5"})}),((le=r==null?void 0:r.video)==null?void 0:le.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 sjt(){var o;const{slug:t}=Uo(),{data:s,isLoading:r,error:n}=HBe(t);if(M.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),M.useEffect(()=>{s!=null&&s.id&&to(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(gs,{className:"h-28 w-28 rounded-full"}),e.jsx(gs,{className:"h-6 w-48"}),e.jsx(gs,{className:"h-4 w-36"})]}),e.jsx(gs,{className:"h-12 w-full"}),e.jsx(gs,{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(Gh,{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(L1e,{card:s})]})}function VA({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=M.useState(0),[o,l]=M.useState(!1),i=M.useCallback(()=>{a(g=>(g+1)%t.length)},[t.length]),d=M.useCallback(()=>{a(g=>(g-1+t.length)%t.length)},[t.length]),u=M.useCallback(g=>{a(g)},[]);if(M.useEffect(()=>{if(t.length<=1||o)return;const g=setInterval(i,s);return()=>clearInterval(g)},[t.length,o,s,i]),!t||t.length===0)return null;const f=t[n];return e.jsxs("div",{className:It("relative w-full overflow-hidden rounded-xl",r),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsxs("div",{className:"relative aspect-[21/9] md:aspect-[3/1] w-full",children:[e.jsx("img",{src:f.image_url,alt:f.title,className:"w-full h-full object-cover rounded-t-xl"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{variant:"ghost",size:"icon",className:It("absolute left-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:d,children:e.jsx(ec,{className:"h-6 w-6"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:It("absolute right-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:i,children:e.jsx(ei,{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((g,v)=>e.jsx("button",{onClick:()=>u(v),className:It("w-2 h-2 rounded-full transition-all duration-300",v===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${v+1}`},v))})]}),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:f.title}),f.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:f.description})]}),f.link_url&&e.jsx("a",{href:f.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",children:e.jsx(Z,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:f.link_text||"Learn More"})})]})]})}function rjt(t){return"EST"}function DI(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=rjt();return`${r} ${n}`}function j5(t){const s=new Date,r=new Date(t),n=C4(r,-15),a=C4(r,30);return s>a?"ended":tne(s,{start:r,end:a})?"live":tne(s,{start:n,end:r})?"starting_soon":"upcoming"}function h_e(t){const s=j5(t);return s==="starting_soon"||s==="live"}const u3e=h_e,njt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=M.useState(new Date);M.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>h_e(_.event_date));if(o.length===0)return null;const l=o[0],i=j5(l.event_date),d=s.find(_=>_.event_id===l.id),u=(d==null?void 0:d.zoom_join_url)||l.zoom_link,f=!!d,g=i==="live",v=g?{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 ${v.container} border`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${v.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 ${v.indicator} opacity-75`}),e.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${v.indicator}`})]}),e.jsx("div",{className:`flex items-center gap-2 ${v.text} font-bold text-sm uppercase tracking-wider`,children:g?e.jsxs(e.Fragment,{children:[e.jsx(tN,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(Tn,{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:g?`Started at ${DI(new Date(l.event_date))}`:`Starts at ${DI(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:f?e.jsxs(Z,{onClick:()=>window.open(u,"_blank"),className:`${v.button} text-white gap-2`,children:[e.jsx(un,{className:"h-4 w-4"}),g?"Join Now":"Join When Live"]}):e.jsxs(Z,{variant:"outline",onClick:r,className:`${v.outlineButton} gap-2`,children:[e.jsx(xr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var m_e="Progress",p_e=100,[ajt]=Cc(m_e),[ijt,ojt]=ajt(m_e),$$e=M.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=ljt,...l}=t;(a||a===0)&&!h3e(a)&&console.error(cjt(`${a}`,"Progress"));const i=h3e(a)?a:p_e;n!==null&&!m3e(n,i)&&console.error(djt(`${n}`,"Progress"));const d=m3e(n,i)?n:null,u=fne(d)?o(d,i):void 0;return e.jsx(ijt,{scope:r,value:d,max:i,children:e.jsx(Qr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":fne(d)?d:void 0,"aria-valuetext":u,role:"progressbar","data-state":V$e(d,i),"data-value":d??void 0,"data-max":i,...l,ref:s})})});$$e.displayName=m_e;var q$e="ProgressIndicator",U$e=M.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=ojt(q$e,r);return e.jsx(Qr.div,{"data-state":V$e(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});U$e.displayName=q$e;function ljt(t,s){return`${Math.round(t/s*100)}%`}function V$e(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function fne(t){return typeof t=="number"}function h3e(t){return fne(t)&&!isNaN(t)&&t>0}function m3e(t,s){return fne(t)&&!isNaN(t)&&t<=s&&t>=0}function cjt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${p_e}\`.`}function djt(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 ${p_e} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var H$e=$$e,ujt=U$e;const wo=M.forwardRef(({className:t,value:s,...r},n)=>e.jsx(H$e,{ref:n,className:It("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(ujt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));wo.displayName=H$e.displayName;function hjt(){const{user:t,isBrokerageManager:s}=Qs(),[r,n]=M.useState([]),[a,o]=M.useState([]),[l,i]=M.useState(!1),[d,u]=M.useState(!0),f=s?"brokerage_manager":"agent";M.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}g()},[t==null?void 0:t.id,f]);const g=async()=>{if(t!=null&&t.id)try{const{data:I,error:L}=await K.from("onboarding_checklist_items").select("*").eq("target_role",f).eq("is_active",!0).order("sort_order");if(L)throw L;const{data:F,error:$}=await K.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if($)throw $;const{data:q,error:H}=await K.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(H)throw H;n(I||[]),o(F||[]),i(!!q),I&&I.length>0&&await v(I,F||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},v=async(I,L)=>{var Fe,Ie;if(!(t!=null&&t.id))return;const F=L.map(Ve=>Ve.item_id),$=I.filter(Ve=>!F.includes(Ve.id));if($.length===0)return;const[q,H,U,Q,se,te,Y,ce,oe,le,de,xe,be,ye,ve]=await Promise.all([K.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),K.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),K.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),K.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),K.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),K.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),K.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),K.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),K.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),K.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),K.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),K.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),K.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),K.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),K.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),ke={},Ge=(Fe=q.data)==null?void 0:Fe.brokerage_id;ke.share_resource=(H.count||0)>0,ke.post_community=(U.count||0)>0,ke.register_event=(Q.count||0)>0,ke.view_template=(se.count||0)>0,ke.watch_academy=(te.count||0)>0,ke.use_toolbox=(Y.count||0)>0,ke.launch_app=(ce.count||0)>0,ke.add_contact=(oe.count||0)>0,ke.create_video=(le.count||0)>0,ke.complete_touch=(de.count||0)>0,ke.add_transaction=(xe.count||0)>0,ke.add_listing=(be.count||0)>0,ke.add_deal=(ve.count||0)>0;const Ne=((Ie=ye.data)==null?void 0:Ie.map(Ve=>Ve.id))||[],Ae=[];Ge?Ae.push(K.from("profiles").select("id").eq("brokerage_id",Ge).neq("id",t.id).then(Ve=>{var dt;ke.add_agent=(((dt=Ve.data)==null?void 0:dt.length)||0)>0})):ke.add_agent=!1,Ne.length>0?(Ae.push(K.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Ne).then(Ve=>{ke.add_plan=(Ve.count||0)>0})),Ae.push(K.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Ne).then(Ve=>{ke.schedule_popby=(Ve.count||0)>0}))):(ke.add_plan=!1,ke.schedule_popby=!1),await Promise.all(Ae);const Pe=$.filter(Ve=>ke[Ve.action_type]);if(Pe.length>0){const Ve=Pe.map(Le=>({user_id:t.id,item_id:Le.id})),{error:dt}=await K.from("onboarding_checklist_progress").upsert(Ve,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!dt){const Le=Pe.map(Rt=>({item_id:Rt.id,completed_at:new Date().toISOString()}));o(Rt=>[...Rt,...Le])}}},_=async I=>{if(t!=null&&t.id)try{const{error:L}=await K.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:I});if(L)throw L;o(F=>[...F,{item_id:I,completed_at:new Date().toISOString()}])}catch(L){console.error("Error marking item complete:",L)}},b=async()=>{if(t!=null&&t.id)try{const{error:I}=await K.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(I)throw I;i(!0)}catch(I){console.error("Error dismissing checklist:",I)}},w=a.length,j=r.length,N=j>0&&w>=j,S=j>0?w/j*100:0;return{items:r,progress:a,isDismissed:l,loading:d,completedCount:w,totalCount:j,isComplete:N,progressPercentage:S,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:_,dismiss:b,refetch:g}}const mjt={add_agent:e.jsx(xr,{className:"h-4 w-4"}),share_resource:e.jsx(nd,{className:"h-4 w-4"}),post_community:e.jsx(ho,{className:"h-4 w-4"}),register_event:e.jsx(nn,{className:"h-4 w-4"}),view_template:e.jsx(Jy,{className:"h-4 w-4"}),watch_academy:e.jsx(Yu,{className:"h-4 w-4"}),use_toolbox:e.jsx(Vx,{className:"h-4 w-4"}),launch_app:e.jsx(DE,{className:"h-4 w-4"}),add_deal:e.jsx(Bx,{className:"h-4 w-4"}),add_listing:e.jsx(Hn,{className:"h-4 w-4"})},pjt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function fjt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:u}=hjt(),f=Or(),[g,v]=M.useState(!0);return r||s||a===0||o?null:e.jsxs(De,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs($t,{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($x,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Vt,{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(Z,{variant:"ghost",size:"sm",onClick:()=>v(!g),className:"h-8 w-8 p-0",children:g?e.jsx(Tg,{className:"h-4 w-4"}):e.jsx(tl,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(Vr,{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(wo,{value:l,className:"h-2"})]})]}),g&&e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(_=>{const b=i(_.id);return e.jsxs("div",{className:It("flex items-start gap-3 p-3 rounded-lg transition-colors",b?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(b)return;const w=pjt[_.action_type];w?f(w):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx(Ma,{className:"h-5 w-5 text-primary"}):e.jsx(qc,{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:mjt[_.action_type]||e.jsx(qc,{className:"h-4 w-4"})}),e.jsx("span",{className:It("font-medium",b&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:It("text-sm text-muted-foreground mt-1",b&&"line-through"),children:_.description})]})]},_.id)})})})]})}const Vg=()=>Tt({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await K.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),Im=t=>{const s=vi(),r=1e3,n=async a=>{const o=[];let l=0;for(;;){const{data:i,error:d}=await a.range(l,l+r-1);if(d)throw d;const u=i??[];if(o.push(...u),u.length{let a=K.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})},gjt=t=>Tt({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await K.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}),W$e=()=>{const t=vi();return Tt({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await K.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})},Loe=()=>{const t=ds(),s=vi();return Bt({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 K.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:d}=await K.from("innercircle_contact_tags").insert(n.map(u=>({contact_id:l.id,relationship_type_id:u})));if(d)throw d}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),dn({title:"Contact created successfully"})},onError:r=>{dn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},G$e=()=>{const t=ds();return Bt({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:d}=await K.from("innercircle_contacts").update(l).eq("id",s).select().single();if(d)throw d;if(n!==void 0&&(await K.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await K.from("innercircle_contact_tags").insert(n.map(f=>({contact_id:s,relationship_type_id:f})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),dn({title:"Contact updated successfully"})},onError:s=>{dn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},K$e=()=>{const t=ds();return Bt({mutationFn:async({contactId:s,spouseContactId:r})=>{if(r){const{error:n}=await K.from("innercircle_contacts").update({spouse_contact_id:r}).eq("id",s);if(n)throw n;const{error:a}=await K.from("innercircle_contacts").update({spouse_contact_id:s}).eq("id",r);if(a)throw a}else{const{data:n}=await K.from("innercircle_contacts").select("spouse_contact_id").eq("id",s).single(),a=n==null?void 0:n.spouse_contact_id,{error:o}=await K.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",s);if(o)throw o;if(a){const{error:l}=await K.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"]}),dn({title:"Spouse link updated"})},onError:s=>{dn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},f_e=()=>{const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),dn({title:"Contact deleted successfully"})},onError:s=>{dn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},Doe=()=>Tt({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await K.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),xjt=t=>Tt({queryKey:["action-scripts",t],queryFn:async()=>{let s=K.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),yjt=()=>Tt({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await K.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),vjt=()=>{const t=ds(),s=vi();return Bt({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await K.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"]}),dn({title:"Plan created successfully"})},onError:r=>{dn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},_jt=()=>{const t=ds(),s=vi();return Bt({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await K.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 K.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 d=a.items.map(f=>({plan_id:l.id,month_number:f.month_number,action_type_id:f.action_type_id,default_script_id:f.default_script_id,notes:f.notes})),{error:u}=await K.from("touchpoint_plan_items").insert(d);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),dn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{dn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},bjt=()=>{const t=ds();return Bt({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await K.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"]}),dn({title:"Plan updated successfully"})}})},wjt=()=>{const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),dn({title:"Plan deleted successfully"})}})},jjt=()=>{const t=ds();return Bt({mutationFn:async({planId:s,items:r})=>{if(await K.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await K.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"]}),dn({title:"Plan schedule updated"})}})},kjt=()=>{const t=ds();return Bt({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await K.auth.getUser(),{data:i,error:d}=await K.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(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),dn({title:"Script created successfully"})},onError:s=>{dn({title:"Error creating script",description:s.message,variant:"destructive"})}})},Njt=()=>{const t=vi();return Tt({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await K.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},Sjt=()=>{const t=ds(),s=vi();return Bt({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await K.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await K.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await K.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"]}),dn({title:"Plan enrollment updated"})}})},Ooe=(t=7)=>{const s=vi();return Tt({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await K.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},Z$e=()=>{const t=vi();return Tt({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await K.from("contact_touch_logs").select("contact_id, completed_at").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})},Cjt=(t=90)=>{const{data:s}=Im(),{data:r}=Z$e();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=ds(),s=vi();return Bt({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:d}=await K.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(d)throw d;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"]}),dn({title:"Action completed!"});try{const[l,i]=await Promise.all([K.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),K.from("action_types").select("name").eq("id",n.actionTypeId).single()]),d=(a=l.data)==null?void 0:a.email,u=((o=i.data)==null?void 0:o.name)||"Touch";d&&K.functions.invoke("boldtrail-sync",{body:{action:"push_touch",contact_email:d,touch_type:u,touch_notes:n.notes||null,touch_date:n.completedAt||r.completed_at}}).catch(()=>{})}catch{}}})},Y$e="agentos_weekly_touch_goal",p3e=20,gne=()=>{if(typeof window>"u")return p3e;const t=localStorage.getItem(Y$e);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return p3e},X$e=t=>{localStorage.setItem(Y$e,t.toString())},Q$e=()=>{const{data:t}=Ooe(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(d=>new Date(d.completed_at).toDateString()));let i=new Date(s);for(;l.has(i.toDateString());)a++,i.setDate(i.getDate()-1)}const o=gne();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},Mjt=()=>{const t=vi();return Tt({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await K.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})},Tjt=()=>{const t=ds();return vi(),Bt({mutationFn:async()=>{const{data:s}=await K.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await K.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await K.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 d=s.find(u=>u.relationship_type_id===i.relationship_type_id);d&&!a.has(`${l.id}-${d.plan_id}`)&&o.push({contact_id:l.id,plan_id:d.plan_id,relationship_type_id:i.relationship_type_id})}if(o.length>0){const{error:l}=await K.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&dn({title:`${s} contact(s) enrolled in plans`})}})},J$e=()=>{const t=vi(),{data:s}=Mjt(),{data:r}=Ooe(30);return Tt({queryKey:["today-actions",t,s==null?void 0:s.length,r==null?void 0:r.length],queryFn:async()=>{var b;if(!s||s.length===0)return[];const{data:n}=await K.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(w=>w.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),d=new Set((r==null?void 0:r.filter(w=>new Date(w.completed_at)>=i).map(w=>`${w.contact_id}-${w.action_type_id}`))||[]);for(const w of s){if(!((b=w.plan)!=null&&b.items)||w.plan.items.length===0||!w.contact||a.has(w.contact_id))continue;const j=new Date(w.cycle_start_date),S=Math.floor((o.getTime()-j.getTime())/(30.44*24*60*60*1e3))%12+1,A=w.plan.items.find(I=>I.month_number===S);if(A&&A.action_type){const I=`${w.contact_id}-${A.action_type_id}`;if(!d.has(I)){const{data:L}=await K.from("relationship_types").select("name").eq("id",w.relationship_type_id).single();l.push({contact:w.contact,actionType:A.action_type,script:A.default_script||void 0,planName:w.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:S})}}}const u=5,f=o.getDate(),g=l.sort((w,j)=>w.contact.first_name.localeCompare(j.contact.first_name)),v=(f-1)%Math.max(1,g.length);return[...g.slice(v),...g.slice(0,v)].slice(0,u)},enabled:!!t&&!!s})};function Ajt(){const t=Or(),{data:s,isLoading:r}=J$e(),{data:n}=Im(),a=Q$e(),[o,l]=M.useState(gne()),[i,d]=M.useState(""),[u,f]=M.useState(!1);M.useEffect(()=>{l(gne())},[]);const g=()=>{const F=parseInt(i,10);if(isNaN(F)||F<1){dn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(F),X$e(F),f(!1),dn({title:"Goal updated",description:`Weekly touch goal set to ${F}`})},v=()=>{d(o.toString()),f(!0)},_=qh(new Date),b=hl(_,7),w=F=>{if(!F)return null;const $=F.split(/[-/T]/);if($.length<3)return null;const q=parseInt($[1],10)-1,H=parseInt($[2],10);return isNaN(q)||isNaN(H)?null:new Date(_.getFullYear(),q,H)},j=(n==null?void 0:n.map(F=>{const $=w(F.birthday),q=w(F.home_anniversary),H=[];return $&&$>=_&&$<=b&&H.push({contact:F,type:"birthday",date:$,isToday:ll($,_)}),q&&q>=_&&q<=b&&H.push({contact:F,type:"anniversary",date:q,isToday:ll(q,_)}),H}).flat().sort((F,$)=>F.date.getTime()-$.date.getTime()).slice(0,3))||[],N=(n==null?void 0:n.filter(F=>{const $=w(F.birthday),q=w(F.home_anniversary);return $&&ll($,_)||q&&ll(q,_)}).length)||0,S=(s==null?void 0:s.length)||0,A=N+S,I=(a==null?void 0:a.actionsThisWeek)||0,L=(a==null?void 0:a.streak)||0;return r?e.jsx(De,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):e.jsxs(De,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs($t,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:L>0&&e.jsxs(nt,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(dp,{className:"h-3 w-3"}),L," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[A," 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(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Z,{size:"sm",variant:"outline",className:"gap-1.5",onClick:F=>{F.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(pc,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(Z,{size:"sm",variant:"outline",className:"gap-1.5",onClick:F=>{F.stopPropagation(),t("/mission-control")},children:[e.jsx(ga,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(Z,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:F=>{F.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(Z,{size:"sm",variant:"outline",className:"gap-1.5",onClick:F=>{F.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(Pi,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(Z,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:F=>{F.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(Bx,{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(Mm,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(bs,{open:u,onOpenChange:f,children:[e.jsx(Si,{asChild:!0,children:e.jsx("button",{onClick:v,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(_s,{className:"sm:max-w-[360px]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Set Weekly Goal"}),e.jsx(Kr,{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(_e,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(Re,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:F=>d(F.target.value),placeholder:"20",onKeyDown:F=>{F.key==="Enter"&&g()}})]}),e.jsx(Z,{onClick:g,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(wo,{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"]})]}),j.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Lh,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:j.map((F,$)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${F.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:q=>{q.stopPropagation(),t(`/mission-control/contacts/${F.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[F.type==="birthday"?e.jsx(Lh,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(Hn,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[F.contact.first_name," ",F.contact.last_name]}),F.isToday&&e.jsx(nt,{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:F.isToday?F.type==="birthday"?"🎂":"🏠":js(F.date,"EEE, MMM d")}),e.jsx(ei,{className:"h-3 w-3"})]})]},`${F.contact.id}-${F.type}-${$}`))})]}),e.jsxs(Z,{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(Ai,{className:"h-4 w-4"})]})]})]})}function Ejt(t){return Tt({queryKey:["brokerage-content-categories",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("brokerage_content_categories").select("*").eq("brokerage_id",t).order("sort_order");if(r)throw r;return s},enabled:!!t})}function Pjt(t,s){return Tt({queryKey:["brokerage-content",t,s],queryFn:async()=>{if(!t)return[];let r=K.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 Ijt(t,s=4){return Tt({queryKey:["brokerage-content-recent",t,s],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await K.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 Ljt(t){const s=ds();return Bt({mutationFn:async r=>{const{data:n,error:a}=await K.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 Djt(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("brokerage_content").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content"]}),t.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function Ojt(t){const s=ds();return Bt({mutationFn:async r=>{const{data:n,error:a}=await K.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 Rjt(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("brokerage_content_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function Fjt(t){const s=ds();return Bt({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 K.from("brokerage_content_categories").upsert(r,{onConflict:"brokerage_id,name"});if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}const zjt={video:dl,pdf:Un,link:Al,event:nn,graphic:El},Bjt={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 $jt(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 qjt(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 Ujt({item:t}){const s=Or(),r=zjt[t.content_type]||Al,n=Bjt[t.content_type]||"",[a,o]=M.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?$jt(t.url):null);M.useEffect(()=>{l||!t.url||t.content_type!=="video"||!qjt(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(d=>d.ok?d.json():null).then(d=>{d!=null&&d.thumbnail_url&&o(d.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,l]);const i=l||a;return e.jsxs(De,{className:"group cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",onClick:()=>s(`/brokerage-content/${t.id}`),children:[i?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:i,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/20 flex items-center justify-center",children:e.jsx(r,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(nt,{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:js(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function Vjt(){const{brokerageId:t}=Qs(),s=Or(),{data:r=[],isLoading:n}=Ijt(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(_a,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Brokerage Content"})]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>s("/brokerage-content"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ai,{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(Ujt,{item:a},a.id))})]})}const eqe=()=>Tt({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await K.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),tqe=t=>{const{user:s,brokerageId:r}=Qs();return Tt({queryKey:["listings",t,r],queryFn:async()=>{let n=K.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 K.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const d=i.map(g=>g.id);let u=K.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",d);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:f}=await u;if(f){const g=new Set(l.map(_=>_.id)),v=f.filter(_=>!g.has(_.id));l=[...l,...v]}}}switch(t==null?void 0:t.sortBy){case"updated":l.sort((i,d)=>new Date(d.updated_at).getTime()-new Date(i.updated_at).getTime());break;case"price_asc":l.sort((i,d)=>i.price-d.price);break;case"price_desc":l.sort((i,d)=>d.price-i.price);break;default:l.sort((i,d)=>new Date(d.created_at).getTime()-new Date(i.created_at).getTime())}return l}})},sqe=()=>{const{user:t}=Qs();return Tt({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},rqe=t=>{const{user:s}=Qs();return Tt({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await K.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 K.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},Hjt=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await K.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"]})}})},Wjt=()=>{const t=ds();return Bt({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await K.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"]})}})},Gjt=()=>{const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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]})}})},nqe=()=>{const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},Kjt=()=>{const t=ds();return Bt({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await K.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"]})}})},Zjt=()=>{const t=ds();return Bt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await K.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"]})}})},Yjt=()=>{const t=ds();return Bt({mutationFn:async({photos:s})=>{var o;const r=s.map(l=>K.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"]})}})},Xjt=()=>{const t=ds();return Bt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await K.from("listing_photos").update({is_primary:!1}).eq("listing_id",r);if(n)throw n;const{error:a}=await K.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"]})}})},Qjt=()=>{const{user:t}=Qs();return Tt({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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})},aqe=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await K.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await K.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await K.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},iqe=t=>{const{user:s}=Qs();return Tt({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await K.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},Jjt=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await K.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await K.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await K.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},ekt=t=>{const{user:s}=Qs();return Tt({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await K.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},tkt=()=>{const{user:t}=Qs();return Bt({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await K.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},skt=()=>{const{user:t}=Qs();return Tt({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([K.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),K.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})},rkt=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async({listingId:r,listingAgentId:n,buyerName:a,buyerType:o,notes:l})=>{if(!s)throw new Error("Not authenticated");const{data:i,error:d}=await K.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(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["my-referrals"]})}})},nkt=()=>Tt({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await K.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 d=s.get(i);d?d.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 K.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 d;const i=a.get(l.agent_id);i?i.count++:a.set(l.agent_id,{name:((d=l.agent)==null?void 0:d.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}}}),akt=()=>{const{user:t,brokerageId:s}=Qs();return Tt({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await K.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 K.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})},oqe=({className:t,variant:s="default"})=>e.jsx(nt,{variant:"outline",className:It("text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0 h-4",s==="default"?"border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10":"border-muted-foreground/30 text-muted-foreground",t),children:"Beta"}),ikt={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"},okt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function lkt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function ckt(){const t=Or(),{data:s,isLoading:r}=eqe(),{data:n,isLoading:a}=tqe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(f=>f.is_approved&&f.is_public))||[],l=o.filter(f=>f.is_featured),i=o.filter(f=>!f.is_featured),d=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(De,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),e.jsx(oqe,{})]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ai,{className:"h-4 w-4"})]})]}),d.length===0?e.jsx(De,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Hn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(Z,{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:d.map(f=>{var v,_;const g=((v=f.photos)==null?void 0:v.find(b=>b.is_primary))||((_=f.photos)==null?void 0:_[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${f.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:[g!=null&&g.photo_url?e.jsx("img",{src:g.photo_url,alt:`${f.city}, ${f.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(Hn,{className:"h-8 w-8 text-muted-foreground/50"})}),f.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(nt,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Gn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(nt,{className:`text-[10px] px-1.5 py-0.5 ${ikt[f.status]}`,children:okt[f.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:lkt(f.price)}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[f.city,", ",f.state]}),(f.bedrooms||f.bathrooms)&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[f.bedrooms&&`${f.bedrooms} bed`,f.bedrooms&&f.bathrooms&&" · ",f.bathrooms&&`${f.bathrooms} bath`]})]})]},f.id)})})]})}function lqe(t=10,s){return Tt({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await K.from("user_roles").select("user_id").eq("role","admin"),n=new Set((r==null?void 0:r.map(v=>v.user_id))||[]);let a=null;if(s){const{data:v}=await K.from("profiles").select("id").eq("brokerage_id",s);a=new Set((v==null?void 0:v.map(_=>_.id))||[])}const{data:o,error:l}=await K.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(v=>!n.has(v.user_id));a&&(i=i.filter(v=>a.has(v.user_id)));const d=i.slice(0,t),u=d.map(v=>v.user_id),{data:f}=await K.from("profiles").select("id, name").in("id",u),g=new Map((f==null?void 0:f.map(v=>[v.id,{name:v.name}]))||[]);return d.map(v=>({user_id:v.user_id,total_points:v.total_points,total_events_attended:v.total_events_attended,current_streak:v.current_streak,profile:g.get(v.user_id)||null}))}})}function cqe(t){return Tt({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function dqe(t){return Tt({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function uqe(t,s){return Tt({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await K.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await K.from("user_roles").select("user_id").eq("role","admin"),a=new Set((n==null?void 0:n.map(d=>d.user_id))||[]),{data:o,error:l}=await K.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(d=>!a.has(d.user_id)))||[];if(s){const{data:d}=await K.from("profiles").select("id").eq("brokerage_id",s),u=new Set((d==null?void 0:d.map(f=>f.id))||[]);i=i.filter(f=>u.has(f.user_id))}return i.length+1},enabled:!!t})}function dkt(){const{user:t,brokerageId:s,isAdmin:r}=Qs();Or();const n=!!s,[a,o]=M.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:d}=lqe(5,l()),{data:u}=cqe(t==null?void 0:t.id),{data:f}=uqe(t==null?void 0:t.id,l()),{data:g}=dqe(t==null?void 0:t.id),v=r||n,_=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(d)return e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...Array(v?5:3)].map((w,j)=>e.jsx(gs,{className:"h-10 w-full"},j))})})]});const b=w=>w===0?e.jsx(so,{className:"h-4 w-4 text-yellow-500 mx-auto"}):w===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):w===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:w+1});if(v){const w=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(De,{children:[e.jsxs($t,{className:"pb-2",children:[e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4 text-yellow-500"}),_()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(Z,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(Z,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(Oe,{children:[!r&&u&&e.jsx("div",{className:"mb-3 p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rank:"}),e.jsxs("span",{className:"font-bold text-primary",children:["#",f||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:u.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:u.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[w.map((j,N)=>{var S,A,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${j.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":N===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(N)}),e.jsx(mn,{className:"h-6 w-6",children:e.jsx(pn,{className:"text-xs",children:((A=(S=j.profile)==null?void 0:S.name)==null?void 0:A.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=j.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:j.total_points})]},j.user_id)}),w.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(yo,{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(uo,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(ei,{className:"h-4 w-4"})]})]})]})}return e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Oe,{children:u?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:u.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Points"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:u.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events Attended"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dp,{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," 🔥"]})]}),g&&g.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(dc,{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:[g.slice(0,4).map(w=>e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-600 border border-yellow-500/20",children:w.badge_name},w.id)),g.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",g.length-4," more"]})]})]}),e.jsxs(yo,{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(uo,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(ei,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Gn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(yo,{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(uo,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(ei,{className:"h-4 w-4"})]})]})})]})}const gL=()=>Tt({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await K.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),hqe=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{data:n,error:a}=await K.from("lead_sources").insert({name:r,owner_user_id:s==null?void 0:s.id,sort_order:100}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),ge.success("Lead source added")},onError:r=>{ge.error("Failed to add lead source"),console.error(r)}})},x_e=(t,s)=>{const{user:r,isAdmin:n}=Qs(),a=n&&s?s:r==null?void 0:r.id;return Tt({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=K.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})},mqe=t=>{const{user:s,isAdmin:r}=Qs(),n=r&&t?t:s==null?void 0:s.id;return Tt({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await K.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})},Roe=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{data:n,error:a}=await K.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"]}),ge.success("Transaction added")},onError:r=>{ge.error("Failed to add transaction"),console.error(r)}})},ukt=()=>{const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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"]}),ge.success("Transaction updated")},onError:s=>{ge.error("Failed to update transaction"),console.error(s)}})},hkt=()=>{const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),ge.success("Transaction deleted")},onError:s=>{ge.error("Failed to delete transaction"),console.error(s)}})},pqe=(t,s)=>{const{user:r,isAdmin:n}=Qs(),a=n&&s?s:r==null?void 0:r.id;return Tt({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await K.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},mkt=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{data:n,error:a}=await K.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]}),ge.success("Goals saved")},onError:r=>{ge.error("Failed to save goals"),console.error(r)}})},Foe=()=>{const{user:t}=Qs();return Tt({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},pkt=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{data:n,error:a}=await K.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"]}),ge.success("Settings saved")},onError:r=>{ge.error("Failed to save settings"),console.error(r)}})},fqe=(t,s)=>{const{data:r,isLoading:n}=x_e(t,s),{data:a,isLoading:o}=mqe(s),{data:l}=Foe(),i=(l==null?void 0:l.show_commission)??!0,d=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 f=u.filter(L=>L.transaction_type==="buyer").length,g=u.filter(L=>L.transaction_type==="seller").length,v=u.reduce((L,F)=>L+Number(F.sale_price),0),_=u.reduce((L,F)=>L+(Number(F.commission_amount)||0),0),b=u.reduce((L,F)=>{const $=Number(F.commission_amount)||0;if(!$)return L;let q=$;return F.brokerage_split_pct&&(q-=$*(F.brokerage_split_pct/100)),F.team_split_pct&&(q-=$*(F.team_split_pct/100)),F.franchise_fee_pct&&(q-=$*(F.franchise_fee_pct/100)),F.referral_fee_pct&&(q-=$*(F.referral_fee_pct/100)),F.transaction_fee&&(q-=F.transaction_fee),L+Math.max(0,q)},0),w={};u.forEach(L=>{var $;const F=(($=L.lead_source)==null?void 0:$.name)||"Unknown";w[F]=(w[F]||0)+1});const j=Object.entries(w).map(([L,F])=>({name:L,count:F})).sort((L,F)=>F.count-L.count),N=j[0]||null,S={};u.forEach(L=>{const F=new Date(L.close_date).toLocaleString("default",{month:"short"});S[F]=(S[F]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(L=>({month:L,count:S[L]||0}));return{totalTransactions:u.length,buyerCount:f,sellerCount:g,totalVolume:v,averagePrice:u.length>0?v/u.length:0,totalCommission:i?_:0,totalNetToAgent:i?b:0,topLeadSource:N,transactionsByMonth:I,leadSourceBreakdown:j}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},fkt=()=>{const{isAdmin:t}=Qs();return Tt({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await K.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 K.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},Jv={recency:40,touchpoints:30,transactions:20},f3e={warm:70,cooling:40};function gkt(t){return t===null?0:t<=14?Jv.recency:t<=30?Jv.recency*.85:t<=60?Jv.recency*.65:t<=90?Jv.recency*.4:t<=180?Jv.recency*.2:Jv.recency*.05}function xkt(t){const s=Math.min(t/12,1);return Math.round(Jv.touchpoints*s)}function ykt(t){return t?Jv.transactions:0}function vkt(){return 0}function _kt(t){return t>=f3e.warm?"warm":t>=f3e.cooling?"cooling":"at-risk"}function y_e(){const{data:t,isLoading:s}=Im(),{data:r}=Z$e(),{data:n}=Ooe(365),{data:a}=mqe(),o=M.useMemo(()=>{if(!t)return[];const i=new Date,d=v9e(i,12),u={};n==null||n.forEach(g=>{new Date(g.completed_at)>=d&&(u[g.contact_id]=(u[g.contact_id]||0)+1)});const f=new Set((a==null?void 0:a.filter(g=>g.contact_id).map(g=>g.contact_id))||[]);return t.map(g=>{const v=(r==null?void 0:r[g.id])||null,_=v?zg(i,new Date(v)):null,b=u[g.id]||0,w=f.has(g.id),j=gkt(_),N=xkt(b),S=ykt(w),A=vkt(),I=Math.round(j+N+S+A),L={score:I,status:_kt(I),breakdown:{recency:Math.round(j),touchpoints:Math.round(N),transactions:Math.round(S),referrals:Math.round(A)},lastTouchDate:v,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:w};return{...g,relationshipScore:L}})},[t,r,n,a]),l=M.useMemo(()=>{const i=o.filter(v=>v.relationshipScore.status==="warm").length,d=o.filter(v=>v.relationshipScore.status==="cooling").length,u=o.filter(v=>v.relationshipScore.status==="at-risk").length,f=o.length,g=f>0?Math.round(o.reduce((v,_)=>v+_.relationshipScore.score,0)/f):0;return{warm:i,cooling:d,atRisk:u,total:f,averageScore:g}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function gqe(){const t=Or(),{stats:s,contactsWithScores:r,isLoading:n}=y_e();if(n)return e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(gs,{className:"h-5 w-40"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(gs,{className:"h-20 w-full"}),e.jsx(gs,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(Z,{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(d=>d.relationshipScore.status==="at-risk").sort((d,u)=>d.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(De,{children:[e.jsxs($t,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Vc,{className:"h-5 w-5 text-emerald-500"}),"Relationship Health"]}),e.jsx("span",{className:"text-2xl font-bold",children:s.averageScore})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Average score across ",s.total," contacts"]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-500"}),e.jsx("span",{children:"Warm"})]}),e.jsxs("span",{className:"font-medium",children:[s.warm," (",a,"%)"]})]}),e.jsx(wo,{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(wo,{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(wo,{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(rN,{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(d=>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/${d.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:[d.first_name," ",d.last_name]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:d.relationshipScore.daysSinceTouch===null?"Never":`${d.relationshipScore.daysSinceTouch}d`}),e.jsx(ei,{className:"h-3 w-3"})]})]},d.id))})]}),e.jsxs(Z,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(ei,{className:"h-4 w-4 ml-1"})]})]})]})}const bkt=()=>{var oe;const{user:t,isAdmin:s}=Qs(),r=Or(),[n,a]=M.useState([]),[o,l]=M.useState([]),[i,d]=M.useState([]),[u,f]=M.useState([]),[g,v]=M.useState([]),[_,b]=M.useState([]),[w,j]=M.useState(new Set),[N,S]=M.useState([]),[A,I]=M.useState([]),[L,F]=M.useState([]),[$,q]=M.useState(null),[H,U]=M.useState(!0);M.useEffect(()=>{Q()},[t]);const Q=async()=>{var le,de,xe,be,ye;try{const[ve,ke,Ge,Ne,Ae,Pe,Fe,Ie,Ve,dt,Le]=await Promise.all([K.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),K.from("app_tiles").select("*").order("name"),K.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),K.from("events").select("*").order("event_date",{ascending:!0}),K.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),K.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),K.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),K.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),K.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),K.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),K.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(le=Le.data)!=null&&le.name&&q(Le.data.name);const Rt=((de=ve.data)==null?void 0:de.map(mt=>mt.tag))||[],fe=new Set(((xe=Ge.data)==null?void 0:xe.map(mt=>mt.app_id))||[]);j(fe);const at=(((be=ke.data)==null?void 0:be.filter(mt=>!mt.required_tags||mt.required_tags.length===0?!0:mt.required_tags.some(He=>Rt.includes(He))))||[]).sort((mt,He)=>mt.name==="LevelUp Members Portal"?-1:He.name==="LevelUp Members Portal"?1:0);a(at.slice(0,6));const rt=((ye=Ne.data)==null?void 0:ye.filter(mt=>j5(mt.event_date)!=="ended"))||[];l(rt.slice(0,4)),S(Ae.data||[]),d(Pe.data||[]),f(Fe.data||[]),v(Ie.data||[]),b(Ve.data||[]);const je=dt.data||[];I(je.filter(mt=>mt.placement==="top")),F(je.filter(mt=>mt.placement==="between"))}catch(ve){console.error("Error loading dashboard:",ve),ge.error("Failed to load dashboard data")}finally{U(!1)}},se=async le=>{var xe;const de=window.open("about:blank","_blank");try{await K.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:le.app_id,app_name:le.name,user_agent:navigator.userAgent});const{data:be,error:ye}=await K.functions.invoke("sso-launch",{body:{app_id:le.app_id}});if(ye)throw ye;be!=null&&be.redirect_url?de&&!de.closed?(de.location.href=be.redirect_url,(xe=de.focus)==null||xe.call(de)):window.location.assign(be.redirect_url):(de==null||de.close(),ge.error("Launch link unavailable"))}catch(be){de==null||de.close(),console.error("Error launching app:",be),ge.error("Failed to launch app")}},te=le=>N==null?void 0:N.some(de=>de.event_id===le),Y=le=>{const de=N==null?void 0:N.find(xe=>xe.event_id===le);return de==null?void 0:de.zoom_join_url};if(H)return e.jsx(Ms,{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=le=>L.filter(de=>de.section_after===le);return e.jsxs(Ms,{title:"Dashboard",children:[e.jsx(njt,{events:o,registrations:N,onNavigateToEvents:()=>r("/events")}),A.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(VA,{banners:A})}),e.jsx(fjt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",($||((oe=t==null?void 0:t.user_metadata)==null?void 0:oe.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(Ajt,{}),e.jsx(gqe,{}),e.jsx(dkt,{})]}),e.jsx(Vjt,{}),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(Z,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ai,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(De,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(nn,{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(le=>{const de=te(le.id),xe=Y(le.id)||le.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 ${u3e(le.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[u3e(le.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(tN,{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(le.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(le.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:le.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(le.event_date))," at ",DI(new Date(le.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:de?e.jsxs(Z,{size:"sm",variant:"default",className:"gap-1",onClick:be=>{be.stopPropagation(),window.open(xe,"_blank")},children:[e.jsx(un,{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(ei,{className:"h-4 w-4"})]})})]},le.id)})})]}),ce("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(VA,{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(Z,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ai,{className:"h-4 w-4"})]})]}),g.length===0?e.jsx(De,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(mm,{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:g.map(le=>e.jsxs("div",{onClick:()=>r(`/academy/${le.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:[le.thumbnail_url?e.jsx("img",{src:le.thumbnail_url,alt:le.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(mm,{className:"h-8 w-8 text-muted-foreground/50"})}),le.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:le.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:le.title})})]},le.id))})]}),ce("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(VA,{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(Z,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ai,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(De,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Oh,{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(le=>e.jsxs("div",{onClick:()=>r(`/toolbox/${le.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:le.featured_image_url?e.jsx("img",{src:le.featured_image_url,alt:le.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(Oh,{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:le.name})})]},le.id))})]}),ce("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(VA,{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(Z,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ai,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(De,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(H1,{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(le=>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:le.preview_image_url?e.jsx("img",{src:le.preview_image_url,alt:le.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(H1,{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:le.name})})]},le.id))})]}),ce("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(VA,{banners:ce("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(ckt,{})}),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(Z,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ai,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(De,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Cg,{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(le=>{const de=w.has(le.id);return e.jsxs("div",{onClick:()=>se(le),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:le.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:le.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:le.description})]}),de&&e.jsx(Cg,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},le.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(Z,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ai,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(De,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(gn,{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:_.map(le=>e.jsxs("div",{onClick:()=>window.open(le.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:le.preview_image_url?e.jsx("img",{src:le.preview_image_url,alt:le.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(gn,{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:le.name}),le.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:le.description})]})]},le.id))})]})]})};var xqe="AlertDialog",[wkt]=Cc(xqe,[R7e]),W0=R7e(),yqe=t=>{const{__scopeAlertDialog:s,...r}=t,n=W0(s);return e.jsx(ioe,{...n,...r,modal:!0})};yqe.displayName=xqe;var jkt="AlertDialogTrigger",vqe=M.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W0(r);return e.jsx(E1e,{...a,...n,ref:s})});vqe.displayName=jkt;var kkt="AlertDialogPortal",_qe=t=>{const{__scopeAlertDialog:s,...r}=t,n=W0(s);return e.jsx(ooe,{...n,...r})};_qe.displayName=kkt;var Nkt="AlertDialogOverlay",bqe=M.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W0(r);return e.jsx(aM,{...a,...n,ref:s})});bqe.displayName=Nkt;var k5="AlertDialogContent",[Skt,Ckt]=wkt(k5),Mkt=_8e("AlertDialogContent"),wqe=M.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=W0(r),l=M.useRef(null),i=Sa(s,l),d=M.useRef(null);return e.jsx(Fxt,{contentName:k5,titleName:jqe,docsSlug:"alert-dialog",children:e.jsx(Skt,{scope:r,cancelRef:d,children:e.jsxs(iM,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Sr(a.onOpenAutoFocus,u=>{var f;u.preventDefault(),(f=d.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(Mkt,{children:n}),e.jsx(Akt,{contentRef:l})]})})})});wqe.displayName=k5;var jqe="AlertDialogTitle",kqe=M.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W0(r);return e.jsx(aL,{...a,...n,ref:s})});kqe.displayName=jqe;var Nqe="AlertDialogDescription",Sqe=M.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W0(r);return e.jsx(iL,{...a,...n,ref:s})});Sqe.displayName=Nqe;var Tkt="AlertDialogAction",Cqe=M.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W0(r);return e.jsx(oL,{...a,...n,ref:s})});Cqe.displayName=Tkt;var Mqe="AlertDialogCancel",Tqe=M.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=Ckt(Mqe,r),o=W0(r),l=Sa(s,a);return e.jsx(oL,{...o,...n,ref:l})});Tqe.displayName=Mqe;var Akt=({contentRef:t})=>{const s=`\`${k5}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${k5}\` by passing a \`${Nqe}\` 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 \`${k5}\`. 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 M.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},Ekt=yqe,Pkt=vqe,Ikt=_qe,Aqe=bqe,Eqe=wqe,Pqe=Cqe,Iqe=Tqe,Lqe=kqe,Dqe=Sqe;const uc=Ekt,Sh=Pkt,Lkt=Ikt,Oqe=M.forwardRef(({className:t,...s},r)=>e.jsx(Aqe,{className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));Oqe.displayName=Aqe.displayName;const Gl=M.forwardRef(({className:t,...s},r)=>e.jsxs(Lkt,{children:[e.jsx(Oqe,{}),e.jsx(Eqe,{ref:r,className:It("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));Gl.displayName=Eqe.displayName;const Kl=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-2 text-center sm:text-left",t),...s});Kl.displayName="AlertDialogHeader";const Zl=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Zl.displayName="AlertDialogFooter";const Yl=M.forwardRef(({className:t,...s},r)=>e.jsx(Lqe,{ref:r,className:It("text-lg font-semibold",t),...s}));Yl.displayName=Lqe.displayName;const Xl=M.forwardRef(({className:t,...s},r)=>e.jsx(Dqe,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));Xl.displayName=Dqe.displayName;const Ml=M.forwardRef(({className:t,...s},r)=>e.jsx(Pqe,{ref:r,className:It(TI(),t),...s}));Ml.displayName=Pqe.displayName;const Ql=M.forwardRef(({className:t,...s},r)=>e.jsx(Iqe,{ref:r,className:It(TI({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));Ql.displayName=Iqe.displayName;const Dkt=[{key:"contacts",label:"Contacts",icon:ga,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:Zk,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Oh,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:Cn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Hn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:qE,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Pi,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:cp,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:nu,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:lf,description:"Create and manage smart presentations"}];function Okt(){var $;const{user:t}=Qs(),[s,r]=M.useState([]),[n,a]=M.useState(!0),[o,l]=M.useState(!1),[i,d]=M.useState(!1),[u,f]=M.useState(null),[g,v]=M.useState({email:"",name:"",password:""}),[_,b]=M.useState("create"),[w,j]=M.useState(!1),[N,S]=M.useState(null);M.useEffect(()=>{t&&A()},[t]);const A=async()=>{if(t){a(!0);try{const{data:q,error:H}=await K.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(H)throw H;if(q&&q.length>0){const U=q.map(te=>te.assistant_id),{data:Q}=await K.from("profiles").select("id, name, email").in("id",U),se=q.map(te=>{const Y=Q==null?void 0:Q.find(ce=>ce.id===te.assistant_id);return{...te,permissions:te.permissions,assistant_profile:Y?{name:Y.name||"",email:Y.email||""}:void 0}});r(se)}else r([])}catch(q){console.error("Error loading assistants:",q)}finally{a(!1)}}},I=async()=>{if(t){if(_==="link"){if(!g.email.trim()){ge.error("Please enter the assistant's email");return}j(!0);try{const{data:{session:q}}=await K.auth.getSession();if(!q)throw new Error("Not authenticated");const{data:H,error:U}=await K.from("profiles").select("id, name, email").eq("email",g.email.trim().toLowerCase()).single();if(U||!H){ge.error("No account found with that email. Try creating a new assistant instead.");return}const{data:Q}=await K.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",H.id);if(Q&&Q.length>0){ge.error("This assistant is already assigned to you");return}const se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:H.id,role:"assistant",action:"add",agentId:t.id})}),te=await se.json();if(!se.ok)throw new Error(te.error||"Failed to assign assistant role");const{error:Y}=await K.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:H.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(Y)throw Y;ge.success(`${H.name||H.email} linked as your assistant`),l(!1),v({email:"",name:"",password:""}),A()}catch(q){console.error("Error linking assistant:",q),ge.error(q.message||"Failed to link assistant")}finally{j(!1)}return}if(!g.email.trim()||!g.name.trim()||!g.password.trim()){ge.error("Please fill in all fields");return}if(g.password.length<6){ge.error("Password must be at least 6 characters");return}j(!0);try{const{data:{session:q}}=await K.auth.getSession();if(!q)throw new Error("Not authenticated");const H=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({email:g.email.trim(),password:g.password,name:g.name.trim(),purpose:"assistant"})}),U=await H.json();if(!H.ok)throw new Error(U.error||"Failed to create assistant account");const Q=U.userId||U.id;if(!Q)throw new Error("No user ID returned");const se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:Q,role:"assistant",action:"add",agentId:t.id})}),te=await se.json();if(!se.ok)throw new Error(te.error||"Failed to assign assistant role");const{error:Y}=await K.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:Q,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(Y)throw Y;ge.success(`Assistant account created for ${g.name.trim()}`),l(!1),v({email:"",name:"",password:""}),A()}catch(q){console.error("Error adding assistant:",q),ge.error(q.message||"Failed to add assistant")}finally{j(!1)}}},L=async()=>{if(!(!u||!t))try{const{data:{session:q}}=await K.auth.getSession();if(!q)throw new Error("Not authenticated");const{error:H}=await K.from("agent_assistant_assignments").delete().eq("id",u.id);if(H)throw H;const{data:U}=await K.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!U||U.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),ge.success("Assistant removed"),d(!1),f(null),A()}catch(q){console.error("Error removing assistant:",q),ge.error(q.message||"Failed to remove assistant")}},F=async(q,H,U)=>{S(q);try{const Q=s.find(Y=>Y.id===q);if(!Q)return;const se={...Q.permissions,[H]:U},{error:te}=await K.from("agent_assistant_assignments").update({permissions:se}).eq("id",q);if(te)throw te;r(Y=>Y.map(ce=>ce.id===q?{...ce,permissions:se}:ce))}catch(Q){console.error("Error updating permissions:",Q),ge.error("Failed to update permissions")}finally{S(null)}};return n?e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(_r,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(Z,{size:"sm",onClick:()=>{b("create"),l(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No assistant assigned. Add one to help manage your contacts, deals, and more."}):e.jsx("div",{className:"space-y-4",children:s.map(q=>{var H,U,Q,se;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(mn,{className:"h-10 w-10",children:e.jsx(pn,{children:((U=(H=q.assistant_profile)==null?void 0:H.name)==null?void 0:U.split(" ").map(te=>te[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Q=q.assistant_profile)==null?void 0:Q.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((se=q.assistant_profile)==null?void 0:se.email)||""})]}),e.jsxs(nt,{variant:"secondary",className:"ml-2",children:[e.jsx(Xu,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(Z,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{f(q),d(!0)},children:e.jsx(Cr,{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:Dkt.map(te=>{const Y=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(Y,{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(qr,{checked:q.permissions[te.key]||!1,onCheckedChange:ce=>F(q.id,te.key,ce),disabled:N===q.id})]},te.key)})})]})]},q.id)})})})]}),e.jsx(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Add Assistant"}),e.jsx(Kr,{children:_==="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(Z,{variant:_==="create"?"default":"outline",size:"sm",onClick:()=>b("create"),children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(Z,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>b("link"),children:[e.jsx(Po,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"assistant-name",children:"Name"}),e.jsx(Re,{id:"assistant-name",value:g.name,onChange:q=>v({...g,name:q.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"assistant-email",children:"Email"}),e.jsx(Re,{id:"assistant-email",type:"email",value:g.email,onChange:q=>v({...g,email:q.target.value}),placeholder:"assistant@email.com"})]}),_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(Re,{id:"assistant-password",type:"password",value:g.password,onChange:q=>v({...g,password:q.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(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(Z,{onClick:I,disabled:w,children:[w&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(uc,{open:i,onOpenChange:d,children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Remove Assistant?"}),e.jsxs(Xl,{children:["This will remove ",($=u==null?void 0:u.assistant_profile)==null?void 0:$.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function ku(t){this.content=t}ku.prototype={constructor:ku,find:function(t){for(var s=0;s>1}};ku.from=function(t){if(t instanceof ku)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new ku(s)};function Rqe(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=Rqe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function Fqe(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),d=l.nodeSize;if(l==i){r-=d,n-=d;continue}if(!l.sameMarkup(i))return{a:r,b:n};if(l.isText&&l.text!=i.text){let u=0,f=Math.min(l.text.length,i.text.length);for(;us&&n(d,a+i,o||null,l)!==!1&&d.content.size){let f=i+1;d.nodesBetween(Math.max(0,s-f),Math.min(d.content.size,r-f),n,a+f)}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,d)=>{let u=i.isText?i.text.slice(Math.max(s,d)-d,r-d):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=d}return new Mr(n,a)}cutByIndex(s,r){return s==r?Mr.empty:s==0&&r==this.content.length?this:new Mr(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 Mr(a,o)}addToStart(s){return new Mr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Mr(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?w8(r+1,o):w8(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 Mr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Mr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Mr.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}};ml.none=[];class yne extends Error{}class fn{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=Bqe(this.content,s+this.openStart,r);return n&&new fn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new fn(zqe(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 fn.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 fn(Mr.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 fn(s,n,a)}}fn.empty=new fn(Mr.empty,0,0);function zqe(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(zqe(o.content,s-a-1,r-a-1)))}function Bqe(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=Bqe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function Rkt(t,s,r){if(r.openStart>t.depth)throw new yne("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new yne("Inconsistent open depths");return $qe(t,s,r,0)}function $qe(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 IP(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&&(aN(t.nodeAfter,n),o++));for(let i=o;ia&&Rge(t,s,a+1),l=n.depth>a&&Rge(r,n,a+1),i=[];return IP(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(qqe(o,l),aN(iN(o,Uqe(t,s,r,n,a+1)),i)):(o&&aN(iN(o,vne(t,s,a+1)),i),IP(s,r,a,i),l&&aN(iN(l,vne(r,n,a+1)),i)),IP(n,null,a,i),new Mr(i)}function vne(t,s,r){let n=[];if(IP(null,t,r,n),t.depth>r){let a=Rge(t,s,r+1);aN(iN(a,vne(t,s,r+1)),n)}return IP(s,null,r,n),new Mr(n)}function Fkt(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(Mr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class OI{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 _ne(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:d}=l.content.findIndex(o),u=o-d;if(n.push(l,i,a+d),!u||(l=l.child(i),l.isText))break;o=u-1,a+=d+1}return new OI(r,n,o)}static resolveCached(s,r){let n=g3e.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()+")"),Vqe(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=Mr.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 d=a;dr.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=Mr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};n_.prototype.text=void 0;class bne extends n_{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):Vqe(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 bne(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new bne(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 Vqe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class TN{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new qkt(s,r);if(n.next==null)return TN.empty;let a=Hqe(n);n.next&&n.err("Unexpected trailing text");let o=Zkt(Kkt(a));return Ykt(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(` `)}}TN.empty=new TN(!0);class qkt{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 Hqe(t){let s=[];do s.push(Ukt(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function Ukt(t){let s=[];do s.push(Vkt(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function Vkt(t){let s=Gkt(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=Hkt(t,s);else break;return s}function x3e(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function Hkt(t,s){let r=x3e(t),n=r;return t.eat(",")&&(t.next!="}"?n=x3e(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function Wkt(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 Gkt(t){if(t.eat("(")){let s=Hqe(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=Wkt(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 Kkt(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,d){let u={term:d,to:i};return s[l].push(u),u}function a(l,i){l.forEach(d=>d.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((d,u)=>d.concat(o(u,i)),[]);if(l.type=="seq")for(let d=0;;d++){let u=o(l.exprs[d],i);if(d==l.exprs.length-1)return u;a(u,i=r())}else if(l.type=="star"){let d=r();return n(i,d),a(o(l.expr,d),d),[n(d)]}else if(l.type=="plus"){let d=r();return a(o(l.expr,i),d),a(o(l.expr,d),d),[n(d)]}else{if(l.type=="opt")return[n(i)].concat(o(l.expr,i));if(l.type=="range"){let d=i;for(let u=0;u{t[l].forEach(({term:i,to:d})=>{if(!i)return;let u;for(let f=0;f{u||a.push([i,u=[]]),u.indexOf(f)==-1&&u.push(f)})})});let o=s[n.join(",")]=new TN(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:Kqe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new n_(this,this.computeAttrs(s),Mr.from(r),ml.setFrom(n))}createChecked(s=null,r,n){return r=Mr.from(r),this.checkContent(r),new n_(this,this.computeAttrs(s),r,ml.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Mr.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(Mr.empty,!0);return o?new n_(this,s,r.append(o),ml.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 Xqe(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 Xkt(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 Qkt{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Xkt(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class zoe{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=Yqe(s,a.attrs),this.excluded=null;let o=Gqe(this.attrs);this.instance=o?new ml(this,o):null}create(s=null){return!s&&this.instance?this.instance:new ml(this,Kqe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new zoe(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class Qqe{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=ku.from(s.nodes),r.marks=ku.from(s.marks||{}),this.nodes=v3e.compile(this.spec.nodes,this),this.marks=zoe.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]=TN.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?_3e(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==""?[]:_3e(this,l.split(" "))}this.nodeFromJSON=a=>n_.fromJSON(this,a),this.markFromJSON=a=>ml.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 v3e){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 bne(n,n.defaultAttrs,s,ml.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 _3e(t,s){let r=[];for(let n=0;n-1)&&r.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+s[n]+"'")}return r}function Jkt(t){return t.tag!=null}function eNt(t){return t.style!=null}let LP=class zge{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(Jkt(a))this.tags.push(a);else if(eNt(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 w3e(this,r,!1);return n.addAll(s,ml.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new w3e(this,r,!0);return n.addAll(s,ml.none,r.from,r.to),fn.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 d=l.getAttrs(r);if(d===!1)continue;l.attrs=d||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=j3e(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=j3e(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new zge(s,zge.schemaRules(s)))}};const Jqe={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},tNt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},eUe={ol:!0,ul:!0},RI=1,Bge=2,DP=4;function b3e(t,s,r){return s!=null?(s?RI:0)|(s==="full"?Bge:0):t&&t.whitespace=="pre"?RI|Bge:r&~DP}class j8{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=ml.none,this.match=o||(l&DP?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Mr.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&RI)){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=Mr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Mr.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&&!Jqe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class w3e{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=b3e(null,r.preserveWhitespace,0)|(n?DP:0);a?o=new j8(a.type,a.attrs,ml.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new j8(null,null,ml.none,!0,null,l):o=new j8(s.schema.topNodeType,null,ml.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&Bge?"full":this.localPreserveWS||(a.options&RI)>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 d=0;d!d.clearMark(u)):r=r.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)i=d;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 d=this.enter(l,r.attrs||null,n,r.preserveWhitespace);d&&(o=!0,n=d)}else{let d=this.parser.schema.marks[r.mark];n=n.concat(d.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(d=>this.insertNode(d,n,!1));else{let d=s;typeof r.contentElement=="string"?d=s.querySelector(r.contentElement):typeof r.contentElement=="function"?d=r.contentElement(s):r.contentElement&&(d=r.contentElement),this.findAround(s,d,!0),this.addAll(d,n),this.findAround(s,d,!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 d=this.nodes[l],u=d.findWrapping(s);if(u&&(!a||a.length>u.length+i)&&(a=u,o=d,!u.length))break;if(d.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):k3e(u.type,s))?(d=u.addToSet(d),!1):!0),this.nodes.push(new j8(s,r,d,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|=RI)}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,d)=>{for(;i>=0;i--){let u=r[i];if(u==""){if(i==r.length-1||i==0)continue;for(;d>=o;d--)if(l(i-1,d))return!0;return!1}else{let f=d>0||d==0&&a?this.nodes[d].type:n&&d>=o?n.node(d-o).type:null;if(!f||f.name!=u&&!f.isInGroup(u))return!1;d--}}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 sNt(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&eUe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function rNt(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function j3e(t){let s={};for(let r in t)s[r]=t[r];return s}function k3e(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 d=0;d{if(o.length||l.marks.length){let i=0,d=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&&Zse(Ihe(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Zse(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new ZN(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=N3e(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return N3e(s.marks)}}function N3e(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function Ihe(t){return t.document||window.document}const S3e=new WeakMap;function nNt(t){let s=S3e.get(t);return s===void 0&&S3e.set(t,s=aNt(t)),s}function aNt(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,d=r?t.createElementNS(r,a):t.createElement(a),u=s[1],f=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){f=2;for(let g in u)if(u[g]!=null){let v=g.indexOf(" ");v>0?d.setAttributeNS(g.slice(0,v),g.slice(v+1),u[g]):g=="style"&&d.style?d.style.cssText=u[g]:d.setAttribute(g,u[g])}}for(let g=f;gf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:b}=Zse(t,v,r,n);if(d.appendChild(_),b){if(i)throw new RangeError("Multiple content holes");i=b}}}return{dom:d,contentDOM:i}}const tUe=65535,sUe=Math.pow(2,16);function iNt(t,s){return t+s*sUe}function C3e(t){return t&tUe}function oNt(t){return(t-(t&tUe))/sUe}const rUe=1,nUe=2,Yse=4,aUe=8;class $ge{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&aUe)>0}get deletedBefore(){return(this.delInfo&(rUe|Yse))>0}get deletedAfter(){return(this.delInfo&(nUe|Yse))>0}get deletedAcross(){return(this.delInfo&Yse)>0}}class rp{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&rp.empty)return rp.empty}recover(s){let r=0,n=C3e(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],f=this.ranges[i+l],g=d+u;if(s<=g){let v=u?s==d?-1:s==g?1:r:r,_=d+a+(v<0?0:f);if(n)return _;let b=s==(r<0?d:g)?null:iNt(i/3,s-d),w=s==d?nUe:s==g?rUe:Yse;return(r<0?s!=d:s!=g)&&(w|=aUe),new $ge(_,w,b)}a+=f-u}return n?s+a:new $ge(s+a,0,null)}touches(s,r){let n=0,a=C3e(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],f=d+u;if(s<=f&&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 FI;return s.appendMappingInverted(this),s}map(s,r=1){if(this.mirror)return this._map(s,r,!0);for(let n=this.from;no&&d!l.isAtom||!i.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),r.openStart,r.openEnd);return _d.fromReplace(s,this.from,this.to,o)}invert(){return new Lx(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 T1(r.pos,n.pos,this.mark)}merge(s){return s instanceof T1&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new T1(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 T1(r.from,r.to,s.markFromJSON(r.mark))}}rh.jsonID("addMark",T1);class Lx extends rh{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 fn(v_e(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return _d.fromReplace(s,this.from,this.to,n)}invert(){return new T1(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 Lx(r.pos,n.pos,this.mark)}merge(s){return s instanceof Lx&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new Lx(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 Lx(r.from,r.to,s.markFromJSON(r.mark))}}rh.jsonID("removeMark",Lx);class A1 extends rh{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return _d.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return _d.fromReplace(s,this.pos,this.pos+1,new fn(Mr.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 cu(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 cu(r.from,r.to,r.gapFrom,r.gapTo,fn.fromJSON(s,r.slice),r.insert,!!r.structure)}}rh.jsonID("replaceAround",cu);function qge(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 lNt(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(d,u,f)=>{if(!d.isInline)return;let g=d.marks;if(!n.isInSet(g)&&f.type.allowsMarkType(n.type)){let v=Math.max(u,s),_=Math.min(u+d.nodeSize,r),b=n.addToSet(g);for(let w=0;wt.step(d)),o.forEach(d=>t.step(d))}function cNt(t,s,r,n){let a=[],o=0;t.doc.nodesBetween(s,r,(l,i)=>{if(!l.isInline)return;o++;let d=null;if(n instanceof zoe){let u=l.marks,f;for(;f=n.isInSet(u);)(d||(d=[])).push(f),u=f.removeFromSet(u)}else n?n.isInSet(l.marks)&&(d=[n]):d=l.marks;if(d&&d.length){let u=Math.min(i+l.nodeSize,r);for(let f=0;ft.step(new Lx(l.from,l.to,l.style)))}function __e(t,s,r,n=r.contentMatch,a=!0){let o=t.doc.nodeAt(s),l=[],i=s+1;for(let d=0;d=0;d--)t.step(l[d])}function dNt(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function cM(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,d=t.$to.indexAfter(n)-o;if(nr;b--)w||n.index(b)>0?(w=!0,f=Mr.from(n.node(b).copy(f)),g++):d--;let v=Mr.empty,_=0;for(let b=o,w=!1;b>r;b--)w||a.after(b+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=Mr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new cu(a,o,a,o,new fn(n,0,0),r.length,!0))}function fNt(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 d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,d)&&gNt(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let _=n.whitespace=="pre",b=!!n.contentMatch.matchType(n.schema.linebreakReplacement);_&&!b?u=!1:!_&&b&&(u=!0)}u===!1&&oUe(t,l,i,o),__e(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let f=t.mapping.slice(o),g=f.map(i,1),v=f.map(i+l.nodeSize,1);return t.step(new cu(g,v,g+1,v-1,new fn(Mr.from(n.create(d,null,l.marks)),0,0),1,!0)),u===!0&&iUe(t,l,i,o),!1}})}function iUe(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 d=t.mapping.slice(n).map(r+1+o+l.index);t.replaceWith(d,d+1,s.type.schema.linebreakReplacement.create())}}})}function oUe(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 gNt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function xNt(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 cu(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new fn(Mr.from(l),0,0),1,!0))}function S0(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,f=r-2;u>o;u--,f--){let g=a.node(u),v=a.index(u);if(g.type.spec.isolating)return!1;let _=g.content.cutByIndex(v,g.childCount),b=n&&n[f+1];b&&(_=_.replaceChild(0,b.type.create(b.attrs)));let w=n&&n[f]||g;if(!g.canReplace(v+1,g.childCount)||!w.type.validContent(_))return!1}let i=a.indexAfter(o),d=n&&n[0];return a.node(o).canReplaceWith(i,i,d?d.type:a.node(o+1).type)}function yNt(t,s,r=1,n){let a=t.doc.resolve(s),o=Mr.empty,l=Mr.empty;for(let i=a.depth,d=a.depth-r,u=r-1;i>d;i--,u--){o=Mr.from(a.node(i).copy(o));let f=n&&n[u];l=Mr.from(f?f.type.create(f.attrs,l):a.node(i).copy(l))}t.step(new su(s,s,new fn(o.append(l),r,r),!0))}function R_(t,s){let r=t.resolve(s),n=r.index();return lUe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function vNt(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&&lUe(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 _Nt(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 f=l.whitespace=="pre",g=!!l.contentMatch.matchType(a);f&&!g?n=!1:!f&&g&&(n=!0)}let i=t.steps.length;if(n===!1){let f=t.doc.resolve(s+r);oUe(t,f.node(),f.before(),i)}l.inlineContent&&__e(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let d=t.mapping.slice(i),u=d.map(s-r);if(t.step(new su(u,d.map(s+r,-1),fn.empty,!0)),n===!0){let f=t.doc.resolve(u);iUe(t,f.node(),f.before(),t.steps.length)}return t}function bNt(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,d=n.index(l)+(i>0?1:0),u=n.node(l),f=!1;if(o==1)f=u.canReplace(d,d,a);else{let g=u.contentMatchAt(d).findWrapping(a.firstChild.type);f=g&&u.canReplaceWith(d,d,g[0])}if(f)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function $oe(t,s,r=s,n=fn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return dUe(a,o,n)?new su(s,r,n):new wNt(a,o,n).fit()}function dUe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class wNt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Mr.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=Mr.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 d=new fn(o,l,i);return s>-1?new cu(n.pos,s,this.$to.pos,this.$to.end(),d,r):d.size||n.pos!=this.$to.pos?new su(n.pos,a.pos,d):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=Dhe(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:d,match:u}=this.frontier[i],f,g=null;if(r==1&&(l?u.matchType(l.type)||(g=u.fillBefore(Mr.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:g};if(r==2&&l&&(f=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:f};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=Dhe(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new fn(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=Dhe(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new fn(yE(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new fn(yE(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let w=0;w1||d==0||w.content.size)&&(g=j,f.push(uUe(w.mark(v.allowedMarks(w.marks)),u==1?d:0,u==i.childCount?_:-1)))}let b=u==i.childCount;b||(_=-1),this.placed=vE(this.placed,r,Mr.from(f)),this.frontier[r].match=g,b&&_<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,j=i;w<_;w++){let N=j.lastChild;this.frontier.push({type:N.type,match:N.contentMatchAt(N.childCount)}),j=N.content}this.unplaced=b?s==0?fn.empty:new fn(yE(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new fn(yE(l.content,s,u),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let s=this.frontier[this.depth],r;if(!s.type.isTextblock||!Ohe(this.$to,this.$to.depth,s.type,s.match,!1)||this.$to.depth==this.depth&&(r=this.findCloseLevel(this.$to))&&r.depth==this.depth)return-1;let{depth:n}=this.$to,a=this.$to.after(n);for(;n>1&&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:d,type:u}=this.frontier[i],f=Ohe(s,i,u,d,!0);if(!f||f.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=vE(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=vE(this.placed,this.depth,Mr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Mr.empty,!0);r.childCount&&(this.placed=vE(this.placed,this.frontier.length,r))}}function yE(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(yE(t.firstChild.content,s-1,r)))}function vE(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(vE(t.lastChild.content,s-1,r)))}function Dhe(t,s){for(let r=0;r1&&(n=n.replaceChild(0,uUe(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(Mr.empty,!0)))),t.copy(n)}function Ohe(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&&!jNt(r,o.content,l)?i:null}function jNt(t,s,r){for(let n=r;n0;v--,_--){let b=a.node(v).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;l.indexOf(v)>-1?i=v:a.before(v)==_&&l.splice(1,0,-v)}let d=l.indexOf(i),u=[],f=n.openStart;for(let v=n.content,_=0;;_++){let b=v.firstChild;if(u.push(b),_==n.openStart)break;v=b.content}for(let v=f-1;v>=0;v--){let _=u[v],b=kNt(_.type);if(b&&!_.sameMarkup(a.node(Math.abs(i)-1)))f=v;else if(b||!_.type.isTextblock)break}for(let v=n.openStart;v>=0;v--){let _=(v+f+1)%(n.openStart+1),b=u[_];if(b)for(let w=0;w=0&&(t.replace(s,r,n),!(t.steps.length>g));v--){let _=l[v];_<0||(s=a.before(_),r=o.after(_))}}function hUe(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(Mr.empty,!0))}return t}function SNt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=bNt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new fn(Mr.from(n),0,0))}function CNt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=mUe(n,a);for(let l=0;l0&&(d||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 mUe(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 N5 extends rh{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 _d.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 _d.fromReplace(s,this.pos,this.pos+1,new fn(Mr.from(a),0,r.isLeaf?0:1))}getMap(){return rp.empty}invert(s){return new N5(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 N5(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 N5(r.pos,r.attr,r.value)}}rh.jsonID("attr",N5);class zI extends rh{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 _d.ok(n)}getMap(){return rp.empty}invert(s){return new zI(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 zI(r.attr,r.value)}}rh.jsonID("docAttr",zI);let u3=class extends Error{};u3=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};u3.prototype=Object.create(Error.prototype);u3.prototype.constructor=u3;u3.prototype.name="TransformError";class w_e{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new FI}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new u3(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=fn.empty){let a=$oe(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new fn(Mr.from(n),0,0))}delete(s,r){return this.replace(s,r,fn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return NNt(this,s,r,n),this}replaceRangeWith(s,r,n){return SNt(this,s,r,n),this}deleteRange(s,r){return CNt(this,s,r),this}lift(s,r){return uNt(this,s,r),this}join(s,r=1){return _Nt(this,s,r),this}wrap(s,r){return pNt(this,s,r),this}setBlockType(s,r=s,n,a=null){return fNt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return xNt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new N5(s,r,n)),this}setDocAttribute(s,r){return this.step(new zI(s,r)),this}addNodeMark(s,r){return this.step(new A1(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 ml)r.isInSet(n.marks)&&this.step(new AN(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new AN(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 yNt(this,s,r,n),this}addMark(s,r,n){return lNt(this,s,r,n),this}removeMark(s,r,n){return cNt(this,s,r,n),this}clearIncompatible(s,r,n){return __e(this,s,r,n),this}}const Rhe=Object.create(null);class si{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new pUe(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?u4(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):u4(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 gp(s.node(0))}static atStart(s){return u4(s,s,0,0,1)||new gp(s)}static atEnd(s){return u4(s,s,s.content.size,s.childCount,-1)||new gp(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Rhe[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 Rhe)throw new RangeError("Duplicate use of selection JSON ID "+s);return Rhe[s]=r,r.prototype.jsonID=s,r}getBookmark(){return $a.between(this.$anchor,this.$head).getBookmark()}}si.prototype.visible=!0;class pUe{constructor(s,r){this.$from=s,this.$to=r}}let T3e=!1;function A3e(t){!T3e&&!t.parent.inlineContent&&(T3e=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class $a extends si{constructor(s,r=s){A3e(s),A3e(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 si.near(n);let a=s.resolve(r.map(this.anchor));return new $a(a.parent.inlineContent?a:n,n)}replace(s,r=fn.empty){if(super.replace(s,r),r==fn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof $a&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new qoe(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 $a(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=si.findFrom(r,n,!0)||si.findFrom(r,-n,!0);if(o)r=o.$head;else return si.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(si.findFrom(s,-n,!0)||si.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&&Ta.isSelectable(i))return Ta.create(t,r-(a<0?i.nodeSize:0))}else{let d=u4(t,i,r+a,a<0?i.childCount:0,a,o);if(d)return d}r+=i.nodeSize*a}return null}function E3e(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=f)}),t.setSelection(si.near(t.doc.resolve(l),r))}const P3e=1,k8=2,I3e=4;class TNt extends w_e{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|=k8,this}ensureMarks(s){return ml.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&k8)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~k8,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)||ml.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(si.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|=I3e,this}get scrolledIntoView(){return(this.updated&I3e)>0}}function L3e(t,s){return!s||!t?t:t.bind(s)}class _E{constructor(s,r,n){this.name=s,this.init=L3e(r.init,n),this.apply=L3e(r.apply,n)}}const ANt=[new _E("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new _E("selection",{init(t,s){return t.selection||si.atStart(s.doc)},apply(t){return t.selection}}),new _E("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new _E("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class Fhe{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ANt.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 _E(n.key,n.spec.state,n))})}}class M4{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 Fhe(s.schema,s.plugins),o=new M4(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=n_.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=si.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 d=n[i],u=d.spec.state;if(d.key==l.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,i)){o[l.name]=u.fromJSON.call(d,s,r[i],o);return}}o[l.name]=l.init(s,o)}}),o}}function fUe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=fUe(a,s,{})),r[n]=a}return r}class qd{constructor(s){this.spec=s,this.props={},s.props&&fUe(s.props,this,this.props),this.key=s.key?s.key.key:gUe("plugin")}getState(s){return s[this.key]}}const zhe=Object.create(null);function gUe(t){return t in zhe?t+"$"+ ++zhe[t]:(zhe[t]=0,t+"$")}class nh{constructor(s="key"){this.key=gUe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const Su=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},h3=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let Uge=null;const Zy=function(t,s,r){let n=Uge||(Uge=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},ENt=function(){Uge=null},EN=function(t,s,r,n){return r&&(D3e(t,s,r,n,-1)||D3e(t,s,r,n,1))},PNt=/^(img|br|input|textarea|hr)$/i;function D3e(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:Jp(t))){let l=t.parentNode;if(!l||l.nodeType!=1||xL(t)||PNt.test(t.nodeName)||t.contentEditable=="false")return!1;s=Su(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?Jp(t):0}else return!1}}function Jp(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function INt(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=Jp(t)}else if(t.parentNode&&!xL(t))s=Su(t),t=t.parentNode;else return null}}function LNt(t,s){for(;;){if(t.nodeType==3&&s2),Gp=m3||(Jx?/Mac/.test(Jx.platform):!1),vUe=Jx?/Win/.test(Jx.platform):!1,c0=/Android \d/.test(F_),yL=!!O3e&&"webkitFontSmoothing"in O3e.documentElement.style,FNt=yL?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zNt(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 zy(t,s){return typeof t=="number"?t:t[s]}function BNt(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 R3e(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=h3(l);continue}let i=l,d=i==o.body,u=d?zNt(o):BNt(i),f=0,g=0;if(s.topu.bottom-zy(n,"bottom")&&(g=s.bottom-s.top>u.bottom-u.top?s.top+zy(a,"top")-u.top:s.bottom-u.bottom+zy(a,"bottom")),s.leftu.right-zy(n,"right")&&(f=s.right-u.right+zy(a,"right")),f||g)if(d)o.defaultView.scrollBy(f,g);else{let _=i.scrollLeft,b=i.scrollTop;g&&(i.scrollTop+=g),f&&(i.scrollLeft+=f);let w=i.scrollLeft-_,j=i.scrollTop-b;s={left:s.left-w,top:s.top-j,right:s.right-w,bottom:s.bottom-j}}let v=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(v))break;l=v=="absolute"?l.offsetParent:h3(l)}}function $Nt(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=d.top;break}}return{refDOM:n,refTop:a,stack:_Ue(t.dom)}}function _Ue(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=h3(n));return s}function qNt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;bUe(r,n==0?0:n-s)}function bUe(t,s){for(let r=0;r=i){l=Math.max(b.bottom,l),i=Math.min(b.top,i);let w=b.left>s.left?b.left-s.left:b.right=(b.left+b.right)/2?1:0));continue}}else b.top>s.top&&!d&&b.left<=s.left&&b.right>=s.left&&(d=f,u={left:Math.max(b.left,Math.min(b.right,s.left)),top:b.top});!r&&(s.left>=b.right&&s.top>=b.top||s.left>=b.left&&s.top>=b.bottom)&&(o=g+1)}}return!r&&d&&(r=d,a=u,n=0),r&&r.nodeType==3?VNt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:wUe(r,a)}function VNt(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 k_e(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function HNt(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 GNt(t,s,r,n){let a=-1;for(let o=s,l=!1;o!=t.dom;){let i=t.docView.nearestDesc(o,!0),d;if(!i)return null;if(i.dom.nodeType==1&&(i.node.isBlock&&i.parent||!i.contentDOM)&&((d=i.dom.getBoundingClientRect()).width||d.height)&&(i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(!l&&d.left>n.left||d.top>n.top?a=i.posBefore:(!l&&d.right-1?a:t.docView.posFromDOM(s,r,-1)}function jUe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;yL&&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=GNt(t,n,a,s))}i==null&&(i=WNt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function F3e(t){return t.top=0&&a==n.nodeValue.length?(d--,f=1):r<0?d--:u++,HA(Hv(Zy(n,d,u),f),f<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==Jp(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return Bhe(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==Jp(n))){let d=n.childNodes[a-1],u=d.nodeType==3?Zy(d,Jp(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(u)return HA(Hv(u,1),!1)}if(o==null&&a=0)}function HA(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 Bhe(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 NUe(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 YNt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return NUe(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=kUe(t,a.pos,1);for(let i=o.firstChild;i;i=i.nextSibling){let d;if(i.nodeType==1)d=i.getClientRects();else if(i.nodeType==3)d=Zy(i,0,i.nodeValue.length).getClientRects();else continue;for(let u=0;uf.top+1&&(r=="up"?l.top-f.top>(f.bottom-l.top)*2:f.bottom-l.bottom>(l.bottom-f.top)*2))return!1}}return!0})}const XNt=/[\u0590-\u08ac]/;function QNt(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?!XNt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:NUe(t,s,()=>{let{focusNode:d,focusOffset:u,anchorNode:f,anchorOffset:g}=t.domSelectionRange(),v=i.caretBidiLevel;i.modify("move",r,"character");let _=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:b,focusOffset:w}=t.domSelectionRange(),j=b&&!_.contains(b.nodeType==1?b:b.parentNode)||d==b&&u==w;try{i.collapse(f,g),d&&(d!=f||u!=g)&&i.extend&&i.extend(d,u)}catch{}return v!=null&&(i.caretBidiLevel=v),j}):n.pos==n.start()||n.pos==n.end()}let z3e=null,B3e=null,$3e=!1;function JNt(t,s,r){return z3e==s&&B3e==r?$3e:(z3e=s,B3e=r,$3e=r=="up"||r=="down"?YNt(t,s,r):QNt(t,s,r))}const uf=0,q3e=1,bk=2,ey=3;class vL{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=uf,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;rSu(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 CUe){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 SUe&&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?Su(o.dom)+1:0}}else{let o,l=!0;for(;o=n=f&&r<=u-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(s,r,f);s=l;for(let g=i;g>0;g--){let v=this.children[g-1];if(v.size&&v.dom.parentNode==this.contentDOM&&!v.emptyChildAt(1)){a=Su(v.dom)+1;break}s-=v.size}a==-1&&(a=0)}if(a>-1&&(u>r||i==this.children.length-1)){r=u;for(let f=i+1;fb&&lr){let b=i;i=d,d=b}let _=document.createRange();_.setEnd(d.node,d.offset),_.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(_)}}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,d=l-o.border;if(s>=i&&r<=d){this.dirty=s==n||r==l?bk:q3e,s==i&&r==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ey:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?bk:ey}n=l}this.dirty=bk}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?bk:q3e;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==uf&&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 eSt extends vL{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 PN extends vL{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=ZN.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new PN(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&ey||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=ey&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=uf){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=Kge(o,0,s,n));for(let i=0;i{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},n,a),f=u&&u.dom,g=u&&u.contentDOM;if(r.isText){if(!f)f=document.createTextNode(r.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:g}=ZN.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!g&&!r.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),r.type.spec.draggable&&(f.draggable=!0));let v=f;return f=AUe(f,n,r),u?d=new tSt(s,r,n,a,f,g||null,v,u,o,l+1):r.isText?new Voe(s,r,n,a,f,v,o):new i_(s,r,n,a,f,g||null,v,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=()=>Mr.empty)}return s}matchesNode(s,r,n){return this.dirty==uf&&s.eq(this.node)&&wne(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,d=new rSt(this,l&&l.node,s);iSt(this.node,this.innerDeco,(u,f,g)=>{u.spec.marks?d.syncToMarks(u.spec.marks,n,s):u.type.side>=0&&!g&&d.syncToMarks(f==this.node.childCount?ml.none:this.node.child(f).marks,n,s),d.placeWidget(u,s,a)},(u,f,g,v)=>{d.syncToMarks(u.marks,n,s);let _;d.findNodeMatch(u,f,g,v)||i&&s.state.selection.from>a&&s.state.selection.to-1&&d.updateNodeAt(u,f,g,_,s)||d.updateNextNode(u,f,g,s,v,a)||d.addNode(u,f,g,s,a),a+=u.nodeSize}),d.syncToMarks([],n,s),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==bk)&&(l&&this.protectLocalComposition(s,l),MUe(this.contentDOM,this.children,s),m3&&oSt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof $a)||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=lSt(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 eSt(this,o,r,a);s.input.compositionNodes.push(l),this.children=Kge(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==ey||!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=uf}updateOuterDeco(s){if(wne(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=TUe(this.dom,this.nodeDOM,Gge(this.outerDeco,this.node,r),Gge(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 U3e(t,s,r,n,a){AUe(n,s,t);let o=new i_(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class Voe extends i_{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==ey||this.dirty!=uf&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=uf||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=uf,!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 Voe(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=ey)}get domAtom(){return!1}isText(s){return this.node.text==s}}class CUe extends vL{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==uf&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class tSt extends i_{constructor(s,r,n,a,o,l,i,d,u,f){super(s,r,n,a,o,l,i,u,f),this.spec=d}update(s,r,n,a){if(this.dirty==ey)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 MUe(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 d=PN.create(this.top,s[o],r,n);this.top.children.splice(this.index,0,d),this.top=d,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,d=Math.min(this.top.children.length,i+5);i0;){let i;for(;;)if(n){let u=r.children[n-1];if(u instanceof PN)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 d=i.node;if(d){if(d!=t.child(a-1))break;--a,o.set(i,a),l.push(i)}}return{index:a,matched:o,matches:l.reverse()}}function aSt(t,s){return t.type.side-s.type.side}function iSt(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 b=o+v.nodeSize;if(v.isText){let j=b;l!j.inline):i.slice();n(v,w,s.forChild(o,v),_),o=b}}function oSt(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 lSt(t,s,r,n){for(let a=0,o=0;a=r){if(o>=n&&d.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&&d.length>=n+s.length-i&&d.slice(n-i,n-i+s.length)==s)return n}}return-1}function Kge(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||f<=s?o.push(d):(ur&&o.push(d.slice(r-u,d.size,n)))}return o}function N_e(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),d,u;if(Uoe(r)){for(d=l;a&&!a.node;)a=a.parent;let g=a.node;if(a&&g.isAtom&&Ta.isSelectable(g)&&a.parent&&!(g.isInline&&DNt(r.focusNode,r.focusOffset,a.dom))){let v=a.posBefore;u=new Ta(l==v?i:n.resolve(v))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let g=l,v=l;for(let _=0;_{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!EUe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function dSt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,Su(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&Am&&a_<=11&&(r.disabled=!0,r.disabled=!1)}function PUe(t,s){if(s instanceof Ta){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(K3e(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else K3e(t)}function K3e(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function S_e(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||$a.between(s,r,n)}function Z3e(t){return t.editable&&!t.hasFocus()?!1:IUe(t)}function IUe(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 uSt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return EN(s.node,s.offset,r.anchorNode,r.anchorOffset)}function Zge(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&&si.findFrom(o,s)}function e1(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function Y3e(t,s,r){let n=t.state.selection;if(n instanceof $a)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 e1(t,new $a(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=Zge(t.state,s);return a&&a instanceof Ta?e1(t,a):!1}else if(!(Gp&&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?Ta.isSelectable(o)?e1(t,new Ta(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):yL?e1(t,new $a(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Ta&&n.node.isInline)return e1(t,new $a(s>0?n.$to:n.$from));{let a=Zge(t.state,s);return a?e1(t,a):!1}}}function jne(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function RP(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function XC(t,s){return s<0?hSt(t):mSt(t)}function hSt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(df&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(RP(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(LUe(r))break;{let i=r.previousSibling;for(;i&&RP(i,-1);)a=r.parentNode,o=Su(i),i=i.previousSibling;if(i)r=i,n=jne(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?Yge(t,r,n):a&&Yge(t,a,o)}function mSt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=jne(r),o,l;for(;;)if(n{t.state==a&&C0(t)},50)}function X3e(t,s){let r=t.state.doc.resolve(s);if(!(iu||vUe)&&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 Q3e(t,s,r){let n=t.state.selection;if(n instanceof $a&&!n.empty||r.indexOf("s")>-1||Gp&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=Zge(t.state,s);if(l&&l instanceof Ta)return e1(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof gp?si.near(l,s):si.findFrom(l,s);return i?e1(t,i):!1}return!1}function J3e(t,s){if(!(t.state.selection instanceof $a))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 eMe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function gSt(t){if(!eh||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;eMe(t,n,"true"),setTimeout(()=>eMe(t,n,"false"),20)}return!1}function xSt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function ySt(t,s){let r=s.keyCode,n=xSt(s);if(r==8||Gp&&r==72&&n=="c")return J3e(t,-1)||XC(t,-1);if(r==46&&!s.shiftKey||Gp&&r==68&&n=="c")return J3e(t,1)||XC(t,1);if(r==13||r==27)return!0;if(r==37||Gp&&r==66&&n=="c"){let a=r==37?X3e(t,t.state.selection.from)=="ltr"?-1:1:-1;return Y3e(t,a,n)||XC(t,a)}else if(r==39||Gp&&r==70&&n=="c"){let a=r==39?X3e(t,t.state.selection.from)=="ltr"?1:-1:1;return Y3e(t,a,n)||XC(t,a)}else{if(r==38||Gp&&r==80&&n=="c")return Q3e(t,-1,n)||XC(t,-1);if(r==40||Gp&&r==78&&n=="c")return gSt(t)||Q3e(t,1,n)||XC(t,1);if(n==(Gp?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function C_e(t,s){t.someProp("transformCopied",_=>{s=_(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 _=n.firstChild;r.push(_.type.name,_.attrs!=_.type.defaultAttrs?_.attrs:null),n=_.content}let l=t.someProp("clipboardSerializer")||ZN.fromSchema(t.state.schema),i=BUe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let u=d.firstChild,f,g=0;for(;u&&u.nodeType==1&&(f=zUe[u.nodeName.toLowerCase()]);){for(let _=f.length-1;_>=0;_--){let b=i.createElement(f[_]);for(;d.firstChild;)b.appendChild(d.firstChild);d.appendChild(b),g++}u=d.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${g?` -${g}`:""} ${JSON.stringify(r)}`);let v=t.someProp("clipboardTextSerializer",_=>_(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:d,text:v,slice:s}}function DUe(t,s,r,n,a){let o=a.parent.type.spec.code,l,i;if(!r&&!s)return null;let d=!!s&&(n||o||!r);if(d){if(t.someProp("transformPastedText",v=>{s=v(s,o||n,t)}),o)return i=new fn(Mr.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",v=>{i=v(i,t,!0)}),i;let g=t.someProp("clipboardTextParser",v=>v(s,a,n,t));if(g)i=g;else{let v=a.marks(),{schema:_}=t.state,b=ZN.fromSchema(_);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(w=>{let j=l.appendChild(document.createElement("p"));w&&j.appendChild(b.serializeNode(_.text(w,v)))})}}else t.someProp("transformPastedHTML",g=>{r=g(r,t)}),l=wSt(r),yL&&jSt(l);let u=l&&l.querySelector("[data-pm-slice]"),f=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let g=+f[3];g>0;g--){let v=l.firstChild;for(;v&&v.nodeType!=1;)v=v.nextSibling;if(!v)break;l=v}if(i||(i=(t.someProp("clipboardParser")||t.someProp("domParser")||LP.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||f),context:a,ruleFromNode(v){return v.nodeName=="BR"&&!v.nextSibling&&v.parentNode&&!vSt.test(v.parentNode.nodeName)?{ignore:!0}:null}})),f)i=kSt(tMe(i,+f[1],+f[2]),f[4]);else if(i=fn.maxOpen(_St(i.content,a),!0),i.openStart||i.openEnd){let g=0,v=0;for(let _=i.content.firstChild;g{i=g(i,t,d)}),i}const vSt=/^(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 _St(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 d=a.findWrapping(i.type),u;if(!d)return l=null;if(u=l.length&&o.length&&RUe(d,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=FUe(l[l.length-1],o.length));let f=OUe(i,d);l.push(f),a=a.matchType(f.type),o=d}}),l)return Mr.from(l)}return t}function OUe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Mr.from(t));return t}function RUe(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(Mr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function tMe(t,s,r){return sr})),qhe.createHTML(t)):t}function wSt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=BUe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&zUe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=bSt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=Mr.from(d.create(n[i+1],a)),o++,l++}return new fn(a,o,l)}const Uh={},Vh={},NSt={touchstart:!0,touchmove:!0};class SSt{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 CSt(t){for(let s in Uh){let r=Uh[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{TSt(t,n)&&!M_e(t,n)&&(t.editable||!(n.type in Vh))&&r(t,n)},NSt[s]?{passive:!0}:void 0)}eh&&t.dom.addEventListener("input",()=>null),Qge(t)}function E1(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function MSt(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 Qge(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>M_e(t,n))})}function M_e(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function TSt(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 ASt(t,s){!M_e(t,s)&&Uh[s.type]&&(t.editable||!(s.type in Vh))&&Uh[s.type](t,s)}Vh.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!qUe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(c0&&iu&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),m3&&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,hk(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||ySt(t,r)?r.preventDefault():E1(t,"key")};Vh.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Vh.keypress=(t,s)=>{let r=s;if(qUe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Gp&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof $a)||!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 Hoe(t){return{left:t.clientX,top:t.clientY}}function ESt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function T_e(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 S5(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 PSt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Ta.isSelectable(n)?(S5(t,new Ta(r)),!0):!1}function ISt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Ta&&(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(Ta.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?(S5(t,Ta.create(t.state.doc,a)),!0):!1}function LSt(t,s,r,n,a){return T_e(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?ISt(t,r):PSt(t,r))}function DSt(t,s,r,n){return T_e(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function OSt(t,s,r,n){return T_e(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||RSt(t,r,n)}function RSt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(S5(t,$a.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)S5(t,$a.create(n,i+1,i+1+l.content.size));else if(Ta.isSelectable(l))S5(t,Ta.create(n,i));else continue;return!0}}function A_e(t){return kne(t)}const $Ue=Gp?"metaKey":"ctrlKey";Uh.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=A_e(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&ESt(r,t.input.lastClick)&&!r[$Ue]&&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(Hoe(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new FSt(t,l,r,!!n)):(o=="doubleClick"?DSt:OSt)(t,l.pos,l.inside,r)?r.preventDefault():E1(t,"pointer"))};class FSt{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[$Ue],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let f=s.state.doc.resolve(r.pos);o=f.parent,l=f.depth?f.before():0}const i=a?null:n.target,d=i?s.docView.nearestDesc(i,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:u}=s.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof Ta&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&df&&!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)),E1(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(()=>C0(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(Hoe(s))),this.updateAllowDefault(s),this.allowDefault||!r?E1(this.view,"pointer"):LSt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||eh&&this.mightDrag&&!this.mightDrag.node.isAtom||iu&&!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)?(S5(this.view,si.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):E1(this.view,"pointer")}move(s){this.updateAllowDefault(s),E1(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)}}Uh.touchstart=t=>{t.input.lastTouch=Date.now(),A_e(t),E1(t,"pointer")};Uh.touchmove=t=>{t.input.lastTouch=Date.now(),E1(t,"pointer")};Uh.contextmenu=t=>A_e(t);function qUe(t,s){return t.composing?!0:eh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const zSt=c0?5e3:-1;Vh.compositionstart=Vh.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof $a&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||iu&&vUe&&BSt(t)))t.markCursor=t.state.storedMarks||r.marks(),kne(t,!0),t.markCursor=null;else if(kne(t,!s.selection.empty),df&&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}UUe(t,zSt)};function BSt(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"}Vh.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++,UUe(t,20))};function UUe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>kne(t),s))}function VUe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=qSt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function $St(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=INt(s.focusNode,s.focusOffset),n=LNt(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 qSt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function kne(t,s=!1){if(!(c0&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),VUe(t),s||t.docView&&t.docView.dirty){let r=N_e(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 USt(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 BI=Am&&a_<15||m3&&FNt<604;Uh.copy=Vh.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=BI?null:r.clipboardData,l=n.content(),{dom:i,text:d}=C_e(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):USt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function VSt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function HSt(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?$I(t,n.value,null,a,s):$I(t,n.textContent,n.innerHTML,a,s)},50)}function $I(t,s,r,n,a){let o=DUe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,a,o||fn.empty)))return!0;if(!o)return!1;let l=VSt(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 HUe(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," "):""}Vh.paste=(t,s)=>{let r=s;if(t.composing&&!c0)return;let n=BI?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&$I(t,HUe(n),n.getData("text/html"),a,r)?r.preventDefault():HSt(t,r)};class WUe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const WSt=Gp?"altKey":"ctrlKey";function GUe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[WSt]}Uh.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(Hoe(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Ta?a.to-1:a.to))){if(n&&n.mightDrag)l=Ta.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let g=t.docView.nearestDesc(r.target,!0);g&&g.node.type.spec.draggable&&g!=t.docView&&(l=Ta.create(t.state.doc,g.posBefore))}}let i=(l||t.state.selection).content(),{dom:d,text:u,slice:f}=C_e(t,i);(!r.dataTransfer.files.length||!iu||yUe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(BI?"Text":"text/html",d.innerHTML),r.dataTransfer.effectAllowed="copyMove",BI||r.dataTransfer.setData("text/plain",u),t.dragging=new WUe(f,GUe(t,r),l)};Uh.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Vh.dragover=Vh.dragenter=(t,s)=>s.preventDefault();Vh.drop=(t,s)=>{try{GSt(t,s,t.dragging)}finally{t.dragging=null}};function GSt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(Hoe(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",_=>{o=_(o,t,!1)}):o=DUe(t,HUe(s.dataTransfer),BI?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&GUe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||fn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?cUe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let d=t.state.tr;if(l){let{node:_}=r;_?_.replace(d):d.deleteSelection()}let u=d.mapping.map(i),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,g=d.doc;if(f?d.replaceRangeWith(u,u,o.content.firstChild):d.replaceRange(u,u,o),d.doc.eq(g))return;let v=d.doc.resolve(u);if(f&&Ta.isSelectable(o.content.firstChild)&&v.nodeAfter&&v.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new Ta(v));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((b,w,j,N)=>_=N),d.setSelection(S_e(t,v,d.doc.resolve(_)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Uh.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())&&C0(t)},20))};Uh.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)};Uh.beforeinput=(t,s)=>{if(iu&&c0&&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,hk(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 Vh)Uh[t]=Vh[t];function qI(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 Nne{constructor(s,r){this.toDOM=s,this.spec=r||oN,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 Ch(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof Nne&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&qI(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class o_{constructor(s,r){this.attrs=s,this.spec=r||oN}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 Ch(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==Uu||s.maps.length==0?this:this.mapInner(s,r,0,0,n||oN)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=d+n,f;if(f=ZUe(r,i,u)){for(a||(a=this.children.slice());oi&&g.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&&d.type instanceof o_){let u=Math.max(o,d.from)-o,f=Math.min(l,d.to)-o;ua.map(s,r,oN));return d1.from(n)}forChild(s,r){if(r.isLeaf)return Oc.empty;let n=[];for(let a=0;ar instanceof Oc)?s:s.reduce((r,n)=>r.concat(n instanceof Oc?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let j=w-b-(_-v);for(let N=0;NS+f-g)continue;let A=i[N]+f-g;_>=A?i[N+1]=v<=A?-2:-1:v>=f&&j&&(i[N]+=j,i[N+1]+=j)}g+=j}),f=r.maps[u].map(f,-1)}let d=!1;for(let u=0;u=n.content.size){d=!0;continue}let v=r.map(t[u+1]+o,-1),_=v-a,{index:b,offset:w}=n.content.findIndex(g),j=n.maybeChild(b);if(j&&w==g&&w+j.nodeSize==_){let N=i[u+2].mapInner(r,j,f+1,t[u]+o+1,l);N!=Uu?(i[u]=g,i[u+1]=_,i[u+2]=N):(i[u+1]=-2,d=!0)}else d=!0}if(d){let u=ZSt(i,t,s,r,a,o,l),f=Sne(u,n,0,l);s=f.local;for(let g=0;gr&&l.to{let u=ZUe(t,i,d+r);if(u){o=!0;let f=Sne(u,i,r+d+1,n);f!=Uu&&a.push(d,d+i.nodeSize,f)}});let l=KUe(o?YUe(t):t,-r).sort(lN);for(let i=0;i0;)s++;t.splice(s,0,r)}function Uhe(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Uu&&s.push(n)}),t.cursorWrapper&&s.push(Oc.create(t.state.doc,[t.cursorWrapper.deco])),d1.from(s)}const YSt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},XSt=Am&&a_<=11;class QSt{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 JSt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new QSt,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()}),XSt&&(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,YSt)),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(Z3e(this.view)){if(this.suppressingSelectionUpdates)return C0(this.view);if(Am&&a_<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&EN(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=h3(o))r.add(o);for(let o=s.anchorNode;o;o=h3(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)&&Z3e(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,d=[];if(s.editable)for(let f=0;fg.nodeName=="BR");if(f.length==2){let[g,v]=f;g.parentNode&&g.parentNode.parentNode==v.parentNode?v.remove():g.remove()}else{let{focusNode:g}=this.currentSelection;for(let v of f){let _=v.parentNode;_&&_.nodeName=="LI"&&(!g||sCt(s,g)!=_)&&v.remove()}}}else if((iu||eh)&&d.some(f=>f.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let f of d)if(f.nodeName=="BR"&&f.parentNode){let g=f.nextSibling;g&&g.nodeType==1&&g.contentEditable=="false"&&f.parentNode.removeChild(f)}}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),eCt(s)),this.handleDOMChange(o,l,i,d),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||C0(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 f=0;fa;j--){let N=n.childNodes[j-1],S=N.pmViewDesc;if(N.nodeName=="BR"&&!S){o=j;break}if(!S||S.size)break}let g=t.state.doc,v=t.someProp("domParser")||LP.fromSchema(t.state.schema),_=g.resolve(l),b=null,w=v.parse(n,{topNode:_.parent,topMatch:_.parent.contentMatchAt(_.index()),topOpen:!0,from:a,to:o,preserveWhitespace:_.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:nCt,context:_});if(u&&u[0].pos!=null){let j=u[0].pos,N=u[1]&&u[1].pos;N==null&&(N=j),b={anchor:j+l,head:N+l}}return{doc:w,sel:b,from:l,to:i}}function nCt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(eh&&/^(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||eh&&/^(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 aCt=/^(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 iCt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let $=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,q=N_e(t,$);if(q&&!t.state.selection.eq(q)){if(iu&&c0&&t.input.lastKeyCode===13&&Date.now()-100U(t,hk(13,"Enter"))))return;let H=t.state.tr.setSelection(q);$=="pointer"?H.setMeta("pointer",!0):$=="key"&&H.scrollIntoView(),o&&H.setMeta("composition",o),t.dispatch(H)}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 d=t.state.selection,u=rCt(t,s,r),f=t.state.doc,g=f.slice(u.from,u.to),v,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||c0)&&a.some($=>$.nodeType==1&&!aCt.test($.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",$=>$(t,hk(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(n&&d instanceof $a&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:d.from,endA:d.to,endB:d.to};else{if(u.sel){let $=oMe(t,t.state.doc,u.sel);if($&&!$.eq(t.state.selection)){let q=t.state.tr.setSelection($);o&&q.setMeta("composition",o),t.dispatch(q)}}return}t.state.selection.fromt.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),Am&&a_<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let w=u.doc.resolveNoCache(b.start-u.from),j=u.doc.resolveNoCache(b.endB-u.from),N=f.resolve(b.start),S=w.sameParent(j)&&w.parent.inlineContent&&N.end()>=b.endA;if((m3&&t.input.lastIOSEnter>Date.now()-225&&(!S||a.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!S&&w.pos$(t,hk(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&lCt(f,b.start,b.endA,w,j)&&t.someProp("handleKeyDown",$=>$(t,hk(8,"Backspace")))){c0&&iu&&t.domObserver.suppressSelectionUpdates();return}iu&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),c0&&!S&&w.start()!=j.start()&&j.parentOffset==0&&w.depth==j.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,j=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function($){return $(t,hk(13,"Enter"))})},20));let A=b.start,I=b.endA,L=$=>{let q=$||t.state.tr.replace(A,I,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let H=oMe(t,q.doc,u.sel);H&&!(iu&&t.composing&&H.empty&&(b.start!=b.endB||t.input.lastChromeDeleteC0(t),20));let $=L(t.state.tr.delete(A,I)),q=f.resolve(b.start).marksAcross(f.resolve(b.endA));q&&$.ensureMarks(q),t.dispatch($)}else if(b.endA==b.endB&&(F=oCt(w.parent.content.cut(w.parentOffset,j.parentOffset),N.parent.content.cut(N.parentOffset,b.endA-N.start())))){let $=L(t.state.tr);F.type=="add"?$.addMark(A,I,F.mark):$.removeMark(A,I,F.mark),t.dispatch($)}else if(w.parent.child(w.index()).isText&&w.index()==j.index()-(j.textOffset?0:1)){let $=w.parent.textBetween(w.parentOffset,j.parentOffset),q=()=>L(t.state.tr.insertText($,A,I));t.someProp("handleTextInput",H=>H(t,A,I,$,q))||t.dispatch(q())}else t.dispatch(L());else t.dispatch(L())}function oMe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:S_e(t,s.resolve(r.anchor),s.resolve(r.head))}function oCt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,d;for(let f=0;ff.mark(i.addToSet(f.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",d=f=>f.mark(i.removeFromSet(f.marks));else return null;let u=[];for(let f=0;fr||Vhe(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 cCt(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 d=Math.max(0,o-Math.min(l,i));n-=l+d-o}if(l=l?o-n:0;o-=d,o&&o=i?o-n:0;o-=d,o&&o=56320&&s<=57343&&r>=55296&&r<=56319}class XUe{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 SSt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(mMe),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=uMe(this),dMe(this),this.nodeViews=hMe(this),this.docView=U3e(this.state.doc,cMe(this),Uhe(this),this.dom,this),this.domObserver=new JSt(this,(n,a,o,l)=>iCt(this,n,a,o,l)),this.domObserver.start(),CSt(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&&Qge(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(mMe),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&&(VUe(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 _=hMe(this);uCt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&Qge(this),this.editable=uMe(this),dMe(this);let d=Uhe(this),u=cMe(this),f=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",g=o||!this.docView.matchesNode(s.doc,u,d);(g||!s.selection.eq(a.selection))&&(l=!0);let v=f=="preserve"&&l&&this.dom.style.overflowAnchor==null&&$Nt(this);if(l){this.domObserver.stop();let _=g&&(Am||iu)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&dCt(a.selection,s.selection);if(g){let b=iu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=$St(this)),(o||!this.docView.update(s.doc,u,d,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=U3e(s.doc,u,d,this.dom,this)),b&&!this.trackWrites&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&uSt(this))?C0(this,_):(PUe(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),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():v&&qNt(v)}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 Ta){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&R3e(this,r.getBoundingClientRect(),s)}else R3e(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 WUe(s.slice,s.move,a<0?void 0:Ta.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 KNt(this,s)}coordsAtPos(s,r=1){return kUe(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 JNt(this,r||this.state,s)}pasteHTML(s,r){return $I(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return $I(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return C_e(this,s)}destroy(){this.docView&&(MSt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Uhe(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ENt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return ASt(this,s)}domSelectionRange(){let s=this.domSelection();return s?eh&&this.root.nodeType===11&&ONt(this.dom.ownerDocument)==this.dom&&tCt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}XUe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function cMe(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"),[Ch.node(0,t.state.doc.content.size,s)]}function dMe(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:Ch.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function uMe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function dCt(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 hMe(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 uCt(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 mMe(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 b_={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:"'"},Cne={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},hCt=typeof navigator<"u"&&/Mac/.test(navigator.platform),mCt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Cu=0;Cu<10;Cu++)b_[48+Cu]=b_[96+Cu]=String(Cu);for(var Cu=1;Cu<=24;Cu++)b_[Cu+111]="F"+Cu;for(var Cu=65;Cu<=90;Cu++)b_[Cu]=String.fromCharCode(Cu+32),Cne[Cu]=String.fromCharCode(Cu);for(var Hhe in b_)Cne.hasOwnProperty(Hhe)||(Cne[Hhe]=b_[Hhe]);function pCt(t){var s=hCt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||mCt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?Cne:b_)[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 fCt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),gCt=typeof navigator<"u"&&/Win/.test(navigator.platform);function xCt(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 QUe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const JUe=(t,s,r)=>{let n=QUe(t,r);if(!n)return!1;let a=D_e(n);if(!a){let l=n.blockRange(),i=l&&cM(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(lVe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(p3(o,"end")||Ta.isSelectable(o)))for(let l=n.depth;;l--){let i=$oe(t.doc,n.before(l),n.after(l),fn.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},_Ct=(t,s,r)=>{let n=QUe(t,r);if(!n)return!1;let a=D_e(n);return a?eVe(t,a,s):!1},bCt=(t,s,r)=>{let n=sVe(t,r);if(!n)return!1;let a=O_e(n);return a?eVe(t,a,s):!1};function eVe(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 f=a.lastChild;if(!f)return!1;a=f}let l=s.nodeAfter,i=l,d=s.pos+1;for(;!i.isTextblock;d++){if(i.type.spec.isolating)return!1;let f=i.firstChild;if(!f)return!1;i=f}let u=$oe(t.doc,o,d,fn.empty);if(!u||u.from!=o||u instanceof su&&u.slice.size>=d-o)return!1;if(r){let f=t.tr.step(u);f.setSelection($a.create(f.doc,o)),r(f.scrollIntoView())}return!0}function p3(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 tVe=(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=D_e(n)}let l=o&&o.nodeBefore;return!l||!Ta.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Ta.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function D_e(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 sVe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=sVe(t,r);if(!n)return!1;let a=O_e(n);if(!a)return!1;let o=a.nodeAfter;if(lVe(t,a,s,1))return!0;if(n.parent.content.size==0&&(p3(o,"start")||Ta.isSelectable(o))){let l=$oe(t.doc,n.before(),n.after(),fn.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 Ta,a;if(n){if(r.node.isTextblock||!R_(t.doc,r.from))return!1;a=r.from}else if(a=Boe(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Ta.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},jCt=(t,s)=>{let r=t.selection,n;if(r instanceof Ta){if(r.node.isTextblock||!R_(t.doc,r.to))return!1;n=r.to}else if(n=Boe(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},kCt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&cM(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},aVe=(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 R_e(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=R_e(a.contentMatchAt(o));if(!l||!a.canReplaceWith(o,o,l))return!1;if(s){let i=r.after(),d=t.tr.replaceWith(i,i,l.createAndFill());d.setSelection(si.near(d.doc.resolve(i),1)),s(d.scrollIntoView())}return!0},iVe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof gp||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=R_e(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(S0(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&cM(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function SCt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Ta&&s.selection.node.isBlock)return!n.parentOffset||!S0(s.doc,n.pos)?!1:(r&&r(s.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],l,i,d=!1,u=!1;for(let _=n.depth;;_--)if(n.node(_).isBlock){d=n.end(_)==n.pos+(n.depth-_),u=n.start(_)==n.pos-(n.depth-_),i=R_e(n.node(_-1).contentMatchAt(n.indexAfter(_-1))),o.unshift(d&&i?{type:i}:null),l=_;break}else{if(_==1)return!1;o.unshift(null)}let f=s.tr;(s.selection instanceof $a||s.selection instanceof gp)&&f.deleteSelection();let g=f.mapping.map(n.pos),v=S0(f.doc,g,o.length,o);if(v||(o[0]=i?{type:i}:null,v=S0(f.doc,g,o.length,o)),!v)return!1;if(f.split(g,o.length,o),!d&&u&&n.node(l).type!=i){let _=f.mapping.map(n.before(l)),b=f.doc.resolve(_);i&&n.node(l-1).canReplaceWith(b.index(),b.index()+1,i)&&f.setNodeMarkup(f.mapping.map(n.before(l)),i)}return r&&r(f.scrollIntoView()),!0}}const CCt=SCt(),MCt=(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(Ta.create(t.doc,a))),!0)};function TCt(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||R_(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function lVe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&TCt(t,s,r))return!0;let u=!d&&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 _=s.pos+o.nodeSize,b=Mr.empty;for(let N=l.length-1;N>=0;N--)b=Mr.from(l[N].create(null,b));b=Mr.from(a.copy(b));let w=t.tr.step(new cu(s.pos-1,_,s.pos,_,new fn(b,1,0),l.length,!0)),j=w.doc.resolve(_+2*l.length);j.nodeAfter&&j.nodeAfter.type==a.type&&R_(w.doc,j.pos)&&w.join(j.pos),r(w.scrollIntoView())}return!0}let f=o.type.spec.isolating||n>0&&d?null:si.findFrom(s,1),g=f&&f.$from.blockRange(f.$to),v=g&&cM(g);if(v!=null&&v>=s.depth)return r&&r(t.tr.lift(g,v).scrollIntoView()),!0;if(u&&p3(o,"start",!0)&&p3(a,"end")){let _=a,b=[];for(;b.push(_),!_.isTextblock;)_=_.lastChild;let w=o,j=1;for(;!w.isTextblock;w=w.firstChild)j++;if(_.canReplace(_.childCount,_.childCount,w.content)){if(r){let N=Mr.empty;for(let A=b.length-1;A>=0;A--)N=Mr.from(b[A].copy(N));let S=t.tr.step(new cu(s.pos-b.length,s.pos+o.nodeSize,s.pos+j,s.pos+o.nodeSize-j,new fn(N,b.length,0),0,!0));r(S.scrollIntoView())}return!0}}return!1}function cVe(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($a.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const ACt=cVe(-1),ECt=cVe(1);function PCt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&b_e(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function pMe(t,s=null){return function(r,n){let a=!1;for(let o=0;o{if(a)return!1;if(!(!d.isTextblock||d.hasMarkup(t,s)))if(d.type==t)a=!0;else{let f=r.doc.resolve(u),g=f.index();a=f.parent.canReplaceWith(g,g+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 d=l.resolve(s.start-2);o=new _ne(d,d,s.depth),s.endIndex=0;f--)o=Mr.from(r[f].type.create(r[f].attrs,o));t.step(new cu(s.start-(n?2:0),s.end,s.start,s.end,new fn(o,0,0),r.length,!0));let l=0;for(let f=0;fl.childCount>0&&l.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?RCt(s,r,t,o):FCt(s,r,o):!0:!1}}function RCt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);ow;b--)_-=a.child(b).nodeSize,n.delete(_-1,_+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,d=r.endIndex==a.childCount,u=o.node(-1),f=o.index(-1);if(!u.canReplace(f+(i?0:1),f+1,l.content.append(d?Mr.empty:Mr.from(a))))return!1;let g=o.pos,v=g+l.nodeSize;return n.step(new cu(g-(i?1:0),v+(d?1:0),g+1,v-1,new fn((i?Mr.empty:Mr.from(a.copy(Mr.empty))).append(d?Mr.empty:Mr.from(a.copy(Mr.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function zCt(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,d=i.child(l-1);if(d.type!=t)return!1;if(r){let u=d.lastChild&&d.lastChild.type==i.type,f=Mr.from(u?t.create():null),g=new fn(Mr.from(t.create(null,Mr.from(i.type.create(null,f)))),u?3:1,0),v=o.start,_=o.end;r(s.tr.step(new cu(v-(u?3:1),_,v,_,g,1,!0)).scrollIntoView())}return!0}}function Woe(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 Goe{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,d])=>[i,(...f)=>{const g=d(...f)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),g}]))}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=[],d=!!s,u=s||o.tr,f=()=>(!d&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(v=>v===!0)),g={...Object.fromEntries(Object.entries(n).map(([v,_])=>[v,(...w)=>{const j=this.buildProps(u,r),N=_(...w)(j);return i.push(N),g}])),run:f};return g}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(([d,u])=>[d,(...f)=>u(...f)({...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:Woe({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(([d,u])=>[d,(...f)=>u(...f)(i)]))}};return i}}let BCt=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 Qn(t,s,r){return t.config[s]===void 0&&t.parent?Qn(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?Qn(t.parent,s,r):null}):t.config[s]}function Koe(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 dVe(t){const s=[],{nodeExtensions:r,markExtensions:n}=Koe(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},d=Qn(l,"addGlobalAttributes",i);if(!d)return;d().forEach(f=>{f.types.forEach(g=>{Object.entries(f.attributes).forEach(([v,_])=>{s.push({type:g,name:v,attribute:{...o,..._}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},d=Qn(l,"addAttributes",i);if(!d)return;const u=d();Object.entries(u).forEach(([f,g])=>{const v={...o,...g};typeof(v==null?void 0:v.default)=="function"&&(v.default=v.default()),v!=null&&v.isRequired&&(v==null?void 0:v.default)===void 0&&delete v.default,s.push({type:l.name,name:f,attribute:v})})}),s}function hu(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 Sc(...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(" "):[],d=n[a]?n[a].split(" "):[],u=i.filter(f=>!d.includes(f));n[a]=[...d,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(f=>f.trim()).filter(Boolean):[],d=n[a]?n[a].split(";").map(f=>f.trim()).filter(Boolean):[],u=new Map;d.forEach(f=>{const[g,v]=f.split(":").map(_=>_.trim());u.set(g,v)}),i.forEach(f=>{const[g,v]=f.split(":").map(_=>_.trim());u.set(g,v)}),n[a]=Array.from(u.entries()).map(([f,g])=>`${f}: ${g}`).join("; ")}else n[a]=o}),n},{})}function Jge(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)=>Sc(r,n),{})}function uVe(t){return typeof t=="function"}function qi(t,s=void 0,...r){return uVe(t)?s?t.bind(s)(...r):t(...r):t}function $Ct(t={}){return Object.keys(t).length===0&&t.constructor===Object}function qCt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function fMe(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):qCt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function gMe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&$Ct(r)?!1:r!=null))}function UCt(t,s){var r;const n=dVe(t),{nodeExtensions:a,markExtensions:o}=Koe(t),l=(r=a.find(u=>Qn(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const f=n.filter(N=>N.type===u.name),g={name:u.name,options:u.options,storage:u.storage,editor:s},v=t.reduce((N,S)=>{const A=Qn(S,"extendNodeSchema",g);return{...N,...A?A(u):{}}},{}),_=gMe({...v,content:qi(Qn(u,"content",g)),marks:qi(Qn(u,"marks",g)),group:qi(Qn(u,"group",g)),inline:qi(Qn(u,"inline",g)),atom:qi(Qn(u,"atom",g)),selectable:qi(Qn(u,"selectable",g)),draggable:qi(Qn(u,"draggable",g)),code:qi(Qn(u,"code",g)),whitespace:qi(Qn(u,"whitespace",g)),linebreakReplacement:qi(Qn(u,"linebreakReplacement",g)),defining:qi(Qn(u,"defining",g)),isolating:qi(Qn(u,"isolating",g)),attrs:Object.fromEntries(f.map(N=>{var S;return[N.name,{default:(S=N==null?void 0:N.attribute)===null||S===void 0?void 0:S.default}]}))}),b=qi(Qn(u,"parseHTML",g));b&&(_.parseDOM=b.map(N=>fMe(N,f)));const w=Qn(u,"renderHTML",g);w&&(_.toDOM=N=>w({node:N,HTMLAttributes:Jge(N,f)}));const j=Qn(u,"renderText",g);return j&&(_.toText=j),[u.name,_]})),d=Object.fromEntries(o.map(u=>{const f=n.filter(j=>j.type===u.name),g={name:u.name,options:u.options,storage:u.storage,editor:s},v=t.reduce((j,N)=>{const S=Qn(N,"extendMarkSchema",g);return{...j,...S?S(u):{}}},{}),_=gMe({...v,inclusive:qi(Qn(u,"inclusive",g)),excludes:qi(Qn(u,"excludes",g)),group:qi(Qn(u,"group",g)),spanning:qi(Qn(u,"spanning",g)),code:qi(Qn(u,"code",g)),attrs:Object.fromEntries(f.map(j=>{var N;return[j.name,{default:(N=j==null?void 0:j.attribute)===null||N===void 0?void 0:N.default}]}))}),b=qi(Qn(u,"parseHTML",g));b&&(_.parseDOM=b.map(j=>fMe(j,f)));const w=Qn(u,"renderHTML",g);return w&&(_.toDOM=j=>w({mark:j,HTMLAttributes:Jge(j,f)})),[u.name,_]}));return new Qqe({topNode:l,nodes:i,marks:d})}function Ghe(t,s){return s.nodes[t]||s.marks[t]||null}function xMe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function z_e(t,s){const r=ZN.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const VCt=(t,s=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-s),n,(a,o,l,i)=>{var d,u;const f=((u=(d=a.type.spec).toText)===null||u===void 0?void 0:u.call(d,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";r+=a.isAtom&&!a.isText?f:f.slice(0,Math.max(0,n-o))}),r};function B_e(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Zoe{constructor(s){this.find=s.find,this.handler=s.handler}}const HCt=(t,s)=>{if(B_e(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 N8(t){var s;const{editor:r,from:n,to:a,text:o,rules:l,plugin:i}=t,{view:d}=r;if(d.composing)return!1;const u=d.state.doc.resolve(n);if(u.parent.type.spec.code||!((s=u.nodeBefore||u.nodeAfter)===null||s===void 0)&&s.marks.find(v=>v.type.spec.code))return!1;let f=!1;const g=VCt(u)+o;return l.forEach(v=>{if(f)return;const _=HCt(g,v.find);if(!_)return;const b=d.state.tr,w=Woe({state:d.state,transaction:b}),j={from:n-(_[0].length-o.length),to:a},{commands:N,chain:S,can:A}=new Goe({editor:r,state:w});v.handler({state:w,range:j,match:_,commands:N,chain:S,can:A})===null||!b.steps.length||(b.setMeta(i,{transform:b,from:n,to:a,text:o}),d.dispatch(b),f=!0)}),f}function WCt(t){const{editor:s,rules:r}=t,n=new qd({state:{init(){return null},apply(a,o,l){const i=a.getMeta(n);if(i)return i;const d=a.getMeta("applyInputRules");return!!d&&setTimeout(()=>{let{text:f}=d;typeof f=="string"?f=f:f=z_e(Mr.from(f),l.schema);const{from:g}=d,v=g+f.length;N8({editor:s,from:g,to:v,text:f,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return N8({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&N8({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?N8({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function GCt(t){return Object.prototype.toString.call(t).slice(8,-1)}function S8(t){return GCt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Yoe(t,s){const r={...t};return S8(t)&&S8(s)&&Object.keys(s).forEach(n=>{S8(s[n])&&S8(t[n])?r[n]=Yoe(t[n],s[n]):r[n]=s[n]}),r}class ty{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=qi(Qn(this,"addOptions",{name:this.name}))),this.storage=qi(Qn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new ty(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Yoe(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new ty(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=qi(Qn(r,"addOptions",{name:r.name})),r.storage=qi(Qn(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 d=l.find(u=>(u==null?void 0:u.type.name)===r.name);return d&&n.removeStoredMark(d),n.insertText(" ",a.pos),s.view.dispatch(n),!0}return!1}}function KCt(t){return typeof t=="number"}class ZCt{constructor(s){this.find=s.find,this.handler=s.handler}}const YCt=(t,s,r)=>{if(B_e(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 XCt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:u,can:f}=new Goe({editor:s,state:r}),g=[];return r.doc.nodesBetween(n,a,(_,b)=>{if(!_.isTextblock||_.type.spec.code)return;const w=Math.max(n,b),j=Math.min(a,b+_.content.size),N=_.textBetween(w-b,j-b,void 0,"");YCt(N,o.find,l).forEach(A=>{if(A.index===void 0)return;const I=w+A.index+1,L=I+A[0].length,F={from:r.tr.mapping.map(I),to:r.tr.mapping.map(L)},$=o.handler({state:r,range:F,match:A,commands:d,chain:u,can:f,pasteEvent:l,dropEvent:i});g.push($)})}),g.every(_=>_!==null)}let C8=null;const QCt=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 JCt(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 d=({state:f,from:g,to:v,rule:_,pasteEvt:b})=>{const w=f.tr,j=Woe({state:f,transaction:w});if(!(!XCt({editor:s,state:j,from:Math.max(g-1,0),to:v.b-1,rule:_,pasteEvent:b,dropEvent:i})||!w.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return r.map(f=>new qd({view(g){const v=b=>{var w;n=!((w=g.dom.parentElement)===null||w===void 0)&&w.contains(b.target)?g.dom.parentElement:null,n&&(C8=s)},_=()=>{C8&&(C8=null)};return window.addEventListener("dragstart",v),window.addEventListener("dragend",_),{destroy(){window.removeEventListener("dragstart",v),window.removeEventListener("dragend",_)}}},props:{handleDOMEvents:{drop:(g,v)=>{if(o=n===g.dom.parentElement,i=v,!o){const _=C8;_!=null&&_.isEditable&&setTimeout(()=>{const b=_.state.selection;b&&_.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(g,v)=>{var _;const b=(_=v.clipboardData)===null||_===void 0?void 0:_.getData("text/html");return l=v,a=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(g,v,_)=>{const b=g[0],w=b.getMeta("uiEvent")==="paste"&&!a,j=b.getMeta("uiEvent")==="drop"&&!o,N=b.getMeta("applyPasteRules"),S=!!N;if(!w&&!j&&!S)return;if(S){let{text:L}=N;typeof L=="string"?L=L:L=z_e(Mr.from(L),_.schema);const{from:F}=N,$=F+L.length,q=QCt(L);return d({rule:f,state:_,from:F,to:{b:$},pasteEvt:q})}const A=v.doc.content.findDiffStart(_.doc.content),I=v.doc.content.findDiffEnd(_.doc.content);if(!(!KCt(A)||!I||A===I.b))return d({rule:f,state:_,from:A,to:I,pasteEvt:l})}}))}function e4t(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class T4{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=T4.resolve(s),this.schema=UCt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=T4.sort(T4.flatten(s)),n=e4t(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=Qn(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=Qn(n,"priority")||100,l=Qn(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:Ghe(r.name,this.schema)},a=Qn(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=T4.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:Ghe(l.name,this.schema)},d=[],u=Qn(l,"addKeyboardShortcuts",i);let f={};if(l.type==="mark"&&Qn(l,"exitable",i)&&(f.ArrowRight=()=>ty.handleExit({editor:s,mark:l})),u){const w=Object.fromEntries(Object.entries(u()).map(([j,N])=>[j,()=>N({editor:s})]));f={...f,...w}}const g=vCt(f);d.push(g);const v=Qn(l,"addInputRules",i);xMe(l,s.options.enableInputRules)&&v&&n.push(...v());const _=Qn(l,"addPasteRules",i);xMe(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=Qn(l,"addProseMirrorPlugins",i);if(b){const w=b();d.push(...w)}return d}).flat();return[WCt({editor:s,rules:n}),...JCt({editor:s,rules:a}),...o]}get attributes(){return dVe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=Koe(this.extensions);return Object.fromEntries(r.filter(n=>!!Qn(n,"addNodeView")).map(n=>{const a=this.attributes.filter(d=>d.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:s,type:hu(n.name,this.schema)},l=Qn(n,"addNodeView",o);if(!l)return[];const i=(d,u,f,g,v)=>{const _=Jge(d,a);return l()({node:d,view:u,getPos:f,decorations:g,innerDecorations:v,editor:s,extension:n,HTMLAttributes:_})};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:Ghe(s.name,this.schema)};s.type==="mark"&&(!((r=qi(Qn(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=Qn(s,"onBeforeCreate",n),o=Qn(s,"onCreate",n),l=Qn(s,"onUpdate",n),i=Qn(s,"onSelectionUpdate",n),d=Qn(s,"onTransaction",n),u=Qn(s,"onFocus",n),f=Qn(s,"onBlur",n),g=Qn(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),d&&this.editor.on("transaction",d),u&&this.editor.on("focus",u),f&&this.editor.on("blur",f),g&&this.editor.on("destroy",g)})}}class Lu{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=qi(Qn(this,"addOptions",{name:this.name}))),this.storage=qi(Qn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Lu(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Yoe(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Lu({...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=qi(Qn(r,"addOptions",{name:r.name})),r.storage=qi(Qn(r,"addStorage",{name:r.name,options:r.options})),r}}function hVe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(d,u,f,g)=>{var v;d.isBlock&&u>n&&(i+=o);const _=l==null?void 0:l[d.type.name];if(_)return f&&(i+=_({node:d,pos:u,parent:f,index:g,range:s})),!1;d.isText&&(i+=(v=d==null?void 0:d.text)===null||v===void 0?void 0:v.slice(Math.max(n,u)-u,a-u))}),i}function mVe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const t4t=Lu.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new qd({key:new nh("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(f=>f.$from.pos)),i=Math.max(...o.map(f=>f.$to.pos)),d=mVe(r);return hVe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),s4t=()=>({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),r4t=(t=!1)=>({commands:s})=>s.setContent("",t),n4t=()=>({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,d)=>{if(i.type.isText)return;const{doc:u,mapping:f}=s,g=u.resolve(f.map(d)),v=u.resolve(f.map(d+i.nodeSize)),_=g.blockRange(v);if(!_)return;const b=cM(_);if(i.type.isTextblock){const{defaultType:w}=g.parent.contentMatchAt(g.index());s.setNodeMarkup(_.start,w)}(b||b===0)&&s.lift(_,b)})}),!0},a4t=t=>s=>t(s),i4t=()=>({state:t,dispatch:s})=>iVe(t,s),o4t=(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 $a(n.doc.resolve(Math.max(l-1,0)))),!0},l4t=()=>({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),d=a.after(o);t.delete(i,d).scrollIntoView()}return!0}return!1},c4t=t=>({tr:s,state:r,dispatch:n})=>{const a=hu(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 d=o.before(l),u=o.after(l);s.delete(d,u).scrollIntoView()}return!0}return!1},d4t=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},u4t=()=>({state:t,dispatch:s})=>L_e(t,s),h4t=()=>({commands:t})=>t.keyboardShortcut("Enter"),m4t=()=>({state:t,dispatch:s})=>NCt(t,s);function Mne(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:B_e(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function pVe(t,s,r={}){return t.find(n=>n.type===s&&Mne(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function yMe(t,s,r={}){return!!pVe(t,s,r)}function $_e(t,s,r){var n;if(!t||!s)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(f=>f.type===s))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(f=>f.type===s)||(r=r||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!pVe([...a.node.marks],s,r)))return;let l=a.index,i=t.start()+a.offset,d=l+1,u=i+a.node.nodeSize;for(;l>0&&yMe([...t.parent.child(l-1).marks],s,r);)l-=1,i-=t.parent.child(l).nodeSize;for(;d({tr:r,state:n,dispatch:a})=>{const o=z_(t,n.schema),{doc:l,selection:i}=r,{$from:d,from:u,to:f}=i;if(a){const g=$_e(d,o,s);if(g&&g.from<=u&&g.to>=f){const v=$a.create(l,g.from,g.to);r.setSelection(v)}}return!0},f4t=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=()=>{(q_e()||g4t())&&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&&!fVe(r.state.selection))return l(),!0;const i=gVe(a.doc,t)||r.state.selection,d=r.state.selection.eq(i);return o&&(d||a.setSelection(i),d&&a.storedMarks&&a.setStoredMarks(a.storedMarks),l()),!0},y4t=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),v4t=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),xVe=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&&xVe(n)}return t};function M8(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return xVe(r)}function UI(t,s,r){if(t instanceof n_||t instanceof Mr)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 Mr.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),UI("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const d=new Qqe({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?LP.fromSchema(d).parseSlice(M8(t),r.parseOptions):LP.fromSchema(d).parse(M8(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=LP.fromSchema(s);return r.slice?o.parseSlice(M8(t),r.parseOptions).content:o.parse(M8(t),r.parseOptions)}return UI("",s,r)}function _4t(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=f)}),t.setSelection(si.near(t.doc.resolve(l),r))}const b4t=t=>!("type"in t),w4t=(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 d=j=>{o.emit("contentError",{editor:o,error:j,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{UI(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(j){d(j)}try{i=UI(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(j){return d(j),!1}let{from:f,to:g}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},v=!0,_=!0;if((b4t(i)?i:[i]).forEach(j=>{j.check(),v=v?j.isText&&j.marks.length===0:!1,_=_?j.isBlock:!1}),f===g&&_){const{parent:j}=n.doc.resolve(f);j.isTextblock&&!j.type.spec.code&&!j.childCount&&(f-=1,g+=1)}let w;if(v){if(Array.isArray(s))w=s.map(j=>j.text||"").join("");else if(s instanceof Mr){let j="";s.forEach(N=>{N.text&&(j+=N.text)}),w=j}else typeof s=="object"&&s&&s.text?w=s.text:w=s;n.insertText(w,f,g)}else w=i,n.replaceWith(f,g,w);r.updateSelection&&_4t(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:f,text:w}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:f,text:w})}return!0},j4t=()=>({state:t,dispatch:s})=>wCt(t,s),k4t=()=>({state:t,dispatch:s})=>jCt(t,s),N4t=()=>({state:t,dispatch:s})=>JUe(t,s),S4t=()=>({state:t,dispatch:s})=>rVe(t,s),C4t=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Boe(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},M4t=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Boe(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},T4t=()=>({state:t,dispatch:s})=>_Ct(t,s),A4t=()=>({state:t,dispatch:s})=>bCt(t,s);function yVe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function E4t(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=E4t(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}),d=s.captureTransaction(()=>{r.someProp("handleKeyDown",u=>u(r,i))});return d==null||d.steps.forEach(u=>{const f=u.map(n.mapping);f&&a&&n.maybeStep(f)}),!0};function VI(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?hu(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(g,v)=>{if(g.isText)return;const _=Math.max(n,v),b=Math.min(a,v+g.nodeSize);i.push({node:g,from:_,to:b})});const d=a-n,u=i.filter(g=>l?l.name===g.node.type.name:!0).filter(g=>Mne(g.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((g,v)=>g+v.to-v.from,0)>=d}const I4t=(t,s={})=>({state:r,dispatch:n})=>{const a=hu(t,r.schema);return VI(r,a,s)?kCt(r,n):!1},L4t=()=>({state:t,dispatch:s})=>oVe(t,s),D4t=t=>({state:s,dispatch:r})=>{const n=hu(t,s.schema);return OCt(n)(s,r)},O4t=()=>({state:t,dispatch:s})=>aVe(t,s);function Xoe(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function vMe(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 R4t=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Xoe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=hu(t,n.schema)),i==="mark"&&(l=z_(t,n.schema)),a&&r.selection.ranges.forEach(d=>{n.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,f)=>{o&&o===u.type&&r.setNodeMarkup(f,void 0,vMe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(g=>{l===g.type&&r.addMark(f,f+u.nodeSize,l.create(vMe(g.attrs,s)))})})}),!0):!1},F4t=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),z4t=()=>({tr:t,dispatch:s})=>{if(s){const r=new gp(t.doc);t.setSelection(r)}return!0},B4t=()=>({state:t,dispatch:s})=>tVe(t,s),$4t=()=>({state:t,dispatch:s})=>nVe(t,s),q4t=()=>({state:t,dispatch:s})=>MCt(t,s),U4t=()=>({state:t,dispatch:s})=>ECt(t,s),V4t=()=>({state:t,dispatch:s})=>ACt(t,s);function exe(t,s,r={},n={}){return UI(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const H4t=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var d,u;const{doc:f}=o;if(r.preserveWhitespace!=="full"){const g=exe(t,a.schema,r,{errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:a.options.enableContentCheck});return l&&o.replaceWith(0,f.content.size,g).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:f.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function vVe(t,s){const r=z_(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,d=>{l.push(...d.marks)});const i=l.find(d=>d.type.name===r.name);return i?{...i.attrs}:{}}function W4t(t,s){const r=new w_e(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function G4t(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function _Ve(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 U_e(t){return s=>_Ve(s.$from,t)}function Z4t(t,s){const r={from:0,to:t.content.size};return hVe(t,r,s)}function Y4t(t,s){const r=hu(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 bVe(t,s){const r=Xoe(typeof s=="string"?s:s.name,t.schema);return r==="node"?Y4t(t,s):r==="mark"?vVe(t,s):{}}function X4t(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 Q4t(t){const s=X4t(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 J4t(t){const{mapping:s,steps:r}=t,n=[];return s.maps.forEach((a,o)=>{const l=[];if(a.ranges.length)a.forEach((i,d)=>{l.push({from:i,to:d})});else{const{from:i,to:d}=r[o];if(i===void 0||d===void 0)return;l.push({from:i,to:d})}l.forEach(({from:i,to:d})=>{const u=s.slice(o).map(i,-1),f=s.slice(o).map(d),g=s.invert().map(u,-1),v=s.invert().map(f);n.push({oldRange:{from:g,to:v},newRange:{from:u,to:f}})})}),Q4t(n)}function V_e(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=$_e(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 Xse(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 txe(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?z_(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(g=>o?o.name===g.type.name:!0).find(g=>Mne(g.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:g,$to:v})=>{const _=g.pos,b=v.pos;t.doc.nodesBetween(_,b,(w,j)=>{if(!w.isText&&!w.marks.length)return;const N=Math.max(_,j),S=Math.min(b,j+w.nodeSize),A=S-N;l+=A,i.push(...w.marks.map(I=>({mark:I,from:N,to:S})))})}),l===0)return!1;const d=i.filter(g=>o?o.name===g.mark.type.name:!0).filter(g=>Mne(g.mark.attrs,r,{strict:!1})).reduce((g,v)=>g+v.to-v.from,0),u=i.filter(g=>o?g.mark.type!==o&&g.mark.type.excludes(o):!0).reduce((g,v)=>g+v.to-v.from,0);return(d>0?d+u:d)>=l}function e5t(t,s,r={}){if(!s)return VI(t,null,r)||txe(t,null,r);const n=Xoe(s,t.schema);return n==="node"?VI(t,s,r):n==="mark"?txe(t,s,r):!1}function _Me(t,s){const{nodeExtensions:r}=Koe(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=qi(Qn(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function H_e(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&&(H_e(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function t5t(t){return t instanceof Ta}function s5t(t,s,r){var n;const{selection:a}=s;let o=null;if(fVe(a)&&(o=a.$cursor),o){const i=(n=t.storedMarks)!==null&&n!==void 0?n:o.marks();return!!r.isInSet(i)||!i.some(d=>d.type.excludes(r))}const{ranges:l}=a;return l.some(({$from:i,$to:d})=>{let u=i.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(i.pos,d.pos,(f,g,v)=>{if(u)return!1;if(f.isInline){const _=!v||v.type.allowsMarkType(r),b=!!r.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(r));u=_&&b}return!u}),u})}const r5t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,d=z_(t,n.schema);if(a)if(l){const u=vVe(n,d);r.addStoredMark(d.create({...u,...s}))}else i.forEach(u=>{const f=u.$from.pos,g=u.$to.pos;n.doc.nodesBetween(f,g,(v,_)=>{const b=Math.max(_,f),w=Math.min(_+v.nodeSize,g);v.marks.find(N=>N.type===d)?v.marks.forEach(N=>{d===N.type&&r.addMark(b,w,d.create({...N.attrs,...s}))}):r.addMark(b,w,d.create(s))})});return s5t(n,r,d)},n5t=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),a5t=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=hu(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})=>pMe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>pMe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},i5t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=jk(t,0,n.content.size),o=Ta.create(n,a);s.setSelection(o)}return!0},o5t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=$a.atStart(n).from,i=$a.atEnd(n).to,d=jk(a,l,i),u=jk(o,l,i),f=$a.create(n,d,u);s.setSelection(f)}return!0},l5t=t=>({state:s,dispatch:r})=>{const n=hu(t,s.schema);return zCt(n)(s,r)};function bMe(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 c5t=({keepMarks:t=!0}={})=>({tr:s,state:r,dispatch:n,editor:a})=>{const{selection:o,doc:l}=s,{$from:i,$to:d}=o,u=a.extensionManager.attributes,f=Xse(u,i.node().type.name,i.node().attrs);if(o instanceof Ta&&o.node.isBlock)return!i.parentOffset||!S0(l,i.pos)?!1:(n&&(t&&bMe(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const g=d.parentOffset===d.parent.content.size,v=i.depth===0?void 0:G4t(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=g&&v?[{type:v,attrs:f}]:void 0,b=S0(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!b&&S0(s.doc,s.mapping.map(i.pos),1,v?[{type:v}]:void 0)&&(b=!0,_=v?[{type:v,attrs:f}]:void 0),n){if(b&&(o instanceof $a&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),v&&!g&&!i.parentOffset&&i.parent.type!==v)){const w=s.mapping.map(i.before()),j=s.doc.resolve(w);i.node(-1).canReplaceWith(j.index(),j.index()+1,v)&&s.setNodeMarkup(s.mapping.map(i.before()),v)}t&&bMe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},d5t=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=hu(t,n.schema),{$from:d,$to:u}=n.selection,f=n.selection.node;if(f&&f.isBlock||d.depth<2||!d.sameParent(u))return!1;const g=d.node(-1);if(g.type!==i)return!1;const v=o.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==i||d.index(-2)!==d.node(-2).childCount-1)return!1;if(a){let N=Mr.empty;const S=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-S;q>=d.depth-3;q-=1)N=Mr.from(d.node(q).copy(N));const A=d.indexAfter(-1){if($>-1)return!1;q.isTextblock&&q.content.size===0&&($=H+1)}),$>-1&&r.setSelection($a.near(r.doc.resolve($))),r.scrollIntoView()}return!0}const _=u.pos===d.end()?g.contentMatchAt(0).defaultType:null,b={...Xse(v,g.type.name,g.attrs),...s},w={...Xse(v,d.node().type.name,d.node().attrs),...s};r.delete(d.pos,u.pos);const j=_?[{type:i,attrs:b},{type:_,attrs:w}]:[{type:i,attrs:b}];if(!S0(r.doc,d.pos,2))return!1;if(a){const{selection:N,storedMarks:S}=n,{splittableMarks:A}=o.extensionManager,I=S||N.$to.parentOffset&&N.$from.marks();if(r.split(d.pos,2,j).scrollIntoView(),!I||!a)return!0;const L=I.filter(F=>A.includes(F.type.name));r.ensureMarks(L)}return!0},Khe=(t,s)=>{const r=U_e(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)&&R_(t.doc,r.pos)&&t.join(r.pos),!0},Zhe=(t,s)=>{const r=U_e(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)&&R_(t.doc,n)&&t.join(n),!0},u5t=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:u,can:f})=>{const{extensions:g,splittableMarks:v}=a.extensionManager,_=hu(t,l.schema),b=hu(s,l.schema),{selection:w,storedMarks:j}=l,{$from:N,$to:S}=w,A=N.blockRange(S),I=j||w.$to.parentOffset&&w.$from.marks();if(!A)return!1;const L=U_e(F=>_Me(F.type.name,g))(w);if(A.depth>=1&&L&&A.depth-L.depth<=1){if(L.node.type===_)return u.liftListItem(b);if(_Me(L.node.type.name,g)&&_.validContent(L.node.content)&&i)return d().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>Khe(o,_)).command(()=>Zhe(o,_)).run()}return!r||!I||!i?d().command(()=>f().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>Khe(o,_)).command(()=>Zhe(o,_)).run():d().command(()=>{const F=f().wrapInList(_,n),$=I.filter(q=>v.includes(q.type.name));return o.ensureMarks($),F?!0:u.clearNodes()}).wrapInList(_,n).command(()=>Khe(o,_)).command(()=>Zhe(o,_)).run()},h5t=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=z_(t,n.schema);return txe(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},m5t=(t,s,r={})=>({state:n,commands:a})=>{const o=hu(t,n.schema),l=hu(s,n.schema),i=VI(n,o,r);let d;return n.selection.$anchor.sameParent(n.selection.$head)&&(d=n.selection.$anchor.parent.attrs),i?a.setNode(l,d):a.setNode(o,{...d,...r})},p5t=(t,s={})=>({state:r,commands:n})=>{const a=hu(t,r.schema);return VI(r,a,s)?n.lift(a):n.wrapIn(a,s)},f5t=()=>({state:t,dispatch:s})=>{const r=t.plugins;for(let n=0;n=0;d-=1)l.step(i.steps[d].invert(i.docs[d]));if(o.text){const d=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,d))}else l.delete(o.from,o.to)}return!0}}return!1},g5t=()=>({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},x5t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,d=z_(t,n.schema),{$from:u,empty:f,ranges:g}=i;if(!a)return!0;if(f&&l){let{from:v,to:_}=i;const b=(o=u.marks().find(j=>j.type===d))===null||o===void 0?void 0:o.attrs,w=$_e(u,d,b);w&&(v=w.from,_=w.to),r.removeMark(v,_,d)}else g.forEach(v=>{r.removeMark(v.$from.pos,v.$to.pos,d)});return r.removeStoredMark(d),!0},y5t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Xoe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=hu(t,n.schema)),i==="mark"&&(l=z_(t,n.schema)),a&&r.selection.ranges.forEach(d=>{const u=d.$from.pos,f=d.$to.pos;let g,v,_,b;r.selection.empty?n.doc.nodesBetween(u,f,(w,j)=>{o&&o===w.type&&(_=Math.max(j,u),b=Math.min(j+w.nodeSize,f),g=j,v=w)}):n.doc.nodesBetween(u,f,(w,j)=>{j=u&&j<=f&&(o&&o===w.type&&r.setNodeMarkup(j,void 0,{...w.attrs,...s}),l&&w.marks.length&&w.marks.forEach(N=>{if(l===N.type){const S=Math.max(j,u),A=Math.min(j+w.nodeSize,f);r.addMark(S,A,l.create({...N.attrs,...s}))}}))}),v&&(g!==void 0&&r.setNodeMarkup(g,void 0,{...v.attrs,...s}),l&&v.marks.length&&v.marks.forEach(w=>{l===w.type&&r.addMark(_,b,l.create({...w.attrs,...s}))}))}),!0):!1},v5t=(t,s={})=>({state:r,dispatch:n})=>{const a=hu(t,r.schema);return PCt(a,s)(r,n)},_5t=(t,s={})=>({state:r,dispatch:n})=>{const a=hu(t,r.schema);return ICt(a,s)(r,n)};var b5t=Object.freeze({__proto__:null,blur:s4t,clearContent:r4t,clearNodes:n4t,command:a4t,createParagraphNear:i4t,cut:o4t,deleteCurrentNode:l4t,deleteNode:c4t,deleteRange:d4t,deleteSelection:u4t,enter:h4t,exitCode:m4t,extendMarkRange:p4t,first:f4t,focus:x4t,forEach:y4t,insertContent:v4t,insertContentAt:w4t,joinBackward:N4t,joinDown:k4t,joinForward:S4t,joinItemBackward:C4t,joinItemForward:M4t,joinTextblockBackward:T4t,joinTextblockForward:A4t,joinUp:j4t,keyboardShortcut:P4t,lift:I4t,liftEmptyBlock:L4t,liftListItem:D4t,newlineInCode:O4t,resetAttributes:R4t,scrollIntoView:F4t,selectAll:z4t,selectNodeBackward:B4t,selectNodeForward:$4t,selectParentNode:q4t,selectTextblockEnd:U4t,selectTextblockStart:V4t,setContent:H4t,setMark:r5t,setMeta:n5t,setNode:a5t,setNodeSelection:i5t,setTextSelection:o5t,sinkListItem:l5t,splitBlock:c5t,splitListItem:d5t,toggleList:u5t,toggleMark:h5t,toggleNode:m5t,toggleWrap:p5t,undoInputRule:f5t,unsetAllMarks:g5t,unsetMark:x5t,updateAttributes:y5t,wrapIn:v5t,wrapInList:_5t});const w5t=Lu.create({name:"commands",addCommands(){return{...b5t}}}),j5t=Lu.create({name:"drop",addProseMirrorPlugins(){return[new qd({key:new nh("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),k5t=Lu.create({name:"editable",addProseMirrorPlugins(){return[new qd({key:new nh("editable"),props:{editable:()=>this.editor.options.editable}})]}}),N5t=new nh("focusEvents"),S5t=Lu.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new qd({key:N5t,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}}}})]}}),C5t=Lu.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:d,doc:u}=i,{empty:f,$anchor:g}=d,{pos:v,parent:_}=g,b=g.parent.isTextblock&&v>0?i.doc.resolve(v-1):g,w=b.parent.type.spec.isolating,j=g.pos-g.parentOffset,N=w&&b.parent.childCount===1?j===g.pos:si.atStart(u).from===v;return!f||!_.type.isTextblock||_.textContent.length||!N||N&&g.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 q_e()||yVe()?o:a},addProseMirrorPlugins(){return[new qd({key:new nh("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(w=>w.getMeta("composition")))return;const n=t.some(w=>w.docChanged)&&!s.doc.eq(r.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,d=si.atStart(s.doc).from,u=si.atEnd(s.doc).to;if(o||!(l===d&&i===u)||!H_e(r.doc))return;const v=r.tr,_=Woe({state:r,transaction:v}),{commands:b}=new Goe({editor:this.editor,state:_});if(b.clearNodes(),!!v.steps.length)return v}})]}}),M5t=Lu.create({name:"paste",addProseMirrorPlugins(){return[new qd({key:new nh("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),T5t=Lu.create({name:"tabindex",addProseMirrorPlugins(){return[new qd({key:new nh("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class mk{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 mk(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 mk(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 mk(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 d=new mk(i,this.editor,a,a?r:null);a&&(d.actualDepth=this.depth+1),s.push(new mk(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(d=>r[d]===l.node.attrs[d])&&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 A5t=`.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 E5t(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 P5t extends BCt{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=E5t(A5t,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=uVe(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?[k5t,t4t.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),w5t,S5t,C5t,T5t,j5t,M5t].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 T4(a,this)}createCommandManager(){this.commandManager=new Goe({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=exe(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=exe(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=gVe(r,this.options.autofocus);this.view=new XUe(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:M4.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 bVe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return e5t(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return z_e(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return Z4t(this.state.doc,{blockSeparator:r,textSerializers:{...mVe(this.schema),...n}})}get isEmpty(){return H_e(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 mk(r,this)}get $doc(){return this.$pos(0)}}function f3(t){return new Zoe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=qi(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 d=i.search(/\S/),u=r.from+i.indexOf(l),f=u+l.length;if(V_e(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(w=>w===t.type&&w!==_.mark.type)).filter(_=>_.to>u).length)return null;fr.from&&o.delete(r.from+d,u);const v=r.from+d+l.length;o.addMark(r.from+d,v,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function wVe(t){return new Zoe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=qi(t.getAttributes,void 0,n)||{},{tr:o}=s,l=r.from;let i=r.to;const d=t.type.create(a);if(n[1]){const u=n[0].lastIndexOf(n[1]);let f=l+u;f>i?f=i:i=f+n[1].length;const g=n[0][n[0].length-1];o.insertText(g,l+n[0].length-1),o.replaceWith(f,i,d)}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 sxe(t){return new Zoe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=qi(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 HI(t){return new Zoe({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=qi(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),d=l.doc.resolve(r.from).blockRange(),u=d&&b_e(d,t.type,o);if(!u)return null;if(l.wrap(d,u),t.keepMarks&&t.editor){const{selection:g,storedMarks:v}=s,{splittableMarks:_}=t.editor.extensionManager,b=v||g.$to.parentOffset&&g.$from.marks();if(b){const w=b.filter(j=>_.includes(j.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const g=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(g,o).run()}const f=l.doc.resolve(r.from-1).nodeBefore;f&&f.type===t.type&&R_(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,f))&&l.join(r.from-1)}})}let ah=class rxe{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=qi(Qn(this,"addOptions",{name:this.name}))),this.storage=qi(Qn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new rxe(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Yoe(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new rxe(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=qi(Qn(r,"addOptions",{name:r.name})),r.storage=qi(Qn(r,"addStorage",{name:r.name,options:r.options})),r}};function IN(t){return new ZCt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=qi(t.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=s,i=n[n.length-1],d=n[0];let u=r.to;if(i){const f=d.search(/\S/),g=r.from+d.indexOf(i),v=g+i.length;if(V_e(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>g).length)return null;vr.from&&l.delete(r.from+f,g),u=r.from+f+i.length,l.addMark(r.from+f,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function I5t(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Ta){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 L5t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jVe={exports:{}},Yhe={};/** * @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 wMe;function D5t(){if(wMe)return Yhe;wMe=1;var t=ut;function s(g,v){return g===v&&(g!==0||1/g===1/v)||g!==g&&v!==v}var r=typeof Object.is=="function"?Object.is:s,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(g,v){var _=v(),b=n({inst:{value:_,getSnapshot:v}}),w=b[0].inst,j=b[1];return o(function(){w.value=_,w.getSnapshot=v,d(w)&&j({inst:w})},[g,_,v]),a(function(){return d(w)&&j({inst:w}),g(function(){d(w)&&j({inst:w})})},[g]),l(_),_}function d(g){var v=g.getSnapshot;g=g.value;try{var _=v();return!r(g,_)}catch{return!0}}function u(g,v){return v()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return Yhe.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Yhe}jVe.exports=D5t();var W_e=jVe.exports;const O5t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},R5t=({contentComponent:t})=>{const s=W_e.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ut.createElement(ut.Fragment,null,Object.values(s))};function F5t(){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]:Lve.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 z5t extends ut.Component{constructor(s){var r;super(s),this.editorContentRef=ut.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=F5t(),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 ut.createElement(ut.Fragment,null,ut.createElement("div",{ref:O5t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ut.createElement(R5t,{contentComponent:s.contentComponent}))}}const B5t=M.forwardRef((t,s)=>{const r=ut.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ut.createElement(z5t,{key:r,innerRef:s,...t})}),kVe=ut.memo(B5t);var $5t=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},q5t=L5t($5t),NVe={exports:{}},Xhe={};/** * @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 jMe;function U5t(){if(jMe)return Xhe;jMe=1;var t=ut,s=W_e;function r(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:r,a=s.useSyncExternalStore,o=t.useRef,l=t.useEffect,i=t.useMemo,d=t.useDebugValue;return Xhe.useSyncExternalStoreWithSelector=function(u,f,g,v,_){var b=o(null);if(b.current===null){var w={hasValue:!1,value:null};b.current=w}else w=b.current;b=i(function(){function N(F){if(!S){if(S=!0,A=F,F=v(F),_!==void 0&&w.hasValue){var $=w.value;if(_($,F))return I=$}return I=F}if($=I,n(A,F))return $;var q=v(F);return _!==void 0&&_($,q)?$:(A=F,I=q)}var S=!1,A,I,L=g===void 0?null:g;return[function(){return N(f())},L===null?void 0:function(){return N(L())}]},[f,g,v,_]);var j=a(u,b[0],b[1]);return l(function(){w.hasValue=!0,w.value=j},[j]),d(j),j},Xhe}NVe.exports=U5t();var V5t=NVe.exports;const H5t=typeof window<"u"?M.useLayoutEffect:M.useEffect;class W5t{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 G5t(t){var s;const[r]=M.useState(()=>new W5t(t.editor)),n=V5t.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:q5t);return H5t(()=>r.watch(t.editor),[t.editor,r]),M.useDebugValue(n),n}const K5t=!1,nxe=typeof window>"u",Z5t=nxe||!!(typeof window<"u"&&window.next);class G_e{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?nxe||Z5t?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 P5t(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?G_e.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 SVe(t={},s=[]){const r=M.useRef(t);r.current=t;const[n]=M.useState(()=>new G_e(r)),a=W_e.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return M.useDebugValue(a),M.useEffect(n.onRender(s)),G5t({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const Y5t=M.createContext({editor:null});Y5t.Consumer;const X5t=M.createContext({onDragStart:void 0}),Q5t=()=>M.useContext(X5t);ut.forwardRef((t,s)=>{const{onDragStart:r}=Q5t(),n=t.as||"div";return ut.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const J5t=/^\s*>\s$/,e3t=ah.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Sc(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[HI({find:J5t,type:this.type})]}}),t3t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,s3t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,r3t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,n3t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,a3t=ty.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",Sc(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[f3({find:t3t,type:this.type}),f3({find:r3t,type:this.type})]},addPasteRules(){return[IN({find:s3t,type:this.type}),IN({find:n3t,type:this.type})]}}),i3t="listItem",kMe="textStyle",NMe=/^\s*([-+*])\s$/,o3t=ah.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",Sc(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(i3t,this.editor.getAttributes(kMe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=HI({find:NMe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=HI({find:NMe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kMe),editor:this.editor})),[t]}}),l3t=/(^|[^`])`([^`]+)`(?!`)/,c3t=/(^|[^`])`([^`]+)`(?!`)/g,d3t=ty.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Sc(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[f3({find:l3t,type:this.type})]},addPasteRules(){return[IN({find:c3t,type:this.type})]}}),u3t=/^```([a-z]+)?[\s\n]$/,h3t=/^~~~([a-z]+)?[\s\n]$/,m3t=ah.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",Sc(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(si.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[sxe({find:u3t,type:this.type,getAttributes:t=>({language:t[1]})}),sxe({find:h3t,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new qd({key:new nh("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,d=i.text(r.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},d)),l.selection.$from.parent.type!==this.type&&l.setSelection($a.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),p3t=ah.create({name:"doc",topNode:!0,content:"block+"});function f3t(t={}){return new qd({view(s){return new g3t(s,t)}})}class g3t{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 g=s.nodeBefore,v=s.nodeAfter;if(g||v){let _=this.editorView.nodeDOM(this.cursorPos-(g?g.nodeSize:0));if(_){let b=_.getBoundingClientRect(),w=g?b.bottom:b.top;g&&v&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let j=this.width/2*i;n={left:b.left,right:b.right,top:w-j,bottom:w+j}}}}if(!n){let g=this.editorView.coordsAtPos(this.cursorPos),v=this.width/2*l;n={left:g.left-v,right:g.left+v,top:g.top,bottom:g.bottom}}let d=this.editorView.dom.offsetParent;this.element||(this.element=d.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,f;if(!d||d==document.body&&getComputedStyle(d).position=="static")u=-pageXOffset,f=-pageYOffset;else{let g=d.getBoundingClientRect(),v=g.width/d.offsetWidth,_=g.height/d.offsetHeight;u=g.left-d.scrollLeft*v,f=g.top-d.scrollTop*_}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-f)/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=cUe(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 x3t=Lu.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[f3t(this.options)]}});class Rc extends si{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return Rc.valid(n)?new Rc(n):si.near(n)}content(){return fn.empty}eq(s){return s instanceof Rc&&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 Rc(s.resolve(r.pos))}getBookmark(){return new K_e(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!y3t(s)||!v3t(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&&Rc.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 d=s.doc.resolve(a);if(Rc.valid(d))return d}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Ta.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(Rc.valid(i))return i}return null}}}Rc.prototype.visible=!1;Rc.findFrom=Rc.findGapCursorFrom;si.jsonID("gapcursor",Rc);class K_e{constructor(s){this.pos=s}map(s){return new K_e(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return Rc.valid(r)?new Rc(r):si.near(r)}}function CVe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function y3t(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||CVe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function v3t(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||CVe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function _3t(){return new qd({props:{decorations:k3t,createSelectionBetween(t,s,r){return s.pos==r.pos&&Rc.valid(r)?new Rc(r):null},handleClick:w3t,handleKeyDown:b3t,handleDOMEvents:{beforeinput:j3t}}})}const b3t=I_e({ArrowLeft:T8("horiz",-1),ArrowRight:T8("horiz",1),ArrowUp:T8("vert",-1),ArrowDown:T8("vert",1)});function T8(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,d=l.empty;if(l instanceof $a){if(!o.endOfTextblock(r)||i.depth==0)return!1;d=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=Rc.findGapCursorFrom(i,s,d);return u?(a&&a(n.tr.setSelection(new Rc(u))),!0):!1}}function w3t(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!Rc.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Ta.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Rc(n))),!0)}function j3t(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof Rc))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=Mr.empty;for(let l=n.length-1;l>=0;l--)a=Mr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new fn(a,0,0));return o.setSelection($a.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function k3t(t){if(!(t.selection instanceof Rc))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",Oc.create(t.doc,[Ch.widget(t.selection.head,s,{key:"gapcursor"})])}const N3t=Lu.create({name:"gapCursor",addProseMirrorPlugins(){return[_3t()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=qi(Qn(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),S3t=ah.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",Sc(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,d=o||a.$to.parentOffset&&a.$from.marks();return s().insertContent({type:this.name}).command(({tr:u,dispatch:f})=>{if(f&&d&&l){const g=d.filter(v=>i.includes(v.type.name));u.ensureMarks(g)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),C3t=ah.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]}`,Sc(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=>sxe({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Tne=200,du=function(){};du.prototype.append=function(s){return s.length?(s=du.from(s),!this.length&&s||s.length=r?du.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};du.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};du.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)};du.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};du.from=function(s){return s instanceof du?s:s&&s.length?new MVe(s):du.empty};var MVe=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 d=o;d=l;d--)if(a(this.values[d],i+d)===!1)return!1},s.prototype.leafAppend=function(a){if(this.length+a.length<=Tne)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=Tne)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}(du);du.empty=new MVe([]);var M3t=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}(du);const T3t=500;class _g{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,d,u=[],f=[];return this.items.forEach((g,v)=>{if(!g.step){a||(a=this.remapping(n,v+1),o=a.maps.length),o--,f.push(g);return}if(a){f.push(new vx(g.map));let _=g.step.map(a.slice(o)),b;_&&l.maybeStep(_).doc&&(b=l.mapping.maps[l.mapping.maps.length-1],u.push(new vx(b,void 0,void 0,u.length+f.length))),o--,b&&a.appendMap(b,o)}else l.maybeStep(g.step);if(g.selection)return i=a?g.selection.map(a.slice(o)):g.selection,d=new _g(this.items.slice(0,n).append(f.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:l,selection:i}}addTransform(s,r,n,a){let o=[],l=this.eventCount,i=this.items,d=!a&&i.length?i.get(i.length-1):null;for(let f=0;fE3t&&(i=A3t(i,u),l-=u),new _g(i.append(o),l)}remapping(s,r){let n=new FI;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 _g(this.items.append(s.map(r=>new vx(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(v=>{v.selection&&i--},a);let d=r;this.items.forEach(v=>{let _=o.getMirror(--d);if(_==null)return;l=Math.min(l,_);let b=o.maps[_];if(v.step){let w=s.steps[_].invert(s.docs[_]),j=v.selection&&v.selection.map(o.slice(d+1,_));j&&i++,n.push(new vx(b,w,j))}else n.push(new vx(b))},a);let u=[];for(let v=r;vT3t&&(g=g.compress(this.items.length-n.length)),g}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 d=l.step.map(r.slice(n)),u=d&&d.getMap();if(n--,u&&r.appendMap(u,n),d){let f=l.selection&&l.selection.map(r.slice(n));f&&o++;let g=new vx(u.invert(),d,f),v,_=a.length-1;(v=a.length&&a[_].merge(g))?a[_]=v:a.push(g)}}else l.map&&n--},this.items.length,0),new _g(du.from(a.reverse()),o)}}_g.empty=new _g(du.empty,0);function A3t(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class vx{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 vx(r.getMap().invert(),r,this.selection)}}}class t1{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const E3t=20;function P3t(t,s,r,n){let a=r.getMeta(cN),o;if(a)return a.historyState;r.getMeta(D3t)&&(t=new t1(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(cN))return l.getMeta(cN).redo?new t1(t.done.addTransform(r,void 0,n,Qse(s)),t.undone,SMe(r.mapping.maps),t.prevTime,t.prevComposition):new t1(t.done,t.undone.addTransform(r,void 0,n,Qse(s)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let i=r.getMeta("composition"),d=t.prevTime==0||!l&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!I3t(r,t.prevRanges)),u=l?Qhe(t.prevRanges,r.mapping):SMe(r.mapping.maps);return new t1(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,Qse(s)),_g.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new t1(t.done.rebased(r,o),t.undone.rebased(r,o),Qhe(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new t1(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Qhe(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function I3t(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 SMe(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 Qhe(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=cN.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=L3t(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const AVe=TVe(!1,!0),EVe=TVe(!0,!0),R3t=Lu.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>AVe(t,s),redo:()=>({state:t,dispatch:s})=>EVe(t,s)}},addProseMirrorPlugins(){return[O3t(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()}}}),F3t=ah.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Sc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!I5t(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}):t5t(r)?o.insertContentAt(a.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:l,dispatch:i})=>{var d;if(i){const{$to:u}=l.selection,f=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection($a.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Ta.create(l.doc,u.pos)):l.setSelection($a.create(l.doc,u.pos));else{const g=(d=u.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();g&&(l.insert(f,g),l.setSelection($a.create(l.doc,f+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[wVe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),z3t=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,B3t=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,$3t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,q3t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,U3t=ty.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",Sc(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[f3({find:z3t,type:this.type}),f3({find:$3t,type:this.type})]},addPasteRules(){return[IN({find:B3t,type:this.type}),IN({find:q3t,type:this.type})]}}),V3t=ah.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Sc(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)}}}),H3t="listItem",MMe="textStyle",TMe=/^(\d+)\.\s$/,W3t=ah.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",Sc(this.options.HTMLAttributes,r),0]:["ol",Sc(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(H3t,this.editor.getAttributes(MMe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=HI({find:TMe,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=HI({find:TMe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(MMe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),G3t=ah.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Sc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),K3t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Z3t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Y3t=ty.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",Sc(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[f3({find:K3t,type:this.type})]},addPasteRules(){return[IN({find:Z3t,type:this.type})]}}),X3t=ah.create({name:"text",group:"inline"}),PVe=Lu.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(a3t.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(e3t.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(o3t.configure(this.options.bulletList)),this.options.code!==!1&&t.push(d3t.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(m3t.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(p3t.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(x3t.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(N3t.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(S3t.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(C3t.configure(this.options.heading)),this.options.history!==!1&&t.push(R3t.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(F3t.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(U3t.configure(this.options.italic)),this.options.listItem!==!1&&t.push(V3t.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(W3t.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(G3t.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(Y3t.configure(this.options.strike)),this.options.text!==!1&&t.push(X3t.configure(this.options.text)),t}}),Q3t="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",J3t="ελ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",axe="numeric",ixe="ascii",oxe="alpha",FP="asciinumeric",bE="alphanumeric",lxe="domain",IVe="emoji",eMt="scheme",tMt="slashscheme",eme="whitespace";function sMt(t,s){return t in s||(s[t]=[]),s[t]}function kk(t,s,r){s[axe]&&(s[FP]=!0,s[bE]=!0),s[ixe]&&(s[FP]=!0,s[oxe]=!0),s[FP]&&(s[bE]=!0),s[oxe]&&(s[bE]=!0),s[bE]&&(s[lxe]=!0),s[IVe]&&(s[lxe]=!0);for(const n in s){const a=sMt(n,r);a.indexOf(t)<0&&a.push(t)}}function rMt(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function fm(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}fm.groups={};fm.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),Tc=(t,s,r,n,a)=>t.tr(s,r,n,a),AMe=(t,s,r,n,a)=>t.ts(s,r,n,a),Hr=(t,s,r,n,a)=>t.tt(s,r,n,a),Hy="WORD",cxe="UWORD",LVe="ASCIINUMERICAL",DVe="ALPHANUMERICAL",WI="LOCALHOST",dxe="TLD",uxe="UTLD",Jse="SCHEME",m4="SLASH_SCHEME",Z_e="NUM",hxe="WS",Y_e="NL",zP="OPENBRACE",BP="CLOSEBRACE",Ane="OPENBRACKET",Ene="CLOSEBRACKET",Pne="OPENPAREN",Ine="CLOSEPAREN",Lne="OPENANGLEBRACKET",Dne="CLOSEANGLEBRACKET",One="FULLWIDTHLEFTPAREN",Rne="FULLWIDTHRIGHTPAREN",Fne="LEFTCORNERBRACKET",zne="RIGHTCORNERBRACKET",Bne="LEFTWHITECORNERBRACKET",$ne="RIGHTWHITECORNERBRACKET",qne="FULLWIDTHLESSTHAN",Une="FULLWIDTHGREATERTHAN",Vne="AMPERSAND",Hne="APOSTROPHE",Wne="ASTERISK",s1="AT",Gne="BACKSLASH",Kne="BACKTICK",Zne="CARET",u1="COLON",X_e="COMMA",Yne="DOLLAR",_x="DOT",Xne="EQUALS",Q_e="EXCLAMATION",Up="HYPHEN",$P="PERCENT",Qne="PIPE",Jne="PLUS",eae="POUND",qP="QUERY",J_e="QUOTE",OVe="FULLWIDTHMIDDLEDOT",ebe="SEMI",bx="SLASH",UP="TILDE",tae="UNDERSCORE",RVe="EMOJI",sae="SYM";var FVe=Object.freeze({__proto__:null,ALPHANUMERICAL:DVe,AMPERSAND:Vne,APOSTROPHE:Hne,ASCIINUMERICAL:LVe,ASTERISK:Wne,AT:s1,BACKSLASH:Gne,BACKTICK:Kne,CARET:Zne,CLOSEANGLEBRACKET:Dne,CLOSEBRACE:BP,CLOSEBRACKET:Ene,CLOSEPAREN:Ine,COLON:u1,COMMA:X_e,DOLLAR:Yne,DOT:_x,EMOJI:RVe,EQUALS:Xne,EXCLAMATION:Q_e,FULLWIDTHGREATERTHAN:Une,FULLWIDTHLEFTPAREN:One,FULLWIDTHLESSTHAN:qne,FULLWIDTHMIDDLEDOT:OVe,FULLWIDTHRIGHTPAREN:Rne,HYPHEN:Up,LEFTCORNERBRACKET:Fne,LEFTWHITECORNERBRACKET:Bne,LOCALHOST:WI,NL:Y_e,NUM:Z_e,OPENANGLEBRACKET:Lne,OPENBRACE:zP,OPENBRACKET:Ane,OPENPAREN:Pne,PERCENT:$P,PIPE:Qne,PLUS:Jne,POUND:eae,QUERY:qP,QUOTE:J_e,RIGHTCORNERBRACKET:zne,RIGHTWHITECORNERBRACKET:$ne,SCHEME:Jse,SEMI:ebe,SLASH:bx,SLASH_SCHEME:m4,SYM:sae,TILDE:UP,TLD:dxe,UNDERSCORE:tae,UTLD:uxe,UWORD:cxe,WORD:Hy,WS:hxe});const By=/[a-z]/,WA=new RegExp("\\p{L}","u"),tme=new RegExp("\\p{Emoji}","u"),$y=/\d/,sme=/\s/,EMe="\r",rme=` `,nMt="️",aMt="‍",nme="";let A8=null,E8=null;function iMt(t=[]){const s={};fm.groups=s;const r=new fm;A8==null&&(A8=PMe(Q3t)),E8==null&&(E8=PMe(J3t)),Hr(r,"'",Hne),Hr(r,"{",zP),Hr(r,"}",BP),Hr(r,"[",Ane),Hr(r,"]",Ene),Hr(r,"(",Pne),Hr(r,")",Ine),Hr(r,"<",Lne),Hr(r,">",Dne),Hr(r,"(",One),Hr(r,")",Rne),Hr(r,"「",Fne),Hr(r,"」",zne),Hr(r,"『",Bne),Hr(r,"』",$ne),Hr(r,"<",qne),Hr(r,">",Une),Hr(r,"&",Vne),Hr(r,"*",Wne),Hr(r,"@",s1),Hr(r,"`",Kne),Hr(r,"^",Zne),Hr(r,":",u1),Hr(r,",",X_e),Hr(r,"$",Yne),Hr(r,".",_x),Hr(r,"=",Xne),Hr(r,"!",Q_e),Hr(r,"-",Up),Hr(r,"%",$P),Hr(r,"|",Qne),Hr(r,"+",Jne),Hr(r,"#",eae),Hr(r,"?",qP),Hr(r,'"',J_e),Hr(r,"/",bx),Hr(r,";",ebe),Hr(r,"~",UP),Hr(r,"_",tae),Hr(r,"\\",Gne),Hr(r,"・",OVe);const n=Tc(r,$y,Z_e,{[axe]:!0});Tc(n,$y,n);const a=Tc(n,By,LVe,{[FP]:!0}),o=Tc(n,WA,DVe,{[bE]:!0}),l=Tc(r,By,Hy,{[ixe]:!0});Tc(l,$y,a),Tc(l,By,l),Tc(a,$y,a),Tc(a,By,a);const i=Tc(r,WA,cxe,{[oxe]:!0});Tc(i,By),Tc(i,$y,o),Tc(i,WA,i),Tc(o,$y,o),Tc(o,By),Tc(o,WA,o);const d=Hr(r,rme,Y_e,{[eme]:!0}),u=Hr(r,EMe,hxe,{[eme]:!0}),f=Tc(r,sme,hxe,{[eme]:!0});Hr(r,nme,f),Hr(u,rme,d),Hr(u,nme,f),Tc(u,sme,f),Hr(f,EMe),Hr(f,rme),Tc(f,sme,f),Hr(f,nme,f);const g=Tc(r,tme,RVe,{[IVe]:!0});Hr(g,"#"),Tc(g,tme,g),Hr(g,nMt,g);const v=Hr(g,aMt);Hr(v,"#"),Tc(v,tme,g);const _=[[By,l],[$y,a]],b=[[By,null],[WA,i],[$y,o]];for(let w=0;ww[0]>j[0]?1:-1);for(let w=0;w=0?S[lxe]=!0:By.test(j)?$y.test(j)?S[FP]=!0:S[ixe]=!0:S[axe]=!0,AMe(r,j,j,S)}return AMe(r,"localhost",WI,{ascii:!0}),r.jd=new fm(sae),{start:r,tokens:Object.assign({groups:s},FVe)}}function zVe(t,s){const r=oMt(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(g+=r[l].length,v++),u+=r[l].length,o+=r[l].length,l++;o-=g,l-=v,u-=g,a.push({t:f.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function oMt(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 qv(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 GI={defaultProtocol:"http",events:null,format:IMe,formatHref:IMe,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function tbe(t,s=null){let r=Object.assign({},GI);t&&(r=Object.assign(r,t instanceof tbe?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=GI.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),d=t.get("target",r,s),u=t.get("rel",r,s),f=t.getObj("attributes",r,s),g=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),d&&(l.target=d),u&&(l.rel=u),f&&Object.assign(l,f),{tagName:a,attributes:l,content:o,eventListeners:g}}};function Qoe(t,s){class r extends BVe{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 LMe=Qoe("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),DMe=Qoe("text"),lMt=Qoe("nl"),P8=Qoe("url",{isLink:!0,toHref(t=GI.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==WI&&t[1].t===u1}}),zp=t=>new fm(t);function cMt({groups:t}){const s=t.domain.concat([Vne,Wne,s1,Gne,Kne,Zne,Yne,Xne,Up,Z_e,$P,Qne,Jne,eae,bx,sae,UP,tae]),r=[Hne,u1,X_e,_x,Q_e,$P,qP,J_e,ebe,Lne,Dne,zP,BP,Ene,Ane,Pne,Ine,One,Rne,Fne,zne,Bne,$ne,qne,Une],n=[Vne,Hne,Wne,Gne,Kne,Zne,Yne,Xne,Up,zP,BP,$P,Qne,Jne,eae,qP,bx,sae,UP,tae],a=zp(),o=Hr(a,UP);$i(o,n,o),$i(o,t.domain,o);const l=zp(),i=zp(),d=zp();$i(a,t.domain,l),$i(a,t.scheme,i),$i(a,t.slashscheme,d),$i(l,n,o),$i(l,t.domain,l);const u=Hr(l,s1);Hr(o,s1,u),Hr(i,s1,u),Hr(d,s1,u);const f=Hr(o,_x);$i(f,n,o),$i(f,t.domain,o);const g=zp();$i(u,t.domain,g),$i(g,t.domain,g);const v=Hr(g,_x);$i(v,t.domain,g);const _=zp(LMe);$i(v,t.tld,_),$i(v,t.utld,_),Hr(u,WI,_);const b=Hr(g,Up);Hr(b,Up,b),$i(b,t.domain,g),$i(_,t.domain,g),Hr(_,_x,v),Hr(_,Up,b);const w=Hr(_,u1);$i(w,t.numeric,LMe);const j=Hr(l,Up),N=Hr(l,_x);Hr(j,Up,j),$i(j,t.domain,l),$i(N,n,o),$i(N,t.domain,l);const S=zp(P8);$i(N,t.tld,S),$i(N,t.utld,S),$i(S,t.domain,l),$i(S,n,o),Hr(S,_x,N),Hr(S,Up,j),Hr(S,s1,u);const A=Hr(S,u1),I=zp(P8);$i(A,t.numeric,I);const L=zp(P8),F=zp();$i(L,s,L),$i(L,r,F),$i(F,s,L),$i(F,r,F),Hr(S,bx,L),Hr(I,bx,L);const $=Hr(i,u1),q=Hr(d,u1),H=Hr(q,bx),U=Hr(H,bx);$i(i,t.domain,l),Hr(i,_x,N),Hr(i,Up,j),$i(d,t.domain,l),Hr(d,_x,N),Hr(d,Up,j),$i($,t.domain,L),Hr($,bx,L),Hr($,qP,L),$i(U,t.domain,L),$i(U,s,L),Hr(U,bx,L);const Q=[[zP,BP],[Ane,Ene],[Pne,Ine],[Lne,Dne],[One,Rne],[Fne,zne],[Bne,$ne],[qne,Une]];for(let se=0;se=0&&v++,a++,f++;if(v<0)a-=f,a0&&(o.push(ame(DMe,s,l)),l=[]),a-=v,f-=v;const _=g.t,b=r.slice(a-f,a);o.push(ame(_,s,b))}}return l.length>0&&o.push(ame(DMe,s,l)),o}function ame(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 uMt=typeof console<"u"&&console&&console.warn||(()=>{}),hMt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ul={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function mMt(){return fm.groups={},Ul.scanner=null,Ul.parser=null,Ul.tokenQueue=[],Ul.pluginQueue=[],Ul.customSchemes=[],Ul.initialized=!1,Ul}function OMe(t,s=!1){if(Ul.initialized&&uMt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${hMt}`),!/^[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`);Ul.customSchemes.push([t,s])}function pMt(){Ul.scanner=iMt(Ul.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=W4t(r.doc,[...s]);if(J4t(i).forEach(({newRange:u})=>{const f=K4t(n.doc,u,_=>_.isTextblock);let g,v;if(f.length>1)g=f[0],v=n.doc.textBetween(g.pos,g.pos+g.node.nodeSize,void 0," ");else if(f.length){const _=n.doc.textBetween(u.from,u.to," "," ");if(!gMt.test(_))return;g=f[0],v=n.doc.textBetween(g.pos,u.to,void 0," ")}if(g&&v){const _=v.split(fMt).filter(Boolean);if(_.length<=0)return!1;const b=_[_.length-1],w=g.pos+v.lastIndexOf(b);if(!b)return!1;const j=sbe(b).map(N=>N.toObject(t.defaultProtocol));if(!yMt(j))return!1;j.filter(N=>N.isLink).map(N=>({...N,from:w+N.start+1,to:w+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=>{V_e(N.from,N.to,n.doc).some(S=>S.mark.type===t.type)||l.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!l.steps.length)return l}})}function _Mt(t){return new qd({key:new nh("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(v=>v.nodeName==="A"))return!1;const d=bVe(s.state,t.type.name),u=n.target,f=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:d.href,g=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:d.target;return u&&f?(window.open(f,g),!0):!1}}})}function bMt(t){return new qd({key:new nh("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 d=$Ve(i,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===i);return!i||!d?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function Bb(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(xMt,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const qVe=ty.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"){OMe(t);return}OMe(t.scheme,t.optionalSlashes)})},onDestroy(){mMt()},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)=>!!Bb(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=>!!Bb(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=>!!Bb(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Sc(this.options.HTMLAttributes,t),0]:["a",Sc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!Bb(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=>!!Bb(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[IN({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=$Ve(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!Bb(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(vMt({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!Bb(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(_Mt({type:this.type})),this.options.linkOnPaste&&t.push(bMt({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),UVe=Lu.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")}}}),wMt=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}`)})},VVe=ty.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&wMt(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Sc(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}}}}),jMt=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,kMt=ah.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",Sc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[wVe({find:jMt,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let mxe,pxe;if(typeof WeakMap<"u"){let t=new WeakMap;mxe=s=>t.get(s),pxe=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;mxe=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var zc=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:f,n:N-A});break}const I=a+A*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 CMt(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 TMt(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 Hg(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 Joe(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=dM(s.$head)||AMt(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function AMt(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 fxe(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function EMt(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function nbe(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function HVe(t,s,r){const n=t.node(-1),a=zc.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 LN(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 WVe(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;af!=r.pos-o);d.unshift(r.pos-o);const u=d.map(f=>{const g=n.nodeAt(f);if(!g)throw new RangeError(`No cell with offset ${f} found`);const v=o+f+1;return new pUe(i.resolve(v),i.resolve(v+g.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(fxe(n)&&fxe(a)&&nbe(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Wy.rowSelection(n,a):o&&this.isColSelection()?Wy.colSelection(n,a):new Wy(n,a)}return $a.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=zc.get(s),n=this.$anchorCell.start(-1),a=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let d=a.top;d0||j>0){let N=b.attrs;if(w>0&&(N=LN(N,0,w)),j>0&&(N=LN(N,N.colspan-j,j)),_.lefta.bottom){const N={...b.attrs,rowspan:Math.min(_.bottom,a.bottom)-Math.max(_.top,a.top)};_.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=zc.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),d=s.node(0);return l.top<=i.top?(l.top>0&&(s=d.resolve(o+a.map[l.left])),i.bottom0&&(r=d.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 Wy&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=zc.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),d=s.node(0);return l.left<=i.left?(l.left>0&&(s=d.resolve(o+a.map[l.top*a.width])),i.right0&&(r=d.resolve(o+a.map[i.top*a.width])),l.right{s.push(Ch.node(n,n+r.nodeSize,{class:"selectedCell"}))}),Oc.create(t.doc,s)}function DMt({$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 OMt({$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 RMt(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Ta&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=Il.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=Il.rowSelection(i,i)}else if(!r){const i=zc.get(n.node),d=n.from+1,u=d+i.map[i.width*i.height-1];o=Il.create(a,d+1,u)}}else n instanceof $a&&DMt(n)?o=$a.create(a,n.from):n instanceof $a&&OMt(n)&&(o=$a.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const FMt=new nh("fix-tables");function KVe(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=zMt(t,a,o,r))};return s?s.doc!=t.doc&&KVe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function zMt(t,s,r,n){const a=zc.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let d=0;d0){let _="cell";f.firstChild&&(_=f.firstChild.type.spec.tableRole);const b=[];for(let j=0;j0?-1:0;PMt(s,n,a+o)&&(o=a==0||a==s.width?null:0);for(let l=0;l0&&a0&&s.map[i-1]==d||a0?-1:0;VMt(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,f=s.width*a;u0&&a0&&g==s.map[f-s.width]){const v=r.nodeAt(g).attrs;t.setNodeMarkup(t.mapping.slice(i).map(g+n),null,{...v,rowspan:v.rowspan-1}),u+=v.colspan-1}else if(a0&&r[o]==r[o-1]||n.right0&&r[a]==r[a-t]||n.bottom0){const f=d+1+u.content.size,g=RMe(u)?d+1:f;o.replaceWith(g+n.tableStart,f+n.tableStart,i)}o.setSelection(new Il(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function zMe(t,s){const r=th(t.schema);return YMt(({node:n})=>r[n.type.spec.tableRole])(t,s)}function YMt(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof Il){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=TMt(n.$from),!a)return!1;o=(l=dM(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 d=[],u=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const f=cy(s),g=s.tr;for(let _=0;_{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 QMt(t){return function(s,r){if(!Hg(s))return!1;if(r){const n=th(s.schema),a=cy(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(d=>a.table.nodeAt(d));for(let d=0;d{const _=v+o.tableStart,b=l.doc.nodeAt(_);b&&l.setNodeMarkup(_,g,b.attrs)}),n(l)}return!0}}KI("row",{useDeprecatedLogic:!0});KI("column",{useDeprecatedLogic:!0});const JMt=KI("cell",{useDeprecatedLogic:!0});function eTt(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 I8(t,s){const r=t.selection;if(!(r instanceof Il))return!1;if(s){const n=t.tr,a=th(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 fn(a,0,0))}),n.docChanged&&s(n)}return!0}function sTt(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 d=0;d=0;l--){const{rowspan:i,colspan:d}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Mr.empty),r[a]n&&(v=v.type.createChecked(LN(v.attrs,v.attrs.colspan,f+v.attrs.colspan-n),v.content)),u.push(v),f+=v.attrs.colspan;for(let _=1;_a&&(g=g.type.create({...g.attrs,rowspan:Math.max(1,a-g.attrs.rowspan)},g.content)),d.push(g)}o.push(Mr.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function aTt(t,s,r,n,a,o,l){const i=t.doc.type.schema,d=th(i);let u,f;if(a>s.width)for(let g=0,v=0;gs.height){const g=[];for(let b=0,w=(s.height-1)*s.width;b=s.width?!1:r.nodeAt(s.map[w+b]).type==d.header_cell;g.push(j?f||(f=d.header_cell.createAndFill()):u||(u=d.cell.createAndFill()))}const v=d.row.create(null,Mr.from(g)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof Il)return ere(r,n,si.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=QVe(a,t,s);if(l==null)return!1;if(t=="horiz")return ere(r,n,si.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=HVe(i,t,s);let u;return d?u=si.near(d,1):s<0?u=si.near(r.doc.resolve(i.before(-1)),-1):u=si.near(r.doc.resolve(i.after(-1)),1),ere(r,n,u)}}}function D8(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof Il)l=o;else{const d=QVe(a,t,s);if(d==null)return!1;l=new Il(r.doc.resolve(d))}const i=HVe(l.$headCell,t,s);return i?ere(r,n,new Il(l.$anchorCell,i)):!1}}function oTt(t,s){const r=t.state.doc,n=dM(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new Il(n))),!0):!1}function lTt(t,s,r){if(!Hg(t.state))return!1;let n=sTt(r);const a=t.state.selection;if(a instanceof Il){n||(n={width:1,height:1,rows:[Mr.from(gxe(th(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=zc.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=nTt(n,i.right-i.left,i.bottom-i.top),VMe(t.state,t.dispatch,l,i,n),!0}else if(n){const o=Joe(t.state),l=o.start(-1);return VMe(t.state,t.dispatch,l,zc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function cTt(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=HMe(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof Il)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=dM(t.state.selection.$anchor))!=null&&((r=ime(t,s))===null||r===void 0?void 0:r.pos)!=a.pos)o(a,s),s.preventDefault();else if(!n)return;function o(d,u){let f=ime(t,u);const g=h1.getState(t.state)==null;if(!f||!nbe(d,f))if(g)f=d;else return;const v=new Il(d,f);if(g||!t.state.selection.eq(v)){const _=t.state.tr.setSelection(v);g&&_.setMeta(h1,d.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),h1.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(h1,-1))}function i(d){const u=d,f=h1.getState(t.state);let g;if(f!=null)g=t.state.doc.resolve(f);else if(HMe(t,u.target)!=n&&(g=ime(t,s),!g))return l();g&&o(g,u)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",i)}function QVe(t,s,r){if(!(t.state.selection instanceof $a))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 HMe(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function ime(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 dM(t.state.doc.resolve(n))}var dTt=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")),xxe(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,xxe(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function xxe(t,s,r,n,a,o){let l=0,i=!0,d=s.firstChild;const u=t.firstChild;if(u){for(let g=0,v=0;gnew n(g,r,v)),new hTt(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=np.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{mTt(l,i,t,a)},mouseleave:l=>{pTt(l)},mousedown:(l,i)=>{fTt(l,i,s,r)}},decorations:l=>{const i=np.getState(l);if(i&&i.activeHandle>-1)return _Tt(l,i.activeHandle)},nodeViews:{}}});return o}var hTt=class tre{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(np);if(n&&n.setHandle!=null)return new tre(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new tre(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return fxe(s.doc.resolve(a))||(a=-1),new tre(a,r.dragging)}return r}};function mTt(t,s,r,n){if(!t.editable)return;const a=np.getState(t.state);if(a&&!a.dragging){const o=xTt(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=WMe(t,s,"left",r):d-s.clientX<=r&&(l=WMe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),d=i.node(-1),u=zc.get(d),f=i.start(-1);if(u.colCount(i.pos-f)+i.nodeAfter.attrs.colspan-1==u.width-1)return}JVe(t,l)}}}function pTt(t){if(!t.editable)return;const s=np.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&JVe(t,-1)}function fTt(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=np.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),d=gTt(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(np,{setDragging:{startX:s.clientX,startWidth:d}}));function u(g){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",f);const v=np.getState(t.state);v!=null&&v.dragging&&(yTt(t,v.activeHandle,GMe(v.dragging,g,r)),t.dispatch(t.state.tr.setMeta(np,{setDragging:null})))}function f(g){if(!g.which)return u(g);const v=np.getState(t.state);if(v&&v.dragging){const _=GMe(v.dragging,g,r);KMe(t,v.activeHandle,_,n)}}return KMe(t,l.activeHandle,d,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",f),s.preventDefault(),!0}function gTt(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 d=0;d{const n=t.nodes[r];n.spec.tableRole&&(s[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=s,s}function NTt(t,s,r,n,a){const o=kTt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!STt(s))return!1;let r=0;const n=_Ve(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},CTt=ah.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:wTt,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}=jTt(t,this.options.cellMinWidth),o=["table",Sc(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=NTt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection($a.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>BMt(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>$Mt(t,s),deleteColumn:()=>({state:t,dispatch:s})=>UMt(t,s),addRowBefore:()=>({state:t,dispatch:s})=>HMt(t,s),addRowAfter:()=>({state:t,dispatch:s})=>WMt(t,s),deleteRow:()=>({state:t,dispatch:s})=>KMt(t,s),deleteTable:()=>({state:t,dispatch:s})=>tTt(t,s),mergeCells:()=>({state:t,dispatch:s})=>FMe(t,s),splitCell:()=>({state:t,dispatch:s})=>zMe(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>KI("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>KI("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>JMt(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>FMe(t,s)?!0:zMe(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>XMt(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>$Me(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>$Me(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&ZVe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=Il.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:O8,"Mod-Backspace":O8,Delete:O8,"Mod-Delete":O8}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[uTt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],bTt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:qi(Qn(t,"tableRole",s))}}}),MTt=ah.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Sc(this.options.HTMLAttributes,t),0]}}),TTt=ah.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",Sc(this.options.HTMLAttributes,t),0]}}),ATt=ah.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",Sc(this.options.HTMLAttributes,t),0]}});function Wg({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=M.useState(!1),[i,d]=M.useState(""),[u,f]=M.useState(!0),g=SVe({extensions:[PVe,qVe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),UVe.configure({types:["heading","paragraph"]}),VVe,kMt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),CTt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),MTt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null}}}}),TTt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),ATt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:w})=>{s(w.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(w,j)=>{var S;const N=(S=j.clipboardData)==null?void 0:S.items;if(!N)return!1;for(const A of Array.from(N))if(A.type.startsWith("image/")){j.preventDefault();const I=A.getAsFile();if(!I)continue;const L=new FileReader;return L.onload=F=>{var q;const $=(q=F.target)==null?void 0:q.result;w.dispatch(w.state.tr.replaceSelectionWith(w.state.schema.nodes.image.create({src:$})))},L.readAsDataURL(I),!0}return!1}}});M.useEffect(()=>{g&&t!==g.getHTML()&&g.commands.setContent(t)},[t,g]);const v=()=>{if(!g)return;const w=g.getAttributes("link").href||"",j=g.getAttributes("link").target;d(w),f(j==="_blank"),l(!0)},_=()=>{g&&(i===""?g.chain().focus().extendMarkRange("link").unsetLink().run():g.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),d(""))},b=()=>{g&&g.chain().focus().extendMarkRange("link").unsetLink().run()};return g?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(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleHeading({level:1}).run(),className:g.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(GE,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleHeading({level:2}).run(),className:g.isActive("heading",{level:2})?"bg-muted":"",title:"Heading 2",children:e.jsx(KE,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleBold().run(),className:g.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(Z4,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleItalic().run(),className:g.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(s5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleBulletList().run(),className:g.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(Fh,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleOrderedList().run(),className:g.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(b0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().setTextAlign("left").run(),className:g.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx(W4,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().setTextAlign("center").run(),className:g.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(H4,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().setTextAlign("right").run(),className:g.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",children:e.jsx(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:v,className:g.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Po,{className:"h-4 w-4"})}),g.isActive("link")&&e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:b,title:"Remove Link",children:e.jsx(Po,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().undo().run(),disabled:!g.can().undo(),title:"Undo",children:e.jsx(m5,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().redo().run(),disabled:!g.can().redo(),title:"Redo",children:e.jsx(u5,{className:"h-4 w-4"})})]}),e.jsx(kVe,{editor:g,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(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"link-url",children:"URL"}),e.jsx(Re,{id:"link-url",value:i,onChange:w=>d(w.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"link-new-tab",checked:u,onCheckedChange:f}),e.jsx(_e,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Z,{type:"button",onClick:_,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var ETt=Object.defineProperty,PTt=(t,s,r)=>s in t?ETt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,ac=(t,s,r)=>PTt(t,typeof s!="symbol"?s+"":s,r);const rae={x:0,y:0,width:0,height:0,unit:"px"},QC=(t,s,r)=>Math.min(Math.max(t,s),r),ITt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),XMe=(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 LTt(t,s,r,n){const a=wx(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==="%"?r1(a,r,n):a}function DTt(t,s,r){const n=wx(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?r1(n,s,r):n}function r1(t,s,r){return t.unit==="%"?{...rae,...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 wx(t,s,r){return t.unit?t.unit==="px"?{...rae,...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}:{...rae,...t,unit:"px"}}function QMe(t,s,r,n,a,o=0,l=0,i=n,d=a){const u={...t};let f=Math.min(o,n),g=Math.min(l,a),v=Math.min(i,n),_=Math.min(d,a);s&&(s>1?(f=l?l*s:f,g=f/s,v=i*s):(g=o?o/s:g,f=g*s,_=d/s)),u.y<0&&(u.height=Math.max(u.height+u.y,g),u.y=0),u.x<0&&(u.width=Math.max(u.width+u.x,f),u.x=0);const b=n-(u.x+u.width);b<0&&(u.x=Math.min(u.x,n-f),u.width+=b);const w=a-(u.y+u.height);if(w<0&&(u.y=Math.min(u.y,a-g),u.height+=w),u.widthv&&((r==="sw"||r=="nw")&&(u.x-=v-u.width),u.width=v),u.height>_&&((r==="nw"||r=="ne")&&(u.y-=_-u.height),u.height=_),s){const j=u.width/u.height;if(js){const N=Math.max(u.height*s,f);(r==="sw"||r=="nw")&&(u.x-=N-u.width),u.width=N}}return u}function OTt(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 JC={capture:!0,passive:!1};let RTt=0;const Wv=class ag extends M.PureComponent{constructor(){super(...arguments),ac(this,"docMoveBound",!1),ac(this,"mouseDownOnCrop",!1),ac(this,"dragStarted",!1),ac(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),ac(this,"componentRef",M.createRef()),ac(this,"mediaRef",M.createRef()),ac(this,"resizeObserver"),ac(this,"initChangeCalled",!1),ac(this,"instanceId",`rc-${RTt++}`),ac(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),ac(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=wx(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 d=s.clientX,u=s.clientY,f=o.x,g=o.y;if(l){const v=s.clientX-a.x,_=s.clientY-a.y;let b=0,w=0;l==="ne"||l=="e"?(b=v-(o.x+o.width),w=_-o.y,f=o.x,g=o.y+o.height):l==="se"||l==="s"?(b=v-(o.x+o.width),w=_-(o.y+o.height),f=o.x,g=o.y):l==="sw"||l=="w"?(b=v-o.x,w=_-(o.y+o.height),f=o.x+o.width,g=o.y):(l==="nw"||l=="n")&&(b=v-o.x,w=_-o.y,f=o.x+o.width,g=o.y+o.height),d=f+a.x+b,u=g+a.y+w}this.evData={startClientX:d,startClientY:u,startCropX:f,startCropY:g,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),ac(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 d=s.clientX-i.x,u=s.clientY-i.y,f={unit:"px",x:d,y:u,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:d,startCropY:u,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(wx(f,i.width,i.height),r1(f,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),ac(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 d;i.isResize?d=this.resizeCrop():d=this.dragCrop(),XMe(r,d)||a(wx(d,l.width,l.height),r1(d,l.width,l.height))}),ac(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 d=this.getBox(),u=this.makePixelCrop(d),f=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?ag.nudgeStepLarge:s.shiftKey?ag.nudgeStepMedium:ag.nudgeStep;if(l==="ArrowLeft"?(u.x-=f,i=!0):l==="ArrowRight"?(u.x+=f,i=!0):l==="ArrowUp"?(u.y-=f,i=!0):l==="ArrowDown"&&(u.y+=f,i=!0),i){s.cancelable&&s.preventDefault(),u.x=QC(u.x,0,d.width-u.width),u.y=QC(u.y,0,d.height-u.height);const g=wx(u,d.width,d.height),v=r1(u,d.width,d.height);a(g,v),o&&o(g,v)}}),ac(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:d,maxHeight:u,onChange:f,onComplete:g}=this.props,v=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 _=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?ag.nudgeStepLarge:s.shiftKey?ag.nudgeStepMedium:ag.nudgeStep,b=wx(a,v.width,v.height),w=OTt(b,s.key,_,r),j=QMe(w,n,r,v.width,v.height,l,i,d,u);if(!XMe(a,j)){const N=r1(j,v.width,v.height);f(j,N),g&&g(j,N)}}),ac(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(wx(r,l.width,l.height),r1(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),ac(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(wx(r,a,o),r1(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,JC),this.document.addEventListener("pointerup",this.onDocPointerDone,JC),this.document.addEventListener("pointercancel",this.onDocPointerDone,JC),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,JC),this.document.removeEventListener("pointerup",this.onDocPointerDone,JC),this.document.removeEventListener("pointercancel",this.onDocPointerDone,JC),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=QC(s.startCropX+a,0,r.width-n.width),n.y=QC(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 d;a&&r?d=r==="nw"||r==="n"||r==="ne":d=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 d=this.makePixelCrop(o);const u=this.getPointRegion(o,s.ord,l,i),f=s.ord||u;let g=s.clientX-s.startClientX,v=s.clientY-s.startClientY;(l&&f==="nw"||f==="w"||f==="sw")&&(g=Math.min(g,-l)),(i&&f==="nw"||f==="n"||f==="ne")&&(v=Math.min(v,-i));const _={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(_.x=s.startCropX,_.width=g,r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(v),_.y=s.startCropY-_.height)):u==="se"?(_.x=s.startCropX,_.y=s.startCropY,_.width=g,r?_.height=_.width/r:_.height=v):u==="sw"?(_.x=s.startCropX+g,_.y=s.startCropY,_.width=Math.abs(g),r?_.height=_.width/r:_.height=v):u==="nw"&&(_.x=s.startCropX+g,_.width=Math.abs(g),r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(v),_.y=s.startCropY+v));const b=QMe(_,r,u,o.width,o.height,l,i,n,a);return r||ag.xyOrds.indexOf(f)>-1?d=b:ag.xOrds.indexOf(f)>-1?(d.x=b.x,d.width=b.width):ag.yOrds.indexOf(f)>-1&&(d.y=b.y,d.height=b.height),d.x=QC(d.x,0,o.width-d.width),d.y=QC(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:s=ag.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return ut.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&ut.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},ut.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),ut.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),ut.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),ut.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),ut.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":s.nwDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"nw"),role:"button"}),ut.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":s.nDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"n"),role:"button"}),ut.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":s.neDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"ne"),role:"button"}),ut.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":s.eDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"e"),role:"button"}),ut.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":s.seDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"se"),role:"button"}),ut.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":s.sDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"s"),role:"button"}),ut.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":s.swDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"sw"),role:"button"}),ut.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":s.wDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"w"),role:"button"})),a&&ut.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:d=>d.stopPropagation()},a(this.state)),o&&ut.createElement(ut.Fragment,null,ut.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),ut.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...rae,...this.props.crop||{}};return wx(r,s.width,s.height)}render(){const{aspect:s,children:r,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:d,ruleOfThirds:u}=this.props,{cropIsActive:f,newCropIsBeingDrawn:g}=this.state,v=o?this.renderCropSelection():null,_=ITt("ReactCrop",a,f&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",g&&"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 ut.createElement("div",{ref:this.componentRef,className:_,style:d},ut.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?ut.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},ut.createElement("defs",null,ut.createElement("mask",{id:`hole-${this.instanceId}`},ut.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?ut.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"}):ut.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),ut.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,v)}};ac(Wv,"xOrds",["e","w"]),ac(Wv,"yOrds",["n","s"]),ac(Wv,"xyOrds",["nw","ne","se","sw"]),ac(Wv,"nudgeStep",1),ac(Wv,"nudgeStepMedium",10),ac(Wv,"nudgeStepLarge",100),ac(Wv,"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 FTt=Wv;var eHe=["PageUp","PageDown"],tHe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],sHe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},uM="Slider",[vxe,zTt,BTt]=W6(uM),[rHe]=Cc(uM,[BTt]),[$Tt,ele]=rHe(uM),nHe=M.forwardRef((t,s)=>{const{name:r,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:f,onValueChange:g=()=>{},onValueCommit:v=()=>{},inverted:_=!1,form:b,...w}=t,j=M.useRef(new Set),N=M.useRef(0),A=l==="horizontal"?qTt:UTt,[I=[],L]=uu({prop:f,defaultProp:u,onChange:Q=>{var te;(te=[...j.current][N.current])==null||te.focus(),g(Q)}}),F=M.useRef(I);function $(Q){const se=KTt(I,Q);U(Q,se)}function q(Q){U(Q,N.current)}function H(){const Q=F.current[N.current];I[N.current]!==Q&&v(I)}function U(Q,se,{commit:te}={commit:!1}){const Y=QTt(o),ce=JTt(Math.round((Q-n)/o)*o+n,Y),oe=PI(ce,[n,a]);L((le=[])=>{const de=WTt(le,oe,se);if(XTt(de,d*o)){N.current=de.indexOf(oe);const xe=String(de)!==String(le);return xe&&te&&v(de),xe?de:le}else return le})}return e.jsx($Tt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:N,thumbs:j.current,values:I,orientation:l,form:b,children:e.jsx(vxe.Provider,{scope:t.__scopeSlider,children:e.jsx(vxe.Slot,{scope:t.__scopeSlider,children:e.jsx(A,{"aria-disabled":i,"data-disabled":i?"":void 0,...w,ref:s,onPointerDown:Sr(w.onPointerDown,()=>{i||(F.current=I)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:$,onSlideMove:i?void 0:q,onSlideEnd:i?void 0:H,onHomeKeyDown:()=>!i&&U(n,0,{commit:!0}),onEndKeyDown:()=>!i&&U(a,I.length-1,{commit:!0}),onStepKeyDown:({event:Q,direction:se})=>{if(!i){const ce=eHe.includes(Q.key)||Q.shiftKey&&tHe.includes(Q.key)?10:1,oe=N.current,le=I[oe],de=o*ce*se;U(le+de,oe,{commit:!0})}}})})})})});nHe.displayName=uM;var[aHe,iHe]=rHe(uM,{startEdge:"left",endEdge:"right",size:"width",direction:1}),qTt=M.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:u,...f}=t,[g,v]=M.useState(null),_=Sa(s,A=>v(A)),b=M.useRef(void 0),w=E_(a),j=w==="ltr",N=j&&!o||!j&&o;function S(A){const I=b.current||g.getBoundingClientRect(),L=[0,I.width],$=abe(L,N?[r,n]:[n,r]);return b.current=I,$(A-I.left)}return e.jsx(aHe,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:e.jsx(oHe,{dir:w,"data-orientation":"horizontal",...f,ref:_,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const I=S(A.clientX);l==null||l(I)},onSlideMove:A=>{const I=S(A.clientX);i==null||i(I)},onSlideEnd:()=>{b.current=void 0,d==null||d()},onStepKeyDown:A=>{const L=sHe[N?"from-left":"from-right"].includes(A.key);u==null||u({event:A,direction:L?-1:1})}})})}),UTt=M.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...u}=t,f=M.useRef(null),g=Sa(s,f),v=M.useRef(void 0),_=!a;function b(w){const j=v.current||f.current.getBoundingClientRect(),N=[0,j.height],A=abe(N,_?[n,r]:[r,n]);return v.current=j,A(w-j.top)}return e.jsx(aHe,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(oHe,{"data-orientation":"vertical",...u,ref:g,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const j=b(w.clientY);o==null||o(j)},onSlideMove:w=>{const j=b(w.clientY);l==null||l(j)},onSlideEnd:()=>{v.current=void 0,i==null||i()},onStepKeyDown:w=>{const N=sHe[_?"from-bottom":"from-top"].includes(w.key);d==null||d({event:w,direction:N?-1:1})}})})}),oHe=M.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...u}=t,f=ele(uM,r);return e.jsx(Qr.span,{...u,ref:s,onKeyDown:Sr(t.onKeyDown,g=>{g.key==="Home"?(l(g),g.preventDefault()):g.key==="End"?(i(g),g.preventDefault()):eHe.concat(tHe).includes(g.key)&&(d(g),g.preventDefault())}),onPointerDown:Sr(t.onPointerDown,g=>{const v=g.target;v.setPointerCapture(g.pointerId),g.preventDefault(),f.thumbs.has(v)?v.focus():n(g)}),onPointerMove:Sr(t.onPointerMove,g=>{g.target.hasPointerCapture(g.pointerId)&&a(g)}),onPointerUp:Sr(t.onPointerUp,g=>{const v=g.target;v.hasPointerCapture(g.pointerId)&&(v.releasePointerCapture(g.pointerId),o(g))})})}),lHe="SliderTrack",cHe=M.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=ele(lHe,r);return e.jsx(Qr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});cHe.displayName=lHe;var _xe="SliderRange",dHe=M.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=ele(_xe,r),o=iHe(_xe,r),l=M.useRef(null),i=Sa(s,l),d=a.values.length,u=a.values.map(v=>mHe(v,a.min,a.max)),f=d>1?Math.min(...u):0,g=100-Math.max(...u);return e.jsx(Qr.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:f+"%",[o.endEdge]:g+"%"}})});dHe.displayName=_xe;var bxe="SliderThumb",uHe=M.forwardRef((t,s)=>{const r=zTt(t.__scopeSlider),[n,a]=M.useState(null),o=Sa(s,i=>a(i)),l=M.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(VTt,{...t,ref:o,index:l})}),VTt=M.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=ele(bxe,r),i=iHe(bxe,r),[d,u]=M.useState(null),f=Sa(s,S=>u(S)),g=d?l.form||!!d.closest("form"):!0,v=Z6(d),_=l.values[n],b=_===void 0?0:mHe(_,l.min,l.max),w=GTt(n,l.values.length),j=v==null?void 0:v[i.size],N=j?ZTt(j,b,i.direction):0;return M.useEffect(()=>{if(d)return l.thumbs.add(d),()=>{l.thumbs.delete(d)}},[d,l.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${b}% + ${N}px)`},children:[e.jsx(vxe.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(Qr.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":l.min,"aria-valuenow":_,"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:f,style:_===void 0?{display:"none"}:t.style,onFocus:Sr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),g&&e.jsx(hHe,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});uHe.displayName=bxe;var HTt="RadioBubbleInput",hHe=M.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=M.useRef(null),o=Sa(a,n),l=lL(s);return M.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&f){const g=new Event("input",{bubbles:!0});f.call(i,s),i.dispatchEvent(g)}},[l,s]),e.jsx(Qr.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});hHe.displayName=HTt;function WTt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function mHe(t,s,r){const o=100/(r-s)*(t-s);return PI(o,[0,100])}function GTt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function KTt(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 ZTt(t,s,r){const n=t/2,o=abe([0,50],[0,n]);return(n-o(s)*r)*r}function YTt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function XTt(t,s){if(s>0){const r=YTt(t);return Math.min(...r)>=s}return!0}function abe(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 QTt(t){return(String(t).split(".")[1]||"").length}function JTt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var pHe=nHe,eAt=cHe,tAt=dHe,sAt=uHe;const kg=M.forwardRef(({className:t,...s},r)=>e.jsxs(pHe,{ref:r,className:It("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(eAt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(tAt,{className:"absolute h-full bg-primary"})}),e.jsx(sAt,{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"})]}));kg.displayName=pHe.displayName;function rAt(t,s,r){return DTt(LTt({unit:"%",width:90},r,t,s),t,s)}const ibe=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=M.useRef(null),[l,i]=M.useState(),[d,u]=M.useState(),[f,g]=M.useState(1),[v,_]=M.useState(0),b=M.useCallback(N=>{const{width:S,height:A}=N.currentTarget;i(rAt(S,A,a))},[a]),w=M.useCallback(async()=>{const N=o.current;if(!N||!d)return;const S=document.createElement("canvas"),A=S.getContext("2d");if(!A)return;const I=N.naturalWidth/N.width,L=N.naturalHeight/N.height,F=400;S.width=F,S.height=F,A.imageSmoothingQuality="high";const $=d.x*I,q=d.y*L,H=d.width*I,U=d.height*L,Q=v*Math.PI/180,se=S.width/2,te=S.height/2;return A.save(),A.translate(se,te),A.rotate(Q),A.scale(f,f),A.translate(-se,-te),A.drawImage(N,$,q,H,U,0,0,F,F),A.restore(),new Promise((Y,ce)=>{S.toBlob(oe=>{oe?Y(oe):ce(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,f,v]),j=async()=>{try{const N=await w();N&&(n(N),s())}catch(N){console.error("Error cropping image:",N)}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(FTt,{crop:l,onChange:(N,S)=>i(S),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(${f}) rotate(${v}deg)`,maxHeight:"400px",width:"auto"},onLoad:b})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(f5,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(kg,{value:[f],min:.5,max:3,step:.1,onValueChange:([N])=>g(N),className:"flex-1"}),e.jsx(p5,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(uP,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(kg,{value:[v],min:-180,max:180,step:1,onValueChange:([N])=>_(N),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[v,"°"]})]})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(Z,{onClick:j,children:"Save Photo"})]})]})})},nAt=()=>{const{user:t}=Qs(),{toast:s}=La(),[r,n]=M.useState(!1),[a,o]=M.useState(!1),[l,i]=M.useState(null);M.useEffect(()=>{t&&d()},[t]);const d=async()=>{n(!0);try{const{data:g}=await K.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();g&&i({status:g.subscription_status||"none",productId:g.subscription_product_id,endDate:g.subscription_end_date,isGrandfathered:g.is_grandfathered||!1})}catch(g){console.error("Error loading subscription:",g)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:g}}=await K.auth.getSession();if(!g)throw new Error("Not authenticated");const{data:v,error:_}=await K.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${g.access_token}`}});if(_)throw _;v!=null&&v.url&&window.open(v.url,"_blank")}catch(g){console.error("Error opening customer portal:",g),s({title:"Error",description:g.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},f=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(nt,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(nt,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(nt,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(nt,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(nt,{variant:"secondary",children:"Canceled"});default:return e.jsx(nt,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(cp,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(cp,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(_r,{children:"Manage your subscription and billing"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:f()})]}),(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(Z,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(un,{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."})]})]})},aAt=()=>{const{user:t}=Qs(),s=Or(),{toast:r}=La(),[n]=Gc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:u,unsubscribe:f}=F$e(),[g,v]=M.useState(!1),[_,b]=M.useState(""),[w,j]=M.useState(!1),[N,S]=M.useState(!1),[A,I]=M.useState(""),[L,F]=M.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[$,q]=M.useState(!1),[H,U]=M.useState(!1),[Q,se]=M.useState({newPassword:"",confirmPassword:""});M.useEffect(()=>{t&&te()},[t]),M.useEffect(()=>{o&&t&&setTimeout(()=>{var de;(de=document.getElementById("change-password-section"))==null||de.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const te=async()=>{var de,xe,be;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:ye,error:ve}=await K.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(ve)throw console.error("Profile query error:",ve),ve;ye?(console.log("Profile loaded successfully:",ye),F({name:ye.name||"",email:ye.email||"",title:ye.title||"",bio:ye.bio||"",areas_served:ye.areas_served||"",years_experience:((de=ye.years_experience)==null?void 0:de.toString())||"",instagram_url:ye.instagram_url||"",facebook_url:ye.facebook_url||"",linkedin_url:ye.linkedin_url||"",email_signature:ye.email_signature||"",use_email_signature:ye.use_email_signature||!1}),q(ye.digest_opt_out||!1)):(console.warn("No profile found for user"),F({name:((xe=t.user_metadata)==null?void 0:xe.name)||((be=t.email)==null?void 0:be.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:ke}=await K.storage.from("avatars").list(`${t.id}`);if(ke&&ke.length>0){const{data:Ge}=K.storage.from("avatars").getPublicUrl(`${t.id}/${ke[0].name}`);b(Ge.publicUrl)}}catch(ye){console.error("Error loading profile:",ye),r({title:"Error",description:ye.message||"Failed to load profile",variant:"destructive"})}},Y=de=>{var ye;const xe=(ye=de.target.files)==null?void 0:ye[0];if(!xe)return;const be=new FileReader;be.onloadend=()=>{I(be.result),S(!0)},be.readAsDataURL(xe),de.target.value=""},ce=async de=>{if(t){j(!0);try{const{data:xe}=await K.storage.from("avatars").list(`${t.id}`);xe&&xe.length>0&&await K.storage.from("avatars").remove(xe.map(Ge=>`${t.id}/${Ge.name}`));const ye=`${t.id}/avatar.jpg`,{error:ve}=await K.storage.from("avatars").upload(ye,de,{upsert:!0,contentType:"image/jpeg"});if(ve)throw ve;const{data:ke}=K.storage.from("avatars").getPublicUrl(ye);b(`${ke.publicUrl}?t=${Date.now()}`),r({title:"Success",description:"Profile photo updated successfully"})}catch(xe){console.error("Error uploading avatar:",xe),r({title:"Error",description:xe.message||"Failed to upload photo",variant:"destructive"})}finally{j(!1)}}},oe=async()=>{if(!L.name.trim()||!L.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}v(!0);try{const{error:de}=await K.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(de)throw de;r({title:"Success",description:"Profile updated successfully"})}catch(de){console.error("Error updating profile:",de),r({title:"Error",description:de.message||"Failed to update profile",variant:"destructive"})}finally{v(!1)}},le=async()=>{if(!Q.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(Q.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(Q.newPassword!==Q.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}v(!0);try{const{error:de}=await K.auth.updateUser({password:Q.newPassword});if(de)throw de;r({title:"Success",description:"Password updated successfully"}),se({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(de){console.error("Error updating password:",de),r({title:"Error",description:de.message||"Failed to update password",variant:"destructive"})}finally{v(!1)}};return e.jsx(Ms,{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(Z,{variant:"outline",onClick:()=>{var de;(de=document.getElementById("change-password-section"))==null||de.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(Kk,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Profile Photo"}),e.jsx(_r,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Oe,{className:"flex items-center gap-6",children:[e.jsxs(mn,{className:"h-24 w-24",children:[e.jsx(ba,{src:_}),e.jsx(pn,{className:"text-2xl",children:L.name.split(" ").map(de=>de[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:Y,disabled:w}),e.jsxs(Z,{variant:"outline",onClick:()=>{var de;return(de=document.getElementById("avatar-upload"))==null?void 0:de.click()},disabled:w,children:[e.jsx(xi,{className:"mr-2 h-4 w-4"}),w?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Personal Information"}),e.jsx(_r,{children:"Update your profile details"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:L.name,onChange:de=>F({...L,name:de.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:L.email,onChange:de=>F({...L,email:de.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Job Title"}),e.jsx(Re,{id:"title",value:L.title,onChange:de=>F({...L,title:de.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"bio",children:"Bio"}),e.jsx(Lr,{id:"bio",value:L.bio,onChange:de=>F({...L,bio:de.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(_e,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(Re,{id:"areas_served",value:L.areas_served,onChange:de=>F({...L,areas_served:de.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(Re,{id:"years_experience",type:"number",min:"0",value:L.years_experience,onChange:de=>F({...L,years_experience:de.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(Re,{value:L.linkedin_url,onChange:de=>F({...L,linkedin_url:de.target.value}),placeholder:"LinkedIn URL"}),e.jsx(Re,{value:L.instagram_url,onChange:de=>F({...L,instagram_url:de.target.value}),placeholder:"Instagram URL"}),e.jsx(Re,{value:L.facebook_url,onChange:de=>F({...L,facebook_url:de.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(Z,{onClick:oe,disabled:g,children:[e.jsx(zh,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Xv,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(_r,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Use email signature in all emails"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:L.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(qr,{checked:L.use_email_signature,onCheckedChange:de=>F({...L,use_email_signature:de})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Signature"}),e.jsx(Wg,{content:L.email_signature,onChange:de=>F({...L,email_signature:de}),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(Z,{onClick:oe,disabled:g,children:[e.jsx(zh,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(De,{id:"change-password-section",children:[e.jsxs($t,{children:[e.jsx(Vt,{children:a?"Set Your Password":"Change Password"}),e.jsx(_r,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"newPassword",children:"New Password"}),e.jsx(Re,{id:"newPassword",type:"password",value:Q.newPassword,onChange:de=>se({...Q,newPassword:de.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(Re,{id:"confirmPassword",type:"password",value:Q.confirmPassword,onChange:de=>se({...Q,confirmPassword:de.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(Z,{onClick:le,disabled:g,children:[e.jsx(zh,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(Z,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[i?e.jsx(af,{className:"h-5 w-5"}):e.jsx(U1,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(_r,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Oe,{children:l?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i?"Notifications enabled":"Notifications disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"You'll receive notifications about new templates, videos, and events":"Enable to get notified about new content"})]}),e.jsx(qr,{checked:i,onCheckedChange:de=>{de?u():f()},disabled:d})]}):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(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[$?e.jsx(XE,{className:"h-5 w-5"}):e.jsx(Ar,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(_r,{children:"Manage your email subscription settings"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(qr,{checked:!$,onCheckedChange:async de=>{U(!0);try{const{error:xe}=await K.from("profiles").update({digest_opt_out:!de}).eq("id",t==null?void 0:t.id);if(xe)throw xe;q(!de),r({title:de?"Subscribed":"Unsubscribed",description:de?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(xe){r({title:"Error",description:xe.message||"Failed to update preference",variant:"destructive"})}finally{U(!1)}},disabled:H})]})})]}),e.jsx(Okt,{}),e.jsx(nAt,{})]}),e.jsx(ibe,{open:N,onClose:()=>S(!1),imageSrc:A,onCropComplete:ce,aspectRatio:1})]})})};var iAt="AspectRatio",fHe=M.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(Qr.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});fHe.displayName=iAt;var oAt=fHe;const lAt=oAt;function cAt(){const{user:t}=Qs(),s=ds(),[r,n]=M.useState(!1),[a,o]=M.useState(!1),{data:l,isLoading:i}=Tt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:b,error:w}=await K.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(w)throw w;return b},enabled:!!t&&a}),d=Bt({mutationFn:async()=>{const b=new Uint8Array(12);crypto.getRandomValues(b);const w=btoa(String.fromCharCode(...b)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:j}=await K.from("profiles").update({calendar_token:w}).eq("id",t==null?void 0:t.id);if(j)throw j;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),ge.success("Calendar subscription URL generated!")},onError:b=>{ge.error("Failed to generate calendar URL: "+b.message)}}),u=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,f=async()=>{u&&(await navigator.clipboard.writeText(u),n(!0),ge.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},g=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},v=()=>{if(u){const b=u.replace("https://","webcal://"),w=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(b)}`;window.open(w,"_blank")}},_=()=>{if(u){const b=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(u)}&name=Level%20Up%20Events`;window.open(b,"_blank")}};return e.jsxs(bs,{open:a,onOpenChange:o,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:"gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Kr,{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(Rs,{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(Re,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(Z,{variant:"outline",size:"icon",onClick:f,children:r?e.jsx(ma,{className:"h-4 w-4 text-green-500"}):e.jsx(Ni,{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(Z,{variant:"outline",className:"w-full justify-start gap-2",onClick:g,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(un,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(Z,{variant:"outline",className:"w-full justify-start gap-2",onClick:v,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(un,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(Z,{variant:"outline",className:"w-full justify-start gap-2",onClick:_,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(un,{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(Z,{onClick:()=>d.mutate(),disabled:d.isPending,className:"w-full",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var tle="Tabs",[dAt]=Cc(tle,[P_]),gHe=P_(),[uAt,obe]=dAt(tle),xHe=M.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...u}=t,f=E_(i),[g,v]=uu({prop:n,onChange:a,defaultProp:o??"",caller:tle});return e.jsx(uAt,{scope:r,baseId:Bd(),value:g,onValueChange:v,orientation:l,dir:f,activationMode:d,children:e.jsx(Qr.div,{dir:f,"data-orientation":l,...u,ref:s})})});xHe.displayName=tle;var yHe="TabsList",vHe=M.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=obe(yHe,r),l=gHe(r);return e.jsx(Qie,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(Qr.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});vHe.displayName=yHe;var _He="TabsTrigger",bHe=M.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=obe(_He,r),i=gHe(r),d=kHe(l.baseId,n),u=NHe(l.baseId,n),f=n===l.value;return e.jsx(Jie,{asChild:!0,...i,focusable:!a,active:f,children:e.jsx(Qr.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":u,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:s,onMouseDown:Sr(t.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?l.onValueChange(n):g.preventDefault()}),onKeyDown:Sr(t.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&l.onValueChange(n)}),onFocus:Sr(t.onFocus,()=>{const g=l.activationMode!=="manual";!f&&!a&&g&&l.onValueChange(n)})})})});bHe.displayName=_He;var wHe="TabsContent",jHe=M.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=obe(wHe,r),d=kHe(i.baseId,n),u=NHe(i.baseId,n),f=n===i.value,g=M.useRef(f);return M.useEffect(()=>{const v=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(v)},[]),e.jsx(od,{present:a||f,children:({present:v})=>e.jsx(Qr.div,{"data-state":f?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":d,hidden:!v,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:g.current?"0s":void 0},children:v&&o})})});jHe.displayName=wHe;function kHe(t,s){return`${t}-trigger-${s}`}function NHe(t,s){return`${t}-content-${s}`}var hAt=xHe,SHe=vHe,CHe=bHe,MHe=jHe;const Ia=hAt,Aa=M.forwardRef(({className:t,...s},r)=>e.jsx(SHe,{ref:r,className:It("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));Aa.displayName=SHe.displayName;const Ts=M.forwardRef(({className:t,...s},r)=>e.jsx(CHe,{ref:r,className:It("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...s}));Ts.displayName=CHe.displayName;const Vs=M.forwardRef(({className:t,...s},r)=>e.jsx(MHe,{ref:r,className:It("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));Vs.displayName=MHe.displayName;const mAt={first_timer:Gn,regular:w0,dedicated:dc,veteran:so,streak_master:dp,century:so},pAt={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 JMe(t){return t===1?e.jsx(so,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(w0,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(dc,{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 THe({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Qs(),{data:o,isLoading:l}=lqe(s?5:10,r),{data:i}=cqe(a==null?void 0:a.id),{data:d}=uqe(a==null?void 0:a.id),{data:u}=dqe(a==null?void 0:a.id);return l?e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((f,g)=>e.jsx(gs,{className:"h-12 w-full"},g))})})]}):e.jsxs(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Oe,{children:[t&&i&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),d&&e.jsxs(nt,{variant:"secondary",className:"text-xs",children:["Rank #",d]})]}),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(dp,{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(f=>{const g=mAt[f.badge_type]||Gn;return e.jsxs(nt,{variant:"outline",className:`text-xs ${pAt[f.badge_type]||""}`,title:f.badge_description||"",children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),f.badge_name]},f.id)}),u.length>4&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(Ia,{defaultValue:"points",className:"w-full",children:[e.jsxs(Aa,{className:"w-full mb-3",children:[e.jsx(Ts,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(Ts,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(Vs,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((f,g)=>{var v,_,b;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${f.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${g===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:JMe(g+1)}),e.jsx(mn,{className:"h-8 w-8",children:e.jsx(pn,{className:"text-xs",children:((_=(v=f.profile)==null?void 0:v.name)==null?void 0:_.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((b=f.profile)==null?void 0:b.name)||"Unknown",f.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:[f.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:f.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},f.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(Vs,{value:"events",className:"mt-0",children:e.jsx("div",{className:"space-y-2",children:[...o||[]].sort((f,g)=>g.total_events_attended-f.total_events_attended).map((f,g)=>{var v,_,b;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${f.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${g===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:JMe(g+1)}),e.jsx(mn,{className:"h-8 w-8",children:e.jsx(pn,{className:"text-xs",children:((_=(v=f.profile)==null?void 0:v.name)==null?void 0:_.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((b=f.profile)==null?void 0:b.name)||"Unknown",f.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:[f.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:f.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},f.user_id)})})})]})]})]})}function fAt(){const t=Or(),{user:s,isAdmin:r}=Qs(),n=ds(),{data:a,isLoading:o}=Tt({queryKey:["public-events"],queryFn:async()=>{const{data:w,error:j}=await K.from("events").select("*").order("event_date",{ascending:!0});if(j)throw j;return w}}),{data:l}=Tt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:w,error:j}=await K.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(j)throw j;return w},enabled:!!s}),{data:i}=Tt({queryKey:["event-registration-counts"],queryFn:async()=>{const{data:w,error:j}=await K.from("event_registrations").select("event_id");if(j)throw j;const N={};return w.forEach(S=>{N[S.event_id]=(N[S.event_id]||0)+1}),N}}),d=Bt({mutationFn:async w=>{const{data:j,error:N}=await K.functions.invoke("zoom-register",{body:{event_id:w}});if(N)throw N;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:w=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),w!=null&&w.join_url?ge.success("Successfully registered! You'll receive a Zoom confirmation email."):ge.success("Successfully registered for the event!")},onError:w=>{ge.error("Failed to register: "+w.message)}}),u=Bt({mutationFn:async w=>{const{data:j,error:N}=await K.functions.invoke("zoom-unregister",{body:{event_id:w}});if(N)throw N;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),ge.success("Registration cancelled and removed from Zoom")},onError:w=>{ge.error("Failed to cancel: "+w.message)}}),f=w=>l==null?void 0:l.some(j=>j.event_id===w),g=w=>{const j=l==null?void 0:l.find(N=>N.event_id===w);return j==null?void 0:j.zoom_join_url},v=w=>w.capacity?((i==null?void 0:i[w.id])||0)>=w.capacity:!1,_=(a==null?void 0:a.filter(w=>j5(w.event_date)!=="ended"))||[],b=(a==null?void 0:a.filter(w=>j5(w.event_date)==="ended"))||[];return e.jsx(Ms,{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(cAt,{}),r&&e.jsx(Z,{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..."}):_.length===0?e.jsx(De,{className:"text-center py-12",children:e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:_.map(w=>{const j=j5(w.event_date),N=h_e(w.event_date),S=j==="live",A=j==="starting_soon";return e.jsxs(De,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${S?"border-red-500 ring-2 ring-red-500/20":A?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${w.id}`),children:[N&&e.jsxs("div",{className:`${S?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),S?e.jsxs(e.Fragment,{children:[e.jsx(tN,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),w.image_url&&e.jsx(lAt,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:w.image_url,alt:w.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs($t,{children:[e.jsx(Vt,{className:"line-clamp-2",children:w.title}),w.description&&e.jsx(_r,{className:"line-clamp-2",children:w.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Oe,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(nn,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Tn,{className:"h-4 w-4"}),DI(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(xr,{className:"h-4 w-4"}),(i==null?void 0:i[w.id])||0," registered",w.capacity&&` / ${w.capacity} spots`]})]}),e.jsx(CP,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:f(w.id)?e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(w.id),disabled:u.isPending,children:[e.jsx(Vr,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(Z,{className:"flex-1",onClick:()=>window.open(g(w.id)||w.zoom_link,"_blank"),children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(Z,{className:"w-full",onClick:()=>d.mutate(w.id),disabled:d.isPending||v(w),children:v(w)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},w.id)})}),b.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:b.map(w=>e.jsx(De,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${w.id}`),children:e.jsxs($t,{children:[e.jsx(Vt,{className:"text-base line-clamp-1",children:w.title}),e.jsx(_r,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))})]})},w.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(THe,{showUserStats:!0})})]})]})})}const ome=[{value:"all",label:"All Roles",icon:xr},{value:"brokerage_manager",label:"Brokerage Managers",icon:_P},{value:"admin",label:"Admins",icon:Xu}];function gAt({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Ve,dt;const{user:o,isAdmin:l,isBrokerageManager:i}=Qs(),[d,u]=M.useState([]),[f,g]=M.useState([]),[v,_]=M.useState([]),[b,w]=M.useState([]),[j,N]=M.useState(""),[S,A]=M.useState(""),[I,L]=M.useState(""),[F,$]=M.useState(!1),[q,H]=M.useState(!1),[U,Q]=M.useState("agents"),[se,te]=M.useState("all"),[Y,ce]=M.useState({}),oe=l||i;M.useEffect(()=>{t&&o&&(l?le():de())},[t,o,l]),M.useEffect(()=>{t||(_([]),w([]),N(""),A(""),L(""),Q("agents"),te("all"))},[t]);const le=async()=>{if(o){$(!0);try{const{data:Le,error:Rt}=await K.from("brokerages").select("id, name").order("name");if(Rt)throw Rt;const fe=1e3,Qe={};let at=0,rt=!0;for(;rt;){const{data:He,error:ct}=await K.from("profiles").select("brokerage_id").range(at*fe,(at+1)*fe-1);if(ct)throw ct;He==null||He.forEach(We=>{We.brokerage_id&&(Qe[We.brokerage_id]=(Qe[We.brokerage_id]||0)+1)}),rt=(He==null?void 0:He.length)===fe,at++}g((Le==null?void 0:Le.map(He=>({...He,agent_count:Qe[He.id]||0})))||[]);const je=[];for(at=0,rt=!0;rt;){const{data:He,error:ct}=await K.from("profiles").select("id, name, email, brokerage_id, brokerages(name)").neq("id",o.id).order("name").range(at*fe,(at+1)*fe-1);if(ct)throw ct;He&&je.push(...He),rt=(He==null?void 0:He.length)===fe,at++}const mt={};for(at=0,rt=!0;rt;){const{data:He,error:ct}=await K.from("user_roles").select("user_id, role").range(at*fe,(at+1)*fe-1);if(ct)throw ct;He==null||He.forEach(We=>{mt[We.user_id]||(mt[We.user_id]=[]),mt[We.user_id].push(We.role)}),rt=(He==null?void 0:He.length)===fe,at++}ce(mt),u(je.map(He=>{var ct;return{id:He.id,name:He.name,email:He.email,brokerage_name:((ct=He.brokerages)==null?void 0:ct.name)||"No Brokerage",roles:mt[He.id]||[]}}))}catch(Le){console.error("Error loading data:",Le),ge.error("Failed to load agents and brokerages")}finally{$(!1)}}},de=async()=>{if(o){$(!0);try{const{data:Le}=await K.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(Le!=null&&Le.brokerage_id)){ge.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:Rt,error:fe}=await K.from("profiles").select("id, name, email").eq("brokerage_id",Le.brokerage_id).neq("id",o.id).order("name");if(fe)throw fe;u(Rt||[])}catch(Le){console.error("Error loading agents:",Le),ge.error("Failed to load agents")}finally{$(!1)}}},xe=d.filter(Le=>{var fe;const Rt=Le.name.toLowerCase().includes(j.toLowerCase())||Le.email.toLowerCase().includes(j.toLowerCase())||((fe=Le.brokerage_name)==null?void 0:fe.toLowerCase().includes(j.toLowerCase()));if(l&&se!=="all"){const Qe=Y[Le.id]||[];return Rt&&Qe.includes(se)}return Rt}),be=f.filter(Le=>Le.name.toLowerCase().includes(S.toLowerCase())),ye=()=>{v.length===xe.length?_([]):_(xe.map(Le=>Le.id))},ve=()=>{b.length===be.length?w([]):w(be.map(Le=>Le.id))},ke=Le=>{if(!oe){_([Le]);return}_(Rt=>Rt.includes(Le)?Rt.filter(fe=>fe!==Le):[...Rt,Le])},Ge=Le=>{w(Rt=>Rt.includes(Le)?Rt.filter(fe=>fe!==Le):[...Rt,Le])},Ne=async()=>{if(!(v.length>0||b.length>0)){ge.error("Please select at least one agent or brokerage to share with");return}H(!0);try{const{data:Rt,error:fe}=await K.functions.invoke("send-share-notification",{body:{recipientIds:v,brokerageIds:b,resourceType:r,resourceId:n,resourceTitle:a,message:I.trim()||void 0}});if(fe)throw fe;const Qe=(Rt==null?void 0:Rt.sharesCreated)||v.length;ge.success(`Shared with ${Qe} agent${Qe!==1?"s":""}`),s(!1)}catch(Rt){console.error("Error sharing resource:",Rt),ge.error("Failed to share resource")}finally{H(!1)}},Ae=Le=>Le.split(" ").map(Rt=>Rt[0]).join("").toUpperCase().slice(0,2),Pe=Le=>{const Rt=Y[Le]||[];return Rt.includes("admin")?e.jsx(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):Rt.includes("brokerage_manager")?e.jsx(nt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Fe=v.length+b.length,Ie=se!=="all"?xe.length:null;return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{className:"flex-shrink-0",children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Pa,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Kr,{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(Ia,{value:U,onValueChange:Q,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(Ts,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),v.length>0&&e.jsx(nt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:v.length})]}),e.jsxs(Ts,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(_a,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),b.length>0&&e.jsx(nt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:b.length})]})]}),e.jsxs(Vs,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or brokerage...",value:j,onChange:Le=>N(Le.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:se,onValueChange:te,children:[e.jsxs(Js,{className:"w-[180px]",children:[e.jsx(y0,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(rr,{placeholder:"Filter by role"})]}),e.jsx(er,{children:ome.map(Le=>e.jsx(At,{value:Le.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le.icon,{className:"h-4 w-4"}),e.jsx("span",{children:Le.label})]})},Le.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(Z,{variant:"ghost",size:"sm",onClick:ye,className:"text-xs h-8",disabled:xe.length===0,children:[e.jsx(xr,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===xe.length&&xe.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[Ie!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[Ie," ",(Ve=ome.find(Le=>Le.value===se))==null?void 0:Ve.label]}),e.jsxs("span",{className:"font-medium",children:[v.length," selected"]})]})]}),e.jsx(Fi,{className:"h-[300px] border rounded-lg",children:F?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(Rs,{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-[200px] text-muted-foreground",children:[e.jsx(xr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:se!=="all"?`No ${(dt=ome.find(Le=>Le.value===se))==null?void 0:dt.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:xe.map(Le=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(Le.id)?"bg-accent":""}`,onClick:()=>ke(Le.id),children:[e.jsx($o,{checked:v.includes(Le.id),onCheckedChange:()=>ke(Le.id),className:"flex-shrink-0"}),e.jsx(mn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(pn,{className:"text-xs bg-primary/10 text-primary",children:Ae(Le.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:Le.name}),Pe(Le.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[Le.email,Le.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",Le.brokerage_name]})]})]})]},Le.id))})})]}),e.jsxs(Vs,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search brokerages...",value:S,onChange:Le=>A(Le.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(Z,{variant:"ghost",size:"sm",onClick:ve,className:"text-xs h-8",disabled:be.length===0,children:[e.jsx(_a,{className:"h-3.5 w-3.5 mr-1.5"}),b.length===be.length&&be.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[b.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(Fi,{className:"h-[250px] border rounded-lg",children:F?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):be.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(_a,{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:be.map(Le=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${b.includes(Le.id)?"bg-accent":""}`,onClick:()=>Ge(Le.id),children:[e.jsx($o,{checked:b.includes(Le.id),onCheckedChange:()=>Ge(Le.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(_a,{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:Le.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Le.agent_count," agent",Le.agent_count!==1?"s":""]})]})]},Le.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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:j,onChange:Le=>N(Le.target.value),className:"pl-9"})]}),oe&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(Z,{variant:"ghost",size:"sm",onClick:ye,className:"text-xs h-8",disabled:xe.length===0,children:[e.jsx(xr,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===xe.length&&xe.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[v.length," selected"]})]}),e.jsx(Fi,{className:"h-[300px] border rounded-lg",children:F?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(Rs,{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-[200px] text-muted-foreground",children:[e.jsx(xr,{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:xe.map(Le=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(Le.id)?"bg-accent":""}`,onClick:()=>ke(Le.id),children:[e.jsx($o,{checked:v.includes(Le.id),onCheckedChange:()=>ke(Le.id),className:"flex-shrink-0"}),e.jsx(mn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(pn,{className:"text-xs bg-primary/10 text-primary",children:Ae(Le.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Le.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Le.email})]})]},Le.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(_e,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Lr,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:Le=>L(Le.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Z,{onClick:Ne,disabled:Fe===0||q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function hM({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=M.useState(!1),{user:d}=Qs();return d?e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(gAt,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function xAt(){const{eventId:t}=Uo(),s=Or(),{user:r}=Qs(),[n,a]=M.useState(null),[o,l]=M.useState(null),[i,d]=M.useState(0),[u,f]=M.useState(!0),[g,v]=M.useState(!1);M.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:A,error:I}=await K.from("events").select("*").eq("id",t).single();if(I)throw I;a(A);const{count:L}=await K.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(d(L||0),r){const{data:F}=await K.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(F)}}catch(A){console.error("Error loading event:",A),ge.error("Failed to load event"),s("/events")}finally{f(!1)}},b=async()=>{if(!(!r||!n)){v(!0);try{if(o){const{error:A}=await K.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(A)throw A;ge.success("Successfully cancelled registration"),l(null),d(I=>I-1)}else{const{data:A,error:I}=await K.functions.invoke("zoom-register",{body:{event_id:n.id}});if(I)throw I;ge.success("Successfully registered for event!"),l({id:A.registration_id,zoom_join_url:A.zoom_join_url}),d(L=>L+1)}}catch(A){console.error("Registration error:",A),ge.error(o?"Failed to cancel registration":"Failed to register for event")}finally{v(!1)}}},w=A=>{var I,L,F;if(A.includes("iframe.mediadelivery.net")||A.includes("video.bunnycdn.com")){const $=A.match(/embed\/(\d+)\/([a-f0-9-]+)/);if($)return`https://iframe.mediadelivery.net/embed/${$[1]}/${$[2]}?autoplay=false&preload=true`}if(A.includes("youtube.com")||A.includes("youtu.be")){const $=A.includes("youtu.be")?(I=A.split("youtu.be/")[1])==null?void 0:I.split("?")[0]:(L=A.split("v=")[1])==null?void 0:L.split("&")[0];if($)return`https://www.youtube.com/embed/${$}`}if(A.includes("vimeo.com")){const $=(F=A.split("vimeo.com/")[1])==null?void 0:F.split("?")[0];if($)return`https://player.vimeo.com/video/${$}`}return A};if(u)return e.jsx(Ms,{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(Ms,{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(Z,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const j=Wx(new Date(n.event_date)),N=n.capacity&&i>=n.capacity,S=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Ms,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(Z,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(Ba,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),j&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(nt,{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(hM,{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(mm,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src:w(n.video_url),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Event Preview Video"})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(De,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(nn,{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:DI(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(xr,{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(hi,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!j&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(Z,{className:"w-full gap-2",onClick:()=>window.open(S,"_blank"),children:[e.jsx(un,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(Z,{variant:"outline",className:"w-full",onClick:b,disabled:g,children:[g?e.jsx(Rs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(Z,{className:"w-full gap-2",onClick:b,disabled:g||(N??!1),children:g?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):N?"Event Full":"Register Now"})}),j&&o&&e.jsxs(Z,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(un,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const yAt=()=>{const{user:t,isAdmin:s}=Qs(),r=Or(),[n,a]=M.useState([]),[o,l]=M.useState(!0),[i,d]=M.useState(""),[u,f]=M.useState("all"),[g,v]=M.useState(new Set);M.useEffect(()=>{_()},[t]);const _=async()=>{try{const{data:S}=await K.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),A=(S==null?void 0:S.map(U=>U.tag))||[],{data:I,error:L}=await K.from("app_tiles").select("*").order("name");if(L)throw L;const{data:F}=await K.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),$=new Set((F==null?void 0:F.map(U=>U.app_id))||[]);v($);const H=((I==null?void 0:I.filter(U=>!U.required_tags||U.required_tags.length===0?!0:U.required_tags.some(Q=>A.includes(Q))))||[]).sort((U,Q)=>U.name==="LevelUp Members Portal"?-1:Q.name==="LevelUp Members Portal"?1:0);a(H)}catch(S){console.error("Error loading apps:",S),ge.error("Failed to load apps")}finally{l(!1)}},b=async S=>{var I;const A=window.open("about:blank","_blank");try{const{data:L,error:F}=await K.auth.getSession();if(F||!L.session){A==null||A.close(),ge.error("Session expired. Please refresh the page and try again.");return}const $=L.session.access_token;await K.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:S.app_id,app_name:S.name,user_agent:navigator.userAgent});const{data:q,error:H}=await K.functions.invoke("sso-launch",{body:{app_id:S.app_id},headers:{Authorization:`Bearer ${$}`}});if(H)throw H;q!=null&&q.redirect_url?A&&!A.closed?(A.location.href=q.redirect_url,(I=A.focus)==null||I.call(A)):window.location.assign(q.redirect_url):(A==null||A.close(),ge.error("Launch link unavailable"))}catch(L){A==null||A.close(),console.error("Error launching app:",L),ge.error("Failed to launch app. Please try again.")}},w=async(S,A)=>{S.stopPropagation();const I=g.has(A);try{if(I){const{error:L}=await K.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",A);if(L)throw L;v(F=>{const $=new Set(F);return $.delete(A),$}),ge.success("Removed from favorites")}else{const{error:L}=await K.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:A});if(L)throw L;v(F=>new Set(F).add(A)),ge.success("Added to favorites")}}catch(L){console.error("Error toggling favorite:",L),ge.error("Failed to update favorites")}},j=n.filter(S=>{var I;const A=S.name.toLowerCase().includes(i.toLowerCase())||((I=S.description)==null?void 0:I.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?A&&g.has(S.id):A}),N=[{id:"all",label:"All"},{id:"favorites",label:"Favorites"}];return o?e.jsx(Ms,{title:"Apps",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..."})]})})}):e.jsxs(Ms,{title:"Apps",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"}),e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search apps...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:S=>d(S.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:N.map(S=>e.jsxs("button",{onClick:()=>f(S.id),className:It("pb-3 text-sm font-medium transition-colors relative",u===S.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[S.label,u===S.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},S.id))}),j.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(Cg,{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 to add it to your favorites"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pu,{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(Z,{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:j.map(S=>{const A=g.has(S.id),I=S.name.toLowerCase().includes("agent review")||S.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:()=>b(S),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:S.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:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:S.description})]}),e.jsx("button",{className:It("flex-shrink-0 p-1 transition-colors",A?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:L=>w(L,S.id),children:e.jsx(Cg,{className:It("h-5 w-5",A&&"fill-current")})})]}),I&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:L=>L.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},S.id)})})]})},vAt=()=>{const t=Or(),[s,r]=M.useState(""),[n,a]=M.useState("all"),[o,l]=M.useState("all"),[i,d]=M.useState("grid"),{data:u=[]}=Tt({queryKey:["template-categories"],queryFn:async()=>{const{data:N,error:S}=await K.from("template_categories").select("*").order("name");if(S)throw S;return N}}),{data:f=[]}=Tt({queryKey:["template-types"],queryFn:async()=>{const{data:N,error:S}=await K.from("template_types").select("*").order("name");if(S)throw S;return N}}),{data:g=[],isLoading:v}=Tt({queryKey:["canva-templates"],queryFn:async()=>{const{data:N,error:S}=await K.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(S)throw S;const{data:A,error:I}=await K.from("template_links").select("*").order("sort_order");if(I)throw I;const{data:L}=await K.from("template_likes").select("template_id"),{data:F}=await K.from("template_comments").select("template_id"),$=new Map;L==null||L.forEach(U=>{$.set(U.template_id,($.get(U.template_id)||0)+1)});const q=new Map;return F==null||F.forEach(U=>{q.set(U.template_id,(q.get(U.template_id)||0)+1)}),(N||[]).map(U=>({...U,links:(A||[]).filter(Q=>Q.template_id===U.id)||[],likesCount:$.get(U.id)||0,commentsCount:q.get(U.id)||0}))}}),_=g.filter(N=>{var L;const S=N.name.toLowerCase().includes(s.toLowerCase())||((L=N.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),A=n==="all"||N.category_id===n,I=o==="all"||N.type_id===o;return S&&A&&I}),b=()=>{r(""),a("all"),l("all")},w=s||n!=="all"||o!=="all",j=N=>{t(`/templates/${N}`)};return e.jsx(Ms,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search templates...",value:s,onChange:N=>r(N.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:n,onValueChange:a,children:[e.jsx(Js,{className:"w-full sm:w-48",children:e.jsx(rr,{placeholder:"All Categories"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Categories"}),u.map(N=>e.jsx(At,{value:N.id,children:N.name},N.id))]})]}),e.jsxs(tr,{value:o,onValueChange:l,children:[e.jsx(Js,{className:"w-full sm:w-48",children:e.jsx(rr,{placeholder:"All Types"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),f.map(N=>e.jsx(At,{value:N.id,children:N.name},N.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[w&&e.jsx(Z,{variant:"outline",size:"sm",onClick:b,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>d("grid"),className:"rounded-full",children:e.jsx(hp,{className:"h-4 w-4"})}),e.jsx(Z,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:e.jsx(Fh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[_.length," template",_.length!==1?"s":""," found"]}),v&&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,S)=>e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(gs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(gs,{className:"h-5 w-16"}),e.jsx(gs,{className:"h-5 w-20"})]})]})},S))}),!v&&_.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:w?"No templates match your filters":"No templates available yet"}),w&&e.jsx(Z,{variant:"outline",onClick:b,children:"Clear Filters"})]}),!v&&_.length>0&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:_.map(N=>e.jsxs(De,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>j(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(nt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Po,{className:"h-3 w-3"}),N.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:N.name}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:$ie(N.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[N.category&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:N.category.name}),N.type&&e.jsx(nt,{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(lu,{className:"h-3.5 w-3.5"}),N.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mc,{className:"h-3.5 w-3.5"}),N.commentsCount]})]}),e.jsxs(Z,{size:"sm",className:"w-full gap-2",onClick:S=>{S.stopPropagation(),j(N.id)},children:[e.jsx(un,{className:"h-4 w-4"}),"View Template"]})]})]},N.id))})]})})};var _At="Separator",eTe="horizontal",bAt=["horizontal","vertical"],AHe=M.forwardRef((t,s)=>{const{decorative:r,orientation:n=eTe,...a}=t,o=wAt(n)?n:eTe,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(Qr.div,{"data-orientation":o,...i,...a,ref:s})});AHe.displayName=_At;function wAt(t){return bAt.includes(t)}var EHe=AHe;const Jl=M.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(EHe,{ref:a,decorative:r,orientation:s,className:It("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));Jl.displayName=EHe.displayName;const _L=()=>({trackEngagement:M.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await K.auth.getUser();if(!o)return;await K.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)}},[])}),jAt=()=>{const{templateId:t}=Uo(),s=Or(),{user:r,isAdmin:n}=Qs(),{toast:a}=La(),o=ds(),{trackEngagement:l}=_L(),[i,d]=M.useState(""),{data:u,isLoading:f}=Tt({queryKey:["template-detail",t],queryFn:async()=>{const{data:I,error:L}=await K.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(L)throw L;const{data:F}=await K.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:$}=await K.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...I,links:F||[],guides:$||[]}},enabled:!!t}),{data:g=[]}=Tt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:I,error:L}=await K.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(F=>F.resource_kits).filter(Boolean)},enabled:!!t});M.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:v=[]}=Tt({queryKey:["template-likes",t],queryFn:async()=>{const{data:I,error:L}=await K.from("template_likes").select("*").eq("template_id",t);if(L)throw L;return I},enabled:!!t}),{data:_=[]}=Tt({queryKey:["template-comments",t],queryFn:async()=>{const{data:I,error:L}=await K.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(L)throw L;const F=[...new Set(I.map(H=>H.user_id))],{data:$}=await K.from("profiles").select("id, name").in("id",F),q=new Map(($==null?void 0:$.map(H=>[H.id,H.name]))||[]);return I.map(H=>({...H,user_name:q.get(H.user_id)||"Unknown User"}))},enabled:!!t}),b=Bt({mutationFn:async I=>{const{error:L}=await K.from("template_comments").insert({template_id:t,user_id:r.id,content:I});if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),d(""),a({title:"Comment added!"})},onError:I=>{a({title:"Error adding comment",description:I.message,variant:"destructive"})}}),w=Bt({mutationFn:async I=>{const{error:L}=await K.from("template_comments").delete().eq("id",I);if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),j=Bt({mutationFn:async()=>{const I=v.find(L=>L.user_id===(r==null?void 0:r.id));if(I){const{error:L}=await K.from("template_likes").delete().eq("id",I.id);if(L)throw L}else{const{error:L}=await K.from("template_likes").insert({template_id:t,user_id:r.id});if(L)throw L}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),N=v.some(I=>I.user_id===(r==null?void 0:r.id)),S=I=>I.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),A=I=>{I.preventDefault(),!(!i.trim()||!r)&&b.mutate(i.trim())};return f?e.jsx(Ms,{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(Ms,{title:u.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Z,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(yo,{to:"/templates",children:[e.jsx(Ba,{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(nt,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(nt,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(Z,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(yo,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(Ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(hM,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(Z,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>j.mutate(),disabled:!r||j.isPending,children:[e.jsx(lu,{className:`h-4 w-4 ${N?"fill-current":""}`}),v.length," ",v.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(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Po,{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(Z,{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(un,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})}),u.guides&&u.guides.length>0&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Un,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(I=>e.jsxs(Z,{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(Un,{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(Ei,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),g.length>0&&e.jsx(De,{children:e.jsxs(Oe,{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:g.map(I=>e.jsxs(Z,{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(Jl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(mc,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:A,className:"flex gap-2",children:[e.jsx(Lr,{placeholder:"Add a comment...",value:i,onChange:I=>d(I.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(Z,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||b.isPending,children:e.jsx(Pa,{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:_.length===0?e.jsx(De,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):_.map(I=>e.jsx(De,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(mn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(pn,{className:"text-sm",children:S(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(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>w.mutate(I.id),children:e.jsx(Cr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):e.jsx(Ms,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Po,{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(Z,{asChild:!0,className:"mt-4",children:e.jsx(yo,{to:"/templates",children:"Back to Templates"})})]})})},kAt=()=>{const{user:t}=Qs(),[s,r]=M.useState(""),[n,a]=M.useState("all"),{data:o=[]}=Tt({queryKey:["academy-categories"],queryFn:async()=>{const{data:v,error:_}=await K.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(_)throw _;return v}}),{data:l=[],isLoading:i}=Tt({queryKey:["academy-videos"],queryFn:async()=>{const{data:v,error:_}=await K.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;const{data:b,error:w}=await K.from("academy_resources").select("*").order("sort_order");if(w)throw w;return v.map(N=>({...N,resources:(b==null?void 0:b.filter(S=>S.video_id===N.id))||[]}))}}),{data:d=[]}=Tt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:v,error:_}=await K.from("academy_video_likes").select("video_id, user_id");if(_)throw _;return v}}),u=l.filter(v=>{var w;const _=s===""||v.title.toLowerCase().includes(s.toLowerCase())||((w=v.description)==null?void 0:w.toLowerCase().includes(s.toLowerCase())),b=n==="all"||v.category_id===n;return _&&b}),f=v=>d.filter(_=>_.video_id===v).length,g=v=>d.some(_=>_.video_id===v&&_.user_id===(t==null?void 0:t.id));return e.jsx(Ms,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search videos...",value:s,onChange:v=>r(v.target.value),className:"pl-10"})]})}),e.jsx(Ia,{value:n,onValueChange:a,children:e.jsxs(Aa,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(Ts,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(v=>e.jsx(Ts,{value:v.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:v.name},v.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(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Cn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No videos found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s?"Try adjusting your search terms":"Check back soon for new content"})]})}):e.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:u.map(v=>e.jsx(yo,{to:`/academy/${v.id}`,children:e.jsxs(De,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow group h-full",children:[e.jsxs("div",{className:"relative aspect-video bg-muted",children:[v.thumbnail_url?e.jsx("img",{src:v.thumbnail_url,alt:v.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(dl,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),v.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(Tn,{className:"h-3 w-3"}),v.duration]})]}),e.jsxs($t,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Vt,{className:"text-lg line-clamp-2",children:v.title})}),v.category&&e.jsx(nt,{variant:"secondary",className:"w-fit",children:v.category.name})]}),e.jsxs(Oe,{className:"pt-0",children:[v.description&&e.jsx(_r,{className:"line-clamp-2",children:v.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(lu,{className:`h-4 w-4 ${g(v.id)?"fill-primary text-primary":""}`}),f(v.id)]}),v.resources&&v.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-4 w-4"}),v.resources.length]})]})]})]})},v.id))})]})})};function PHe({resourceType:t,resourceId:s}){const{data:r=[]}=Tt({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await K.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 K.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(El,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(yo,{to:`/templates/${n.id}`,children:e.jsxs(nt,{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(El,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const NAt=(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},SAt=()=>{const{videoId:t}=Uo();Or();const{user:s,isAdmin:r}=Qs(),{toast:n}=La(),a=ds(),{trackEngagement:o}=_L(),[l,i]=M.useState(""),{data:d,isLoading:u}=Tt({queryKey:["academy-video",t],queryFn:async()=>{const{data:A,error:I}=await K.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 K.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...A,resources:L||[]}},enabled:!!t});M.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:f=[]}=Tt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:A,error:I}=await K.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return A},enabled:!!t}),{data:g=[]}=Tt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:A,error:I}=await K.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(A.map(q=>q.user_id))],{data:F}=await K.from("profiles").select("id, name").in("id",L),$=new Map((F==null?void 0:F.map(q=>[q.id,q.name]))||[]);return A.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),v=Bt({mutationFn:async A=>{const{error:I}=await K.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:A});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:A=>{n({title:"Error adding comment",description:A.message,variant:"destructive"})}}),_=Bt({mutationFn:async A=>{const{error:I}=await K.from("academy_video_comments").delete().eq("id",A);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),b=Bt({mutationFn:async()=>{const A=f.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await K.from("academy_video_likes").delete().eq("id",A.id);if(I)throw I}else{const{error:I}=await K.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),w=f.some(A=>A.user_id===(s==null?void 0:s.id)),j=A=>{switch(A==null?void 0:A.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=A=>A.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),S=A=>{A.preventDefault(),!(!l.trim()||!s)&&v.mutate(l.trim())};return u?e.jsx(Ms,{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"})})}):d?e.jsx(Ms,{title:d.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Z,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(yo,{to:"/academy",children:[e.jsx(Ba,{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(d.video_type)?e.jsx("iframe",{src:NAt(d.video_url,d.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(Z,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:d.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(un,{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:d.title}),d.category&&e.jsx(nt,{variant:"secondary",children:d.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(Z,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(yo,{to:`/admin/academy?edit=${d.id}`,children:[e.jsx(Ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(hM,{resourceType:"academy_video",resourceId:d.id,resourceTitle:d.title}),e.jsxs(Z,{variant:w?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(lu,{className:`h-4 w-4 ${w?"fill-current":""}`}),f.length," ",f.length===1?"Like":"Likes"]})]})]}),d.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:d.description}})]}),d.resources&&d.resources.length>0&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Un,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:d.resources.map(A=>e.jsxs("a",{href:A.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-2xl",children:j(A.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:A.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:A.file_type})]}),e.jsx(Ei,{className:"h-4 w-4 text-muted-foreground"})]},A.id))})]})}),e.jsx(PHe,{resourceType:"academy_video",resourceId:d.id}),e.jsx(Jl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(mc,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Lr,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(Z,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:e.jsx(Pa,{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:g.length===0?e.jsx(De,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):g.map(A=>e.jsx(De,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(mn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(pn,{className:"text-sm",children:N(A.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:A.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:$d(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(Cr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Ms,{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(Z,{asChild:!0,className:"mt-4",children:e.jsx(yo,{to:"/academy",children:"Back to Academy"})})]})})};function CAt(){const t=Or(),[s,r]=M.useState(""),{data:n,isLoading:a}=Tt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:_,error:b}=await K.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(b)throw b;return _}}),{data:o}=Tt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:_,error:b}=await K.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(b)throw b;return _}}),{data:l}=Tt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:_,error:b}=await K.from("resource_kit_likes").select("kit_id");if(b)throw b;return _}}),{data:i}=Tt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:_,error:b}=await K.from("resource_kit_comments").select("kit_id");if(b)throw b;return _}}),d=n==null?void 0:n.filter(_=>{var b;return _.name.toLowerCase().includes(s.toLowerCase())||((b=_.description)==null?void 0:b.toLowerCase().includes(s.toLowerCase()))}),u=_=>(o==null?void 0:o.filter(b=>b.kit_id===_))||[],f=_=>(l==null?void 0:l.filter(b=>b.kit_id===_).length)||0,g=_=>(i==null?void 0:i.filter(b=>b.kit_id===_).length)||0,v=_=>{t(`/toolbox/${_}`)};return e.jsx(Ms,{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(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search resource kits...",value:s,onChange:_=>r(_.target.value),className:"pl-10"})]}),!a&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(d==null?void 0:d.length)||0," resource kit",(d==null?void 0:d.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(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(gs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{className:"h-4 w-full mb-4"}),e.jsx(gs,{className:"h-4 w-2/3"})]})},b))}):(d==null?void 0:d.length)===0?e.jsxs(De,{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:d==null?void 0:d.map(_=>{const b=u(_.id).length,w=f(_.id),j=g(_.id);return e.jsxs(De,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>v(_.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:_.featured_image_url?e.jsx("img",{src:_.featured_image_url,alt:_.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(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:_.name}),_.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:$ie(_.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(Un,{className:"h-4 w-4"}),b," file",b!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lu,{className:"h-3.5 w-3.5"}),w]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mc,{className:"h-3.5 w-3.5"}),j]})]})]})]})]},_.id)})})]})})}const MAt=()=>{const{kitId:t}=Uo(),{user:s,isAdmin:r}=Qs(),{toast:n}=La(),a=ds(),{trackEngagement:o}=_L(),[l,i]=M.useState(""),{data:d,isLoading:u}=Tt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:A,error:I}=await K.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await K.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:F}=await K.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...A,files:L||[],links:F||[]}},enabled:!!t});M.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:f=[]}=Tt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:A,error:I}=await K.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return A},enabled:!!t}),{data:g=[]}=Tt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:A,error:I}=await K.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(A.map(q=>q.user_id))],{data:F}=await K.from("profiles").select("id, name").in("id",L),$=new Map((F==null?void 0:F.map(q=>[q.id,q.name]))||[]);return A.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),v=Bt({mutationFn:async A=>{const{error:I}=await K.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:A});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:A=>{n({title:"Error adding comment",description:A.message,variant:"destructive"})}}),_=Bt({mutationFn:async A=>{const{error:I}=await K.from("resource_kit_comments").delete().eq("id",A);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),b=Bt({mutationFn:async()=>{const A=f.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await K.from("resource_kit_likes").delete().eq("id",A.id);if(I)throw I}else{const{error:I}=await K.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),w=f.some(A=>A.user_id===(s==null?void 0:s.id)),j=A=>A.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),N=A=>A?A<1024?A+" B":A<1024*1024?(A/1024).toFixed(1)+" KB":(A/(1024*1024)).toFixed(1)+" MB":"",S=A=>{A.preventDefault(),!(!l.trim()||!s)&&v.mutate(l.trim())};return u?e.jsx(Ms,{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"})})}):d?e.jsx(Ms,{title:d.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Z,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(yo,{to:"/toolbox",children:[e.jsx(Ba,{className:"h-4 w-4"}),"Back to Toolbox"]})}),d.featured_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:d.featured_image_url,alt:d.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:d.name})}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(Z,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(yo,{to:`/admin/toolbox?edit=${d.id}`,children:[e.jsx(Ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(hM,{resourceType:"resource_kit",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),e.jsxs(Z,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(lu,{className:`h-4 w-4 ${w?"fill-current":""}`}),f.length," ",f.length===1?"Like":"Likes"]})]})]}),d.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:d.description}})]}),d.files&&d.files.length>0&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Un,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.files.map(A=>e.jsxs("a",{href:A.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",d.id,d.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(Un,{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(Ei,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},A.id))})]})}),d.links&&d.links.length>0&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(un,{className:"h-4 w-4"}),"Canva Templates (",d.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.links.map(A=>e.jsxs("a",{href:A.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",d.id,d.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(un,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:A.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},A.id))})]})}),e.jsx(PHe,{resourceType:"resource_kit",resourceId:d.id}),e.jsx(Jl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(mc,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Lr,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(Z,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:e.jsx(Pa,{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:g.length===0?e.jsx(De,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):g.map(A=>e.jsx(De,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(mn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(pn,{className:"text-sm",children:j(A.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:A.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:$d(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(Cr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Ms,{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(Z,{asChild:!0,className:"mt-4",children:e.jsx(yo,{to:"/toolbox",children:"Back to Toolbox"})})]})})},TAt=()=>{const t=Or(),[s,r]=M.useState(""),[n,a]=M.useState("grid"),{data:o=[],isLoading:l}=Tt({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:f}=await K.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(f)throw f;const{data:g,error:v}=await K.from("social_swag_links").select("*").order("sort_order");if(v)throw v;const{data:_}=await K.from("social_swag_likes").select("swag_id"),{data:b}=await K.from("social_swag_comments").select("swag_id"),w=new Map;_==null||_.forEach(S=>{w.set(S.swag_id,(w.get(S.swag_id)||0)+1)});const j=new Map;return b==null||b.forEach(S=>{j.set(S.swag_id,(j.get(S.swag_id)||0)+1)}),(u||[]).map(S=>({...S,links:(g||[]).filter(A=>A.swag_id===S.id)||[],likesCount:w.get(S.id)||0,commentsCount:j.get(S.id)||0}))}}),i=o.filter(u=>{var g;return u.title.toLowerCase().includes(s.toLowerCase())||((g=u.description)==null?void 0:g.toLowerCase().includes(s.toLowerCase()))}),d=u=>{t(`/social-swag/${u}`)};return e.jsx(Ms,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{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(Z,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(hp,{className:"h-4 w-4"})}),e.jsx(Z,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Fh,{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,f)=>e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(gs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{className:"h-4 w-full mb-4"})]})},f))}),!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(Z,{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(De,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>d(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(nt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Po,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${n==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:u.title}),u.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:u.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lu,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mc,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(Z,{size:"sm",className:"w-full gap-2",onClick:f=>{f.stopPropagation(),d(u.id)},children:[e.jsx(un,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var li=function(){return li=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(d||!u),g=s>1&&(u||!d),v=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(lEt,{displayMonth:t.displayMonth,hideNext:f,hidePrevious:g,nextMonth:a,previousMonth:n,onPreviousClick:v,onNextClick:_})}function cEt(t){var s,r=Ll(),n=r.classNames,a=r.disableNavigation,o=r.styles,l=r.captionLayout,i=r.components,d=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:DHe,u;return a?u=e.jsx(d,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(tTe,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(tTe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(sTe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):u=e.jsxs(e.Fragment,{children:[e.jsx(d,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(sTe,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function dEt(t){var s=Ll(),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 uEt(t,s,r){for(var n=r?z0(new Date):Ju(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=hl(n,o);a.push(l)}return a}function hEt(){var t=Ll(),s=t.classNames,r=t.styles,n=t.showWeekNumber,a=t.locale,o=t.weekStartsOn,l=t.ISOWeek,i=t.formatters.formatWeekdayName,d=t.labels.labelWeekday,u=uEt(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(f,g){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":d(f,{locale:a}),children:i(f,{locale:a})},g)})]})}function mEt(){var t,s=Ll(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:hEt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function pEt(t){var s=Ll(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var lbe=M.createContext(void 0);function fEt(t){if(!bL(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(lbe.Provider,{value:s,children:t.children})}return e.jsx(gEt,{initialProps:t.initialProps,children:t.children})}function gEt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,f,g){var v,_;(v=s.onDayClick)===null||v===void 0||v.call(s,u,f,g);var b=!!(f.selected&&a&&(n==null?void 0:n.length)===a);if(!b){var w=!!(!f.selected&&o&&(n==null?void 0:n.length)===o);if(!w){var j=n?IHe([],n):[];if(f.selected){var N=j.findIndex(function(S){return ll(u,S)});j.splice(N,1)}else j.push(u);(_=s.onSelect)===null||_===void 0||_.call(s,j,u,f,g)}}},i={disabled:[]};n&&i.disabled.push(function(u){var f=o&&n.length>o-1,g=n.some(function(v){return ll(v,u)});return!!(f&&!g)});var d={selected:n,onDayClick:l,modifiers:i};return e.jsx(lbe.Provider,{value:d,children:r})}function cbe(){var t=M.useContext(lbe);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function xEt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?ll(a,t)&&ll(n,t)?void 0:ll(a,t)?{from:a,to:void 0}:ll(n,t)?void 0:NN(n,t)?{from:t,to:a}:{from:n,to:t}:a?NN(t,a)?{from:a,to:t}:{from:t,to:a}:n?SN(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var dbe=M.createContext(void 0);function yEt(t){if(!wL(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(dbe.Provider,{value:s,children:t.children})}return e.jsx(vEt,{initialProps:t.initialProps,children:t.children})}function vEt(t){var s=t.initialProps,r=t.children,n=s.selected,a=n||{},o=a.from,l=a.to,i=s.min,d=s.max,u=function(_,b,w){var j,N;(j=s.onDayClick)===null||j===void 0||j.call(s,_,b,w);var S=xEt(_,n);(N=s.onSelect)===null||N===void 0||N.call(s,S,_,b,w)},f={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(f.range_start=[o],l?(f.range_end=[l],ll(o,l)||(f.range_middle=[{after:o,before:l}])):f.range_end=[o]):l&&(f.range_start=[l],f.range_end=[l]),i&&(o&&!l&&f.disabled.push({after:Wse(o,i-1),before:hl(o,i-1)}),o&&l&&f.disabled.push({after:o,before:hl(o,i-1)}),!o&&l&&f.disabled.push({after:Wse(l,i-1),before:hl(l,i-1)})),d){if(o&&!l&&(f.disabled.push({before:hl(o,-d+1)}),f.disabled.push({after:hl(o,d-1)})),o&&l){var g=op(l,o)+1,v=d-g;f.disabled.push({before:Wse(o,v)}),f.disabled.push({after:hl(l,v)})}!o&&l&&(f.disabled.push({before:hl(l,-d+1)}),f.disabled.push({after:hl(l,d-1)}))}return e.jsx(dbe.Provider,{value:{selected:n,onDayClick:u,modifiers:f},children:r})}function ube(){var t=M.useContext(dbe);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function sre(t){return Array.isArray(t)?IHe([],t):t!==void 0?[t]:[]}function _Et(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=sre(a)}),s}var Bg;(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"})(Bg||(Bg={}));var bEt=Bg.Selected,qy=Bg.Disabled,wEt=Bg.Hidden,jEt=Bg.Today,lme=Bg.RangeEnd,cme=Bg.RangeMiddle,dme=Bg.RangeStart,kEt=Bg.Outside;function NEt(t,s,r){var n,a=(n={},n[bEt]=sre(t.selected),n[qy]=sre(t.disabled),n[wEt]=sre(t.hidden),n[jEt]=[t.today],n[lme]=[],n[cme]=[],n[dme]=[],n[kEt]=[],n);return t.fromDate&&a[qy].push({before:t.fromDate}),t.toDate&&a[qy].push({after:t.toDate}),bL(t)?a[qy]=a[qy].concat(s.modifiers[qy]):wL(t)&&(a[qy]=a[qy].concat(r.modifiers[qy]),a[dme]=r.modifiers[dme],a[cme]=r.modifiers[cme],a[lme]=r.modifiers[lme]),a}var FHe=M.createContext(void 0);function SEt(t){var s=Ll(),r=cbe(),n=ube(),a=NEt(s,r,n),o=_Et(s.modifiers),l=li(li({},a),o);return e.jsx(FHe.Provider,{value:l,children:t.children})}function zHe(){var t=M.useContext(FHe);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function CEt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function MEt(t){return!!(t&&typeof t=="object"&&"from"in t)}function TEt(t){return!!(t&&typeof t=="object"&&"after"in t)}function AEt(t){return!!(t&&typeof t=="object"&&"before"in t)}function EEt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function PEt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=op(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=op(t,n)>=0&&op(a,t)>=0;return l}return a?ll(a,t):n?ll(n,t):!1}function IEt(t){return R1e(t)}function LEt(t){return Array.isArray(t)&&t.every(R1e)}function DEt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(IEt(r))return ll(t,r);if(LEt(r))return r.includes(t);if(MEt(r))return PEt(t,r);if(EEt(r))return r.dayOfWeek.includes(t.getDay());if(CEt(r)){var n=op(r.before,t),a=op(r.after,t),o=n>0,l=a<0,i=NN(r.before,r.after);return i?l&&o:o||l}return TEt(r)?op(t,r.after)>0:AEt(r)?op(r.before,t)>0:typeof r=="function"?r(t):!1})}function hbe(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return DEt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!voe(t,r)&&(a.outside=!0),a}function OEt(t,s){for(var r=Bh(t[0]),n=dL(t[t.length-1]),a,o,l=r;l<=n;){var i=hbe(l,s),d=!i.disabled&&!i.hidden;if(!d){l=hl(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=hl(l,1)}return o||a}var REt=365;function BHe(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,d=a.weekStartsOn,u=a.fromDate,f=a.toDate,g=a.locale,v={day:hl,week:vk,month:$h,year:C0t,startOfWeek:function(j){return a.ISOWeek?z0(j):Ju(j,{locale:g,weekStartsOn:d})},endOfWeek:function(j){return a.ISOWeek?d9e(j):xoe(j,{locale:g,weekStartsOn:d})}},_=v[r](t,n==="after"?1:-1);n==="before"&&u?_=M0t([u,_]):n==="after"&&f&&(_=T0t([f,_]));var b=!0;if(o){var w=hbe(_,o);b=!w.disabled&&!w.hidden}return b?_:i.count>REt?i.lastFocused:BHe(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:li(li({},i),{count:i.count+1})})}var $He=M.createContext(void 0);function FEt(t){var s=jL(),r=zHe(),n=M.useState(),a=n[0],o=n[1],l=M.useState(),i=l[0],d=l[1],u=OEt(s.displayMonths,r),f=a??(i&&s.isDateDisplayed(i))?i:u,g=function(){d(a),o(void 0)},v=function(j){o(j)},_=Ll(),b=function(j,N){if(a){var S=BHe(a,{moveBy:j,direction:N,context:_,modifiers:r});ll(a,S)||(s.goToDate(S,a),v(S))}},w={focusedDay:a,focusTarget:f,blur:g,focus:v,focusDayAfter:function(){return b("day","after")},focusDayBefore:function(){return b("day","before")},focusWeekAfter:function(){return b("week","after")},focusWeekBefore:function(){return b("week","before")},focusMonthBefore:function(){return b("month","before")},focusMonthAfter:function(){return b("month","after")},focusYearBefore:function(){return b("year","before")},focusYearAfter:function(){return b("year","after")},focusStartOfWeek:function(){return b("startOfWeek","before")},focusEndOfWeek:function(){return b("endOfWeek","after")}};return e.jsx($He.Provider,{value:w,children:t.children})}function mbe(){var t=M.useContext($He);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function zEt(t,s){var r=zHe(),n=hbe(t,r,s);return n}var pbe=M.createContext(void 0);function BEt(t){if(!sle(t.initialProps)){var s={selected:void 0};return e.jsx(pbe.Provider,{value:s,children:t.children})}return e.jsx($Et,{initialProps:t.initialProps,children:t.children})}function $Et(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var d,u,f;if((d=s.onDayClick)===null||d===void 0||d.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}(f=s.onSelect)===null||f===void 0||f.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(pbe.Provider,{value:a,children:r})}function qHe(){var t=M.useContext(pbe);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function qEt(t,s){var r=Ll(),n=qHe(),a=cbe(),o=ube(),l=mbe(),i=l.focusDayAfter,d=l.focusDayBefore,u=l.focusWeekAfter,f=l.focusWeekBefore,g=l.blur,v=l.focus,_=l.focusMonthBefore,b=l.focusMonthAfter,w=l.focusYearBefore,j=l.focusYearAfter,N=l.focusStartOfWeek,S=l.focusEndOfWeek,A=function(le){var de,xe,be,ye;sle(r)?(de=n.onDayClick)===null||de===void 0||de.call(n,t,s,le):bL(r)?(xe=a.onDayClick)===null||xe===void 0||xe.call(a,t,s,le):wL(r)?(be=o.onDayClick)===null||be===void 0||be.call(o,t,s,le):(ye=r.onDayClick)===null||ye===void 0||ye.call(r,t,s,le)},I=function(le){var de;v(t),(de=r.onDayFocus)===null||de===void 0||de.call(r,t,s,le)},L=function(le){var de;g(),(de=r.onDayBlur)===null||de===void 0||de.call(r,t,s,le)},F=function(le){var de;(de=r.onDayMouseEnter)===null||de===void 0||de.call(r,t,s,le)},$=function(le){var de;(de=r.onDayMouseLeave)===null||de===void 0||de.call(r,t,s,le)},q=function(le){var de;(de=r.onDayPointerEnter)===null||de===void 0||de.call(r,t,s,le)},H=function(le){var de;(de=r.onDayPointerLeave)===null||de===void 0||de.call(r,t,s,le)},U=function(le){var de;(de=r.onDayTouchCancel)===null||de===void 0||de.call(r,t,s,le)},Q=function(le){var de;(de=r.onDayTouchEnd)===null||de===void 0||de.call(r,t,s,le)},se=function(le){var de;(de=r.onDayTouchMove)===null||de===void 0||de.call(r,t,s,le)},te=function(le){var de;(de=r.onDayTouchStart)===null||de===void 0||de.call(r,t,s,le)},Y=function(le){var de;(de=r.onDayKeyUp)===null||de===void 0||de.call(r,t,s,le)},ce=function(le){var de;switch(le.key){case"ArrowLeft":le.preventDefault(),le.stopPropagation(),r.dir==="rtl"?i():d();break;case"ArrowRight":le.preventDefault(),le.stopPropagation(),r.dir==="rtl"?d():i();break;case"ArrowDown":le.preventDefault(),le.stopPropagation(),u();break;case"ArrowUp":le.preventDefault(),le.stopPropagation(),f();break;case"PageUp":le.preventDefault(),le.stopPropagation(),le.shiftKey?w():_();break;case"PageDown":le.preventDefault(),le.stopPropagation(),le.shiftKey?j():b();break;case"Home":le.preventDefault(),le.stopPropagation(),N();break;case"End":le.preventDefault(),le.stopPropagation(),S();break}(de=r.onDayKeyDown)===null||de===void 0||de.call(r,t,s,le)},oe={onClick:A,onFocus:I,onBlur:L,onKeyDown:ce,onKeyUp:Y,onMouseEnter:F,onMouseLeave:$,onPointerEnter:q,onPointerLeave:H,onTouchCancel:U,onTouchEnd:Q,onTouchMove:se,onTouchStart:te};return oe}function UEt(){var t=Ll(),s=qHe(),r=cbe(),n=ube(),a=sle(t)?s.selected:bL(t)?r.selected:wL(t)?n.selected:void 0;return a}function VEt(t){return Object.values(Bg).includes(t)}function HEt(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(VEt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function WEt(t,s){var r=li({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=li(li({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function GEt(t,s,r){var n,a,o,l=Ll(),i=mbe(),d=zEt(t,s),u=qEt(t,d),f=UEt(),g=!!(l.onDayClick||l.mode!=="default");M.useEffect(function(){var F;d.outside||i.focusedDay&&g&&ll(i.focusedDay,t)&&((F=r.current)===null||F===void 0||F.focus())},[i.focusedDay,t,r,g,d.outside]);var v=HEt(l,d).join(" "),_=WEt(l,d),b=!!(d.outside&&!l.showOutsideDays||d.hidden),w=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:pEt,j=e.jsx(w,{date:t,displayMonth:s,activeModifiers:d}),N={style:_,className:v,children:j,role:"gridcell"},S=i.focusTarget&&ll(i.focusTarget,t)&&!d.outside,A=i.focusedDay&&ll(i.focusedDay,t),I=li(li(li({},N),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=A||S?0:-1,n)),u),L={isButton:g,isHidden:b,activeModifiers:d,selectedDays:f,buttonProps:I,divProps:N};return L}function KEt(t){var s=M.useRef(null),r=GEt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(nae,li({name:"day",ref:s},r.buttonProps)):e.jsx("div",li({},r.divProps))}function ZEt(t){var s=t.number,r=t.dates,n=Ll(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,d=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,f=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:f});var g=d(Number(s),{locale:i}),v=function(_){a(s,r,_)};return e.jsx(nae,{name:"week-number","aria-label":g,className:l.weeknumber,style:o.weeknumber,onClick:v,children:f})}function YEt(t){var s,r,n=Ll(),a=n.styles,o=n.classNames,l=n.showWeekNumber,i=n.components,d=(s=i==null?void 0:i.Day)!==null&&s!==void 0?s:KEt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:ZEt,f;return l&&(f=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:[f,t.dates.map(function(g){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(d,{displayMonth:t.displayMonth,date:g})},Pvt(g))})]})}function rTe(t,s,r){for(var n=r!=null&&r.ISOWeek?d9e(s):xoe(s,r),a=r!=null&&r.ISOWeek?z0(t):Ju(t,r),o=op(n,a),l=[],i=0;i<=o;i++)l.push(hl(a,i));var d=l.reduce(function(u,f){var g=r!=null&&r.ISOWeek?F1e(f):B1e(f,r),v=u.find(function(_){return _.weekNumber===g});return v?(v.dates.push(f),u):(u.push({weekNumber:g,dates:[f]}),u)},[]);return d}function XEt(t,s){var r=rTe(Bh(t),dL(t),s);if(s!=null&&s.useFixedWeeks){var n=Lvt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=vk(o,6-n),i=rTe(vk(o,1),l,s);r.push.apply(r,i)}}return r}function QEt(t){var s,r,n,a=Ll(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,u=a.fixedWeeks,f=a.components,g=a.weekStartsOn,v=a.firstWeekContainsDate,_=a.ISOWeek,b=XEt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:g,firstWeekContainsDate:v}),w=(s=f==null?void 0:f.Head)!==null&&s!==void 0?s:mEt,j=(r=f==null?void 0:f.Row)!==null&&r!==void 0?r:YEt,N=(n=f==null?void 0:f.Footer)!==null&&n!==void 0?n:dEt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!d&&e.jsx(w,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:b.map(function(S){return e.jsx(j,{displayMonth:t.displayMonth,dates:S.dates,weekNumber:S.weekNumber},S.weekNumber)})}),e.jsx(N,{displayMonth:t.displayMonth})]})}function JEt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var ePt=JEt()?M.useLayoutEffect:M.useEffect,ume=!1,tPt=0;function nTe(){return"react-day-picker-".concat(++tPt)}function sPt(t){var s,r=t??(ume?nTe():null),n=M.useState(r),a=n[0],o=n[1];return ePt(function(){a===null&&o(nTe())},[]),M.useEffect(function(){ume===!1&&(ume=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function rPt(t){var s,r,n=Ll(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=jL().displayMonths,u=sPt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),f=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,g=[o.month],v=l.month,_=t.displayIndex===0,b=t.displayIndex===d.length-1,w=!_&&!b;a==="rtl"&&(s=[_,b],b=s[0],_=s[1]),_&&(g.push(o.caption_start),v=li(li({},v),l.caption_start)),b&&(g.push(o.caption_end),v=li(li({},v),l.caption_end)),w&&(g.push(o.caption_between),v=li(li({},v),l.caption_between));var j=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:cEt;return e.jsxs("div",{className:g.join(" "),style:v,children:[e.jsx(j,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(QEt,{id:f,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function nPt(t){var s=Ll(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function aPt(t){var s,r,n=t.initialProps,a=Ll(),o=mbe(),l=jL(),i=M.useState(!1),d=i[0],u=i[1];M.useEffect(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var f=[a.classNames.root,a.className];a.numberOfMonths>1&&f.push(a.classNames.multiple_months),a.showWeekNumber&&f.push(a.classNames.with_weeknumber);var g=li(li({},a.styles.root),a.style),v=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,w){var j;return li(li({},b),(j={},j[w]=n[w],j))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:nPt;return e.jsx("div",li({className:f.join(" "),style:g,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},v,{children:e.jsx(_,{children:l.displayMonths.map(function(b,w){return e.jsx(rPt,{displayIndex:w,displayMonth:b},w)})})}))}function iPt(t){var s=t.children,r=AAt(t,["children"]);return e.jsx(ZAt,{initialProps:r,children:e.jsx(aEt,{children:e.jsx(BEt,{initialProps:r,children:e.jsx(fEt,{initialProps:r,children:e.jsx(yEt,{initialProps:r,children:e.jsx(SEt,{children:e.jsx(FEt,{children:s})})})})})})})}function oPt(t){return e.jsx(iPt,li({},t,{children:e.jsx(aPt,{initialProps:t})}))}function xp({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(oPt,{showOutsideDays:r,className:It("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:It(TI({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:It(TI({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(ec,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(ei,{className:"h-4 w-4"})},...n})}xp.displayName="Calendar";var rle="Popover",[UHe]=Cc(rle,[iy]),kL=iy(),[lPt,B_]=UHe(rle),VHe=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=kL(s),d=M.useRef(null),[u,f]=M.useState(!1),[g,v]=uu({prop:n,defaultProp:a??!1,onChange:o,caller:rle});return e.jsx(Y6,{...i,children:e.jsx(lPt,{scope:s,contentId:Bd(),triggerRef:d,open:g,onOpenChange:v,onOpenToggle:M.useCallback(()=>v(_=>!_),[v]),hasCustomAnchor:u,onCustomAnchorAdd:M.useCallback(()=>f(!0),[]),onCustomAnchorRemove:M.useCallback(()=>f(!1),[]),modal:l,children:r})})};VHe.displayName=rle;var HHe="PopoverAnchor",cPt=M.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=B_(HHe,r),o=kL(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return M.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(J3,{...o,...n,ref:s})});cPt.displayName=HHe;var WHe="PopoverTrigger",GHe=M.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=B_(WHe,r),o=kL(r),l=Sa(s,a.triggerRef),i=e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":QHe(a.open),...n,ref:l,onClick:Sr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(J3,{asChild:!0,...o,children:i})});GHe.displayName=WHe;var fbe="PopoverPortal",[dPt,uPt]=UHe(fbe,{forceMount:void 0}),KHe=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=B_(fbe,s);return e.jsx(dPt,{scope:s,forceMount:r,children:e.jsx(od,{present:r||o.open,children:e.jsx(Z3,{asChild:!0,container:a,children:n})})})};KHe.displayName=fbe;var g3="PopoverContent",ZHe=M.forwardRef((t,s)=>{const r=uPt(g3,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=B_(g3,t.__scopePopover);return e.jsx(od,{present:n||o.open,children:o.modal?e.jsx(mPt,{...a,ref:s}):e.jsx(pPt,{...a,ref:s})})});ZHe.displayName=g3;var hPt=m_("PopoverContent.RemoveScroll"),mPt=M.forwardRef((t,s)=>{const r=B_(g3,t.__scopePopover),n=M.useRef(null),a=Sa(s,n),o=M.useRef(!1);return M.useEffect(()=>{const l=n.current;if(l)return eoe(l)},[]),e.jsx(sL,{as:hPt,allowPinchZoom:!0,children:e.jsx(YHe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Sr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Sr(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,d=i.button===0&&i.ctrlKey===!0,u=i.button===2||d;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Sr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),pPt=M.forwardRef((t,s)=>{const r=B_(g3,t.__scopePopover),n=M.useRef(!1),a=M.useRef(!1);return e.jsx(YHe,{...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 d,u;(d=t.onInteractOutside)==null||d.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()}})}),YHe=M.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,...g}=t,v=B_(g3,r),_=kL(r);return Xie(),e.jsx(eL,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(C_,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:f,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>v.onOpenChange(!1),children:e.jsx(X6,{"data-state":QHe(v.open),role:"dialog",id:v.contentId,..._,...g,ref:s,style:{...g.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)"}})})})}),XHe="PopoverClose",fPt=M.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=B_(XHe,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Sr(t.onClick,()=>a.onOpenChange(!1))})});fPt.displayName=XHe;var gPt="PopoverArrow",xPt=M.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=kL(r);return e.jsx(Q6,{...a,...n,ref:s})});xPt.displayName=gPt;function QHe(t){return t?"open":"closed"}var yPt=VHe,vPt=GHe,_Pt=KHe,JHe=ZHe;const No=yPt,So=vPt,jo=M.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(_Pt,{children:e.jsx(JHe,{ref:a,align:s,sideOffset:r,className:It("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));jo.displayName=JHe.displayName;const bPt=VN("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"}}),gbe=M.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:It(bPt({variant:s}),t),...r}));gbe.displayName="Alert";const wPt=M.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:It("mb-1 font-medium leading-none tracking-tight",t),...s}));wPt.displayName="AlertTitle";const xbe=M.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("text-sm [&_p]:leading-relaxed",t),...s}));xbe.displayName="AlertDescription";function jPt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=ds(),[d,u]=M.useState(a),[f,g]=M.useState([]),[v,_]=M.useState(null),[b,w]=M.useState("now"),[j,N]=M.useState(g5e(w5e(new Date),1)),[S,A]=M.useState("12"),[I,L]=M.useState("00"),[F,$]=M.useState("PM");M.useEffect(()=>{if(t){u(a),w("now"),g([]);const ke=g5e(w5e(new Date),1);N(ke);const Ge=ke.getHours();A(String(Ge>12?Ge-12:Ge===0?12:Ge)),L("00"),$(Ge>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!j)return null;let ke=parseInt(S);const Ge=parseInt(I);return F==="PM"&&ke!==12&&(ke+=12),F==="AM"&&ke===12&&(ke=0),TP(MP(j,ke),Ge)},{data:H,isLoading:U}=Tt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:ke}}=await K.auth.getUser();if(!ke)return[];const{data:Ge,error:Ne}=await K.from("social_accounts").select("*").eq("user_id",ke.id).eq("is_active",!0).order("platform",{ascending:!0});if(Ne)throw Ne;return console.log("Fetched social accounts for posting:",Ge),Ge},enabled:t,staleTime:0}),Q=Bt({mutationFn:async({accountId:ke,platform:Ge})=>{_(ke);const{data:Ne,error:Ae}=await K.functions.invoke("social-post",{body:{platform:Ge,accountId:ke,imageUrl:r,caption:d}});if(Ae)throw Ae;if(Ne!=null&&Ne.error)throw new Error(Ne.error);return Ne},onSuccess:ke=>{const Ge=ke.platform==="facebook"?"Facebook":ke.platform==="instagram"?"Instagram":ke.platform==="linkedin"?"LinkedIn":"Google Business";ge.success(`Posted to ${Ge}!`)},onError:ke=>{ge.error(`Failed to post: ${ke.message}`)},onSettled:()=>{_(null)}}),se=Bt({mutationFn:async({accountId:ke,platform:Ge,scheduledFor:Ne})=>{const{data:{user:Ae}}=await K.auth.getUser();if(!Ae)throw new Error("Not authenticated");const{error:Pe}=await K.from("scheduled_posts").insert({user_id:Ae.id,social_account_id:ke,platform:Ge,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:Ne.toISOString(),status:"scheduled"});if(Pe)throw Pe;return{platform:Ge}},onSuccess:ke=>{const Ge=ke.platform==="facebook"?"Facebook":ke.platform==="instagram"?"Instagram":"LinkedIn";ge.success(`Post scheduled for ${Ge}!`)},onError:ke=>{ge.error(`Failed to schedule: ${ke.message}`)}}),te=async()=>{if(f.length===0){ge.error("Please select at least one account");return}if(b==="schedule"){const ke=q();if(!ke||ke<=new Date){ge.error("Please select a future date and time");return}for(const Ge of f){const Ne=H==null?void 0:H.find(Ae=>Ae.id===Ge);Ne&&await se.mutateAsync({accountId:Ge,platform:Ne.platform,scheduledFor:ke})}i.invalidateQueries({queryKey:["scheduled-posts"]}),ge.success(`${f.length} post(s) scheduled for ${js(ke,"PPp")}`)}else for(const ke of f){const Ge=H==null?void 0:H.find(Ne=>Ne.id===ke);Ge&&await Q.mutateAsync({accountId:ke,platform:Ge.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),g([]),s(!1)},Y=ke=>{g(Ge=>Ge.includes(ke)?Ge.filter(Ne=>Ne!==ke):[...Ge,ke])},ce=(H==null?void 0:H.filter(ke=>ke.platform==="facebook"))||[],oe=(H==null?void 0:H.filter(ke=>ke.platform==="instagram"))||[],le=(H==null?void 0:H.filter(ke=>ke.platform==="linkedin"))||[],de=(H==null?void 0:H.filter(ke=>ke.platform==="google_business"))||[],xe=((H==null?void 0:H.length)||0)>0,be=Q.isPending||se.isPending,ye=Array.from({length:12},(ke,Ge)=>String(Ge+1)),ve=["00","15","30","45"];return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create Social Post"}),e.jsx(Kr,{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(_e,{htmlFor:"caption",children:"Caption"}),e.jsx(Lr,{id:"caption",placeholder:"Write a caption for your post...",value:d,onChange:ke=>u(ke.target.value),rows:3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.length,"/2200 characters"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Publish Time"}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>w("now"),className:It("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>w("schedule"),className:It("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),b==="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(Tn,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("justify-start text-left font-normal flex-1",!j&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),j?js(j,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:j,onSelect:N,disabled:ke=>kee.jsx(At,{value:ke,children:ke},ke))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(tr,{value:I,onValueChange:L,children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(rr,{})}),e.jsx(er,{children:ve.map(ke=>e.jsx(At,{value:ke,children:ke},ke))})]}),e.jsxs(tr,{value:F,onValueChange:ke=>$(ke),children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"AM",children:"AM"}),e.jsx(At,{value:"PM",children:"PM"})]})]})]})]}),j&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",js(q()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Post to"}),U&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin"})}),!U&&!xe&&e.jsxs(gbe,{children:[e.jsx(Yo,{className:"h-4 w-4"}),e.jsxs(xbe,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(yo,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(Pl,{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(Fd,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),ce.map(ke=>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($o,{checked:f.includes(ke.id),onCheckedChange:()=>Y(ke.id),disabled:v===ke.id}),e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:ke.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(Fd,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:ke.page_name||ke.platform_username}),v===ke.id&&e.jsx(Rs,{className:"h-4 w-4 animate-spin"})]},ke.id))]}),oe.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(zd,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),oe.map(ke=>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($o,{checked:f.includes(ke.id),onCheckedChange:()=>Y(ke.id),disabled:v===ke.id}),e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:ke.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(zd,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",ke.platform_username]}),v===ke.id&&e.jsx(Rs,{className:"h-4 w-4 animate-spin"})]},ke.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(Cm,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),le.map(ke=>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($o,{checked:f.includes(ke.id),onCheckedChange:()=>Y(ke.id),disabled:v===ke.id}),e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:ke.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(Cm,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:ke.platform_username}),v===ke.id&&e.jsx(Rs,{className:"h-4 w-4 animate-spin"})]},ke.id))]}),de.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(Pi,{className:"h-4 w-4 text-red-600"})," Google Business"]}),de.map(ke=>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($o,{checked:f.includes(ke.id),onCheckedChange:()=>Y(ke.id),disabled:v===ke.id}),e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:ke.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(Pi,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:ke.page_name||ke.platform_username}),v===ke.id&&e.jsx(Rs,{className:"h-4 w-4 animate-spin"})]},ke.id))]})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{onClick:te,disabled:f.length===0||be,className:"gap-2",children:[be?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(nn,{className:"h-4 w-4"}):e.jsx(Pa,{className:"h-4 w-4"}),b==="schedule"?`Schedule ${f.length} post${f.length!==1?"s":""}`:`Post to ${f.length} account${f.length!==1?"s":""}`]})]})]})})}function kPt(){const t=ds(),[s,r]=M.useState(void 0),[n,a]=M.useState("all"),[o,l]=M.useState(null),[i,d]=M.useState(""),[u,f]=M.useState(void 0),[g,v]=M.useState("12"),[_,b]=M.useState("00"),[w,j]=M.useState("PM"),{data:N=[],isLoading:S}=Tt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:de,error:xe}=await K.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(xe)throw xe;return de}}),A=N.filter(de=>{if(n!=="all"&&de.status!==n)return!1;if(s&&de.scheduled_for){const xe=new Date(de.scheduled_for);if(!ll(xe,s))return!1}return!0}),I=N.filter(de=>de.scheduled_for).map(de=>qh(new Date(de.scheduled_for))),L=Bt({mutationFn:async de=>{const{error:xe}=await K.from("scheduled_posts").update({caption:de.caption,scheduled_for:de.scheduled_for}).eq("id",de.id);if(xe)throw xe},onSuccess:()=>{ge.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:de=>{ge.error(`Failed to update: ${de.message}`)}}),F=Bt({mutationFn:async de=>{const{error:xe}=await K.from("scheduled_posts").update({status:"cancelled"}).eq("id",de);if(xe)throw xe},onSuccess:()=>{ge.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:de=>{ge.error(`Failed to cancel: ${de.message}`)}}),$=Bt({mutationFn:async de=>{const{error:xe}=await K.from("scheduled_posts").delete().eq("id",de);if(xe)throw xe},onSuccess:()=>{ge.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:de=>{ge.error(`Failed to delete: ${de.message}`)}}),q=Bt({mutationFn:async de=>{const{data:xe,error:be}=await K.functions.invoke("social-post",{body:{platform:de.platform,accountId:de.social_account_id,imageUrl:de.image_url,caption:de.caption}});if(be)throw be;if(xe!=null&&xe.error)throw new Error(xe.error);return await K.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:xe.postId}).eq("id",de.id),xe},onSuccess:de=>{const xe=de.platform==="facebook"?"Facebook":de.platform==="instagram"?"Instagram":"LinkedIn";ge.success(`Posted to ${xe}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:de=>{ge.error(`Failed to post: ${de.message}`)}}),H=de=>{if(l(de),d(de.caption||""),de.scheduled_for){const xe=new Date(de.scheduled_for);f(xe);const be=xe.getHours();v(String(be>12?be-12:be===0?12:be)),b(String(xe.getMinutes()).padStart(2,"0")),j(be>=12?"PM":"AM")}},U=()=>{if(!o||!u)return;let de=parseInt(g);const xe=parseInt(_);w==="PM"&&de!==12&&(de+=12),w==="AM"&&de===12&&(de=0);const be=TP(MP(u,de),xe);L.mutate({id:o.id,caption:i,scheduled_for:be.toISOString()})},Q=de=>{switch(de){case"facebook":return e.jsx(Fd,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(zd,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(Cm,{className:"h-4 w-4 text-blue-700"});default:return null}},se=de=>{switch(de){case"scheduled":return e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(nt,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(hi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(nt,{variant:"destructive",className:"gap-1",children:[e.jsx(bc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(nt,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Yo,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(nt,{variant:"outline",children:de})}},te=Array.from({length:12},(de,xe)=>String(xe+1)),Y=["00","15","30","45"],ce=N.filter(de=>de.status==="scheduled").length,oe=N.filter(de=>de.status==="posted").length,le=N.filter(de=>de.status==="scheduled"&&de.scheduled_for&&Dvt(new Date(de.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(De,{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(De,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:le}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(De,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:oe}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(De,{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(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(jc,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(xp,{mode:"single",selected:s,onSelect:r,className:It("pointer-events-auto"),modifiers:{hasPost:I},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(Z,{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(y0,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(de=>e.jsx(Z,{variant:n===de?"default":"outline",size:"sm",onClick:()=>a(de),className:"capitalize",children:de},de))})]}),S&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Rs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!S&&A.length===0&&e.jsxs(De,{className:"p-8 text-center",children:[e.jsx(nn,{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 ${js(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:A.map(de=>{var xe,be;return e.jsx(De,{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:de.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(Oe,{className:"flex-1 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Q(de.platform),e.jsx("span",{className:"font-medium",children:((xe=de.social_accounts)==null?void 0:xe.page_name)||((be=de.social_accounts)==null?void 0:be.platform_username)||"Unknown"}),se(de.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[de.status==="scheduled"&&e.jsxs(HN,{children:[e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>H(de),children:e.jsx(Ga,{className:"h-4 w-4"})})}),e.jsx(au,{children:"Edit post"})]}),e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>q.mutate(de),disabled:q.isPending,children:q.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(Pa,{className:"h-4 w-4"})})}),e.jsx(au,{children:"Post now"})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Cancel this scheduled post?"}),e.jsx(Xl,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Keep"}),e.jsx(Ml,{onClick:()=>F.mutate(de.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(Ml,{onClick:()=>$.mutate(de.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(de.status==="posted"||de.status==="cancelled"||de.status==="failed")&&e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete this post?"}),e.jsx(Xl,{children:"This will permanently remove this post from your history."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>$.mutate(de.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),de.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:de.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),de.status==="posted"&&de.posted_at?`Posted ${js(new Date(de.posted_at),"PPp")}`:de.scheduled_for?`Scheduled for ${js(new Date(de.scheduled_for),"PPp")}`:"Not scheduled"]}),de.status==="failed"&&de.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",de.error_message]})]})]})},de.id)})})]})]}),e.jsx(bs,{open:!!o,onOpenChange:de=>!de&&l(null),children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Scheduled Post"}),e.jsx(Kr,{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(_e,{children:"Caption"}),e.jsx(Lr,{value:i,onChange:de=>d(de.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(_e,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),u?js(u,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:u,onSelect:f,disabled:de=>dee.jsx(At,{value:de,children:de},de))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(rr,{})}),e.jsx(er,{children:Y.map(de=>e.jsx(At,{value:de,children:de},de))})]}),e.jsxs(tr,{value:w,onValueChange:de=>j(de),children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"AM",children:"AM"}),e.jsx(At,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(Z,{onClick:U,disabled:L.isPending,children:[L.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function R8(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 eWe={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,f){if(!a[u]){if(!n[u]){var g=typeof R8=="function"&&R8;if(!f&&g)return g(u,!0);if(i)return i(u,!0);var v=new Error("Cannot find module '"+u+"'");throw v.code="MODULE_NOT_FOUND",v}var _=a[u]={exports:{}};n[u][0].call(_.exports,function(b){var w=n[u][1][b];return l(w||b)},_,_.exports,r,n,a,o)}return a[u].exports}for(var i=typeof R8=="function"&&R8,d=0;d>2,_=(3&u)<<4|f>>4,b=1>6:64,w=2>4,f=(15&v)<<4|(_=i.indexOf(d.charAt(w++)))>>2,g=(3&_)<<6|(b=i.indexOf(d.charAt(w++))),S[j++]=u,_!==64&&(S[j++]=f),b!==64&&(S[j++]=g);return S}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),d=r("./stream/DataLengthProbe");function u(f,g,v,_,b){this.compressedSize=f,this.uncompressedSize=g,this.crc32=v,this.compression=_,this.compressedContent=b}u.prototype={getContentWorker:function(){var f=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new d("data_length")),g=this;return f.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),f},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(f,g,v){return f.pipe(new i).pipe(new d("uncompressedSize")).pipe(g.compressWorker(v)).pipe(new d("compressedSize")).withStreamInfo("compression",g)},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,d=[],u=0;u<256;u++){i=u;for(var f=0;f<8;f++)i=1&i?3988292384^i>>>1:i>>>1;d[u]=i}return d}();n.exports=function(i,d){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(u,f,g,v){var _=l,b=v+g;u^=-1;for(var w=v;w>>8^_[255&(u^f[w])];return-1^u}(0|d,i,i.length,0):function(u,f,g,v){var _=l,b=v+g;u^=-1;for(var w=v;w>>8^_[255&(u^f.charCodeAt(w))];return-1^u}(0|d,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"),d=r("./stream/GenericWorker"),u=o?"uint8array":"array";function f(g,v){d.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=v,this.meta={}}a.magic="\b\0",i.inherits(f,d),f.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,g.data),!1)},f.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},f.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(v){g.push({data:v,meta:g.meta})}},a.compressWorker=function(g){return new f("Deflate",g)},a.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(_,b){var w,j="";for(w=0;w>>=8;return j}function l(_,b,w,j,N,S){var A,I,L=_.file,F=_.compression,$=S!==u.utf8encode,q=i.transformTo("string",S(L.name)),H=i.transformTo("string",u.utf8encode(L.name)),U=L.comment,Q=i.transformTo("string",S(U)),se=i.transformTo("string",u.utf8encode(U)),te=H.length!==L.name.length,Y=se.length!==U.length,ce="",oe="",le="",de=L.dir,xe=L.date,be={crc32:0,compressedSize:0,uncompressedSize:0};b&&!w||(be.crc32=_.crc32,be.compressedSize=_.compressedSize,be.uncompressedSize=_.uncompressedSize);var ye=0;b&&(ye|=8),$||!te&&!Y||(ye|=2048);var ve=0,ke=0;de&&(ve|=16),N==="UNIX"?(ke=798,ve|=function(Ne,Ae){var Pe=Ne;return Ne||(Pe=Ae?16893:33204),(65535&Pe)<<16}(L.unixPermissions,de)):(ke=20,ve|=function(Ne){return 63&(Ne||0)}(L.dosPermissions)),A=xe.getUTCHours(),A<<=6,A|=xe.getUTCMinutes(),A<<=5,A|=xe.getUTCSeconds()/2,I=xe.getUTCFullYear()-1980,I<<=4,I|=xe.getUTCMonth()+1,I<<=5,I|=xe.getUTCDate(),te&&(oe=o(1,1)+o(f(q),4)+H,ce+="up"+o(oe.length,2)+oe),Y&&(le=o(1,1)+o(f(Q),4)+se,ce+="uc"+o(le.length,2)+le);var Ge="";return Ge+=` \0`,Ge+=o(ye,2),Ge+=F.magic,Ge+=o(A,2),Ge+=o(I,2),Ge+=o(be.crc32,4),Ge+=o(be.compressedSize,4),Ge+=o(be.uncompressedSize,4),Ge+=o(q.length,2),Ge+=o(ce.length,2),{fileRecord:g.LOCAL_FILE_HEADER+Ge+q+ce,dirRecord:g.CENTRAL_FILE_HEADER+o(ke,2)+Ge+o(Q.length,2)+"\0\0\0\0"+o(ve,4)+o(j,4)+q+ce+Q}}var i=r("../utils"),d=r("../stream/GenericWorker"),u=r("../utf8"),f=r("../crc32"),g=r("../signature");function v(_,b,w,j){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=w,this.encodeFileName=j,this.streamFiles=_,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(v,d),v.prototype.push=function(_){var b=_.meta.percent||0,w=this.entriesCount,j=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,d.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:w?(b+100*(w-j-1))/w:100}}))},v.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var b=this.streamFiles&&!_.file.dir;if(b){var w=l(_,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:w.fileRecord,meta:{percent:0}})}else this.accumulate=!0},v.prototype.closedSource=function(_){this.accumulate=!1;var b=this.streamFiles&&!_.file.dir,w=l(_,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(w.dirRecord),b)this.push({data:function(j){return g.DATA_DESCRIPTOR+o(j.crc32,4)+o(j.compressedSize,4)+o(j.uncompressedSize,4)}(_),meta:{percent:100}});else for(this.push({data:w.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},v.prototype.flush=function(){for(var _=this.bytesWritten,b=0;b=this.index;d--)u=(u<<8)+this.byteAt(d);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 d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},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 d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},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 d=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,a){var o=r("../utils"),l=r("../support"),i=r("./ArrayReader"),d=r("./StringReader"),u=r("./NodeBufferReader"),f=r("./Uint8ArrayReader");n.exports=function(g){var v=o.getTypeOf(g);return o.checkSupport(v),v!=="string"||l.uint8array?v==="nodebuffer"?new u(g):l.uint8array?new f(o.transformTo("uint8array",g)):new i(o.transformTo("array",g)):new d(g)}},{"../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(d){o.call(this,"ConvertWorker to "+d),this.destType=d}l.inherits(i,o),i.prototype.processChunk=function(d){this.push({data:l.transformTo(this.destType,d.data),meta:d.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(d){this.streamInfo.crc32=l(d.data,this.streamInfo.crc32||0),this.push(d)},n.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(d){l.call(this,"DataLengthProbe for "+d),this.propName=d,this.withStreamInfo(d,0)}o.inherits(i,l),i.prototype.processChunk=function(d){if(d){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+d.data.length}l.prototype.processChunk.call(this,d)},n.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(d){l.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,d.then(function(f){u.dataIsReady=!0,u.data=f,u.max=f&&f.length||0,u.type=o.getTypeOf(f),u.isPaused||u._tickAndRepeat()},function(f){u.error(f)})}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 d=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":d=this.data.substring(this.index,u);break;case"uint8array":d=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":d=this.data.slice(this.index,u)}return this.index=u,this.push({data:d,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 d=0;d "+l:l}},n.exports=o},{}],29:[function(r,n,a){var o=r("../utils"),l=r("./ConvertWorker"),i=r("./GenericWorker"),d=r("../base64"),u=r("../support"),f=r("../external"),g=null;if(u.nodestream)try{g=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function v(b,w){return new f.Promise(function(j,N){var S=[],A=b._internalType,I=b._outputType,L=b._mimeType;b.on("data",function(F,$){S.push(F),w&&w($)}).on("error",function(F){S=[],N(F)}).on("end",function(){try{var F=function($,q,H){switch($){case"blob":return o.newBlob(o.transformTo("arraybuffer",q),H);case"base64":return d.encode(q);default:return o.transformTo($,q)}}(I,function($,q){var H,U=0,Q=null,se=0;for(H=0;H"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"),d=r("./stream/GenericWorker"),u=new Array(256),f=0;f<256;f++)u[f]=252<=f?6:248<=f?5:240<=f?4:224<=f?3:192<=f?2:1;u[254]=u[254]=1;function g(){d.call(this,"utf-8 decode"),this.leftOver=null}function v(){d.call(this,"utf-8 encode")}a.utf8encode=function(_){return l.nodebuffer?i.newBufferFrom(_,"utf-8"):function(b){var w,j,N,S,A,I=b.length,L=0;for(S=0;S>>6:(j<65536?w[A++]=224|j>>>12:(w[A++]=240|j>>>18,w[A++]=128|j>>>12&63),w[A++]=128|j>>>6&63),w[A++]=128|63&j);return w}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(b){var w,j,N,S,A=b.length,I=new Array(2*A);for(w=j=0;w>10&1023,I[j++]=56320|1023&N)}return I.length!==j&&(I.subarray?I=I.subarray(0,j):I.length=j),o.applyFromCharCode(I)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(g,d),g.prototype.processChunk=function(_){var b=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var w=b;(b=new Uint8Array(w.length+this.leftOver.length)).set(this.leftOver,0),b.set(w,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var j=function(S,A){var I;for((A=A||S.length)>S.length&&(A=S.length),I=A-1;0<=I&&(192&S[I])==128;)I--;return I<0||I===0?A:I+u[S[I]]>A?I:A}(b),N=b;j!==b.length&&(l.uint8array?(N=b.subarray(0,j),this.leftOver=b.subarray(j,b.length)):(N=b.slice(0,j),this.leftOver=b.slice(j,b.length))),this.push({data:a.utf8decode(N),meta:_.meta})},g.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=g,o.inherits(v,d),v.prototype.processChunk=function(_){this.push({data:a.utf8encode(_.data),meta:_.meta})},a.Utf8EncodeWorker=v},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,a){var o=r("./support"),l=r("./base64"),i=r("./nodejsUtils"),d=r("./external");function u(w){return w}function f(w,j){for(var N=0;N>8;this.dir=!!(16&this.externalFileAttributes),_==0&&(this.dosPermissions=63&this.externalFileAttributes),_==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var _=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=_.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=_.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=_.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=_.readInt(4))}},readExtraFields:function(_){var b,w,j,N=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?v[j++]=224|_>>>12:(v[j++]=240|_>>>18,v[j++]=128|_>>>12&63),v[j++]=128|_>>>6&63),v[j++]=128|63&_);return v},a.buf2binstring=function(g){return f(g,g.length)},a.binstring2buf=function(g){for(var v=new o.Buf8(g.length),_=0,b=v.length;_>10&1023,S[b++]=56320|1023&w)}return f(S,b)},a.utf8border=function(g,v){var _;for((v=v||g.length)>g.length&&(v=g.length),_=v-1;0<=_&&(192&g[_])==128;)_--;return _<0||_===0?v:_+d[g[_]]>v?_:v}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,d){for(var u=65535&o|0,f=o>>>16&65535|0,g=0;i!==0;){for(i-=g=2e3>>1:l>>>1;i[d]=l}return i}();n.exports=function(l,i,d,u){var f=o,g=u+d;l^=-1;for(var v=u;v>>8^f[255&(l^i[v])];return-1^l}},{}],46:[function(r,n,a){var o,l=r("../utils/common"),i=r("./trees"),d=r("./adler32"),u=r("./crc32"),f=r("./messages"),g=0,v=4,_=0,b=-2,w=-1,j=4,N=2,S=8,A=9,I=286,L=30,F=19,$=2*I+1,q=15,H=3,U=258,Q=U+H+1,se=42,te=113,Y=1,ce=2,oe=3,le=4;function de(fe,Qe){return fe.msg=f[Qe],Qe}function xe(fe){return(fe<<1)-(4fe.avail_out&&(at=fe.avail_out),at!==0&&(l.arraySet(fe.output,Qe.pending_buf,Qe.pending_out,at,fe.next_out),fe.next_out+=at,Qe.pending_out+=at,fe.total_out+=at,fe.avail_out-=at,Qe.pending-=at,Qe.pending===0&&(Qe.pending_out=0))}function ve(fe,Qe){i._tr_flush_block(fe,0<=fe.block_start?fe.block_start:-1,fe.strstart-fe.block_start,Qe),fe.block_start=fe.strstart,ye(fe.strm)}function ke(fe,Qe){fe.pending_buf[fe.pending++]=Qe}function Ge(fe,Qe){fe.pending_buf[fe.pending++]=Qe>>>8&255,fe.pending_buf[fe.pending++]=255&Qe}function Ne(fe,Qe){var at,rt,je=fe.max_chain_length,mt=fe.strstart,He=fe.prev_length,ct=fe.nice_match,We=fe.strstart>fe.w_size-Q?fe.strstart-(fe.w_size-Q):0,Ze=fe.window,ht=fe.w_mask,Ke=fe.prev,qe=fe.strstart+U,Je=Ze[mt+He-1],Lt=Ze[mt+He];fe.prev_length>=fe.good_match&&(je>>=2),ct>fe.lookahead&&(ct=fe.lookahead);do if(Ze[(at=Qe)+He]===Lt&&Ze[at+He-1]===Je&&Ze[at]===Ze[mt]&&Ze[++at]===Ze[mt+1]){mt+=2,at++;do;while(Ze[++mt]===Ze[++at]&&Ze[++mt]===Ze[++at]&&Ze[++mt]===Ze[++at]&&Ze[++mt]===Ze[++at]&&Ze[++mt]===Ze[++at]&&Ze[++mt]===Ze[++at]&&Ze[++mt]===Ze[++at]&&Ze[++mt]===Ze[++at]&&mtWe&&--je!=0);return He<=fe.lookahead?He:fe.lookahead}function Ae(fe){var Qe,at,rt,je,mt,He,ct,We,Ze,ht,Ke=fe.w_size;do{if(je=fe.window_size-fe.lookahead-fe.strstart,fe.strstart>=Ke+(Ke-Q)){for(l.arraySet(fe.window,fe.window,Ke,Ke,0),fe.match_start-=Ke,fe.strstart-=Ke,fe.block_start-=Ke,Qe=at=fe.hash_size;rt=fe.head[--Qe],fe.head[Qe]=Ke<=rt?rt-Ke:0,--at;);for(Qe=at=Ke;rt=fe.prev[--Qe],fe.prev[Qe]=Ke<=rt?rt-Ke:0,--at;);je+=Ke}if(fe.strm.avail_in===0)break;if(He=fe.strm,ct=fe.window,We=fe.strstart+fe.lookahead,Ze=je,ht=void 0,ht=He.avail_in,Ze=H)for(mt=fe.strstart-fe.insert,fe.ins_h=fe.window[mt],fe.ins_h=(fe.ins_h<=H&&(fe.ins_h=(fe.ins_h<=H)if(rt=i._tr_tally(fe,fe.strstart-fe.match_start,fe.match_length-H),fe.lookahead-=fe.match_length,fe.match_length<=fe.max_lazy_match&&fe.lookahead>=H){for(fe.match_length--;fe.strstart++,fe.ins_h=(fe.ins_h<=H&&(fe.ins_h=(fe.ins_h<=H&&fe.match_length<=fe.prev_length){for(je=fe.strstart+fe.lookahead-H,rt=i._tr_tally(fe,fe.strstart-1-fe.prev_match,fe.prev_length-H),fe.lookahead-=fe.prev_length-1,fe.prev_length-=2;++fe.strstart<=je&&(fe.ins_h=(fe.ins_h<fe.pending_buf_size-5&&(at=fe.pending_buf_size-5);;){if(fe.lookahead<=1){if(Ae(fe),fe.lookahead===0&&Qe===g)return Y;if(fe.lookahead===0)break}fe.strstart+=fe.lookahead,fe.lookahead=0;var rt=fe.block_start+at;if((fe.strstart===0||fe.strstart>=rt)&&(fe.lookahead=fe.strstart-rt,fe.strstart=rt,ve(fe,!1),fe.strm.avail_out===0)||fe.strstart-fe.block_start>=fe.w_size-Q&&(ve(fe,!1),fe.strm.avail_out===0))return Y}return fe.insert=0,Qe===v?(ve(fe,!0),fe.strm.avail_out===0?oe:le):(fe.strstart>fe.block_start&&(ve(fe,!1),fe.strm.avail_out),Y)}),new Ie(4,4,8,4,Pe),new Ie(4,5,16,8,Pe),new Ie(4,6,32,32,Pe),new Ie(4,4,16,16,Fe),new Ie(8,16,32,32,Fe),new Ie(8,16,128,128,Fe),new Ie(8,32,128,256,Fe),new Ie(32,128,258,1024,Fe),new Ie(32,258,258,4096,Fe)],a.deflateInit=function(fe,Qe){return Rt(fe,Qe,S,15,8,0)},a.deflateInit2=Rt,a.deflateReset=Le,a.deflateResetKeep=dt,a.deflateSetHeader=function(fe,Qe){return fe&&fe.state?fe.state.wrap!==2?b:(fe.state.gzhead=Qe,_):b},a.deflate=function(fe,Qe){var at,rt,je,mt;if(!fe||!fe.state||5>8&255),ke(rt,rt.gzhead.time>>16&255),ke(rt,rt.gzhead.time>>24&255),ke(rt,rt.level===9?2:2<=rt.strategy||rt.level<2?4:0),ke(rt,255&rt.gzhead.os),rt.gzhead.extra&&rt.gzhead.extra.length&&(ke(rt,255&rt.gzhead.extra.length),ke(rt,rt.gzhead.extra.length>>8&255)),rt.gzhead.hcrc&&(fe.adler=u(fe.adler,rt.pending_buf,rt.pending,0)),rt.gzindex=0,rt.status=69):(ke(rt,0),ke(rt,0),ke(rt,0),ke(rt,0),ke(rt,0),ke(rt,rt.level===9?2:2<=rt.strategy||rt.level<2?4:0),ke(rt,3),rt.status=te);else{var He=S+(rt.w_bits-8<<4)<<8;He|=(2<=rt.strategy||rt.level<2?0:rt.level<6?1:rt.level===6?2:3)<<6,rt.strstart!==0&&(He|=32),He+=31-He%31,rt.status=te,Ge(rt,He),rt.strstart!==0&&(Ge(rt,fe.adler>>>16),Ge(rt,65535&fe.adler)),fe.adler=1}if(rt.status===69)if(rt.gzhead.extra){for(je=rt.pending;rt.gzindex<(65535&rt.gzhead.extra.length)&&(rt.pending!==rt.pending_buf_size||(rt.gzhead.hcrc&&rt.pending>je&&(fe.adler=u(fe.adler,rt.pending_buf,rt.pending-je,je)),ye(fe),je=rt.pending,rt.pending!==rt.pending_buf_size));)ke(rt,255&rt.gzhead.extra[rt.gzindex]),rt.gzindex++;rt.gzhead.hcrc&&rt.pending>je&&(fe.adler=u(fe.adler,rt.pending_buf,rt.pending-je,je)),rt.gzindex===rt.gzhead.extra.length&&(rt.gzindex=0,rt.status=73)}else rt.status=73;if(rt.status===73)if(rt.gzhead.name){je=rt.pending;do{if(rt.pending===rt.pending_buf_size&&(rt.gzhead.hcrc&&rt.pending>je&&(fe.adler=u(fe.adler,rt.pending_buf,rt.pending-je,je)),ye(fe),je=rt.pending,rt.pending===rt.pending_buf_size)){mt=1;break}mt=rt.gzindexje&&(fe.adler=u(fe.adler,rt.pending_buf,rt.pending-je,je)),mt===0&&(rt.gzindex=0,rt.status=91)}else rt.status=91;if(rt.status===91)if(rt.gzhead.comment){je=rt.pending;do{if(rt.pending===rt.pending_buf_size&&(rt.gzhead.hcrc&&rt.pending>je&&(fe.adler=u(fe.adler,rt.pending_buf,rt.pending-je,je)),ye(fe),je=rt.pending,rt.pending===rt.pending_buf_size)){mt=1;break}mt=rt.gzindexje&&(fe.adler=u(fe.adler,rt.pending_buf,rt.pending-je,je)),mt===0&&(rt.status=103)}else rt.status=103;if(rt.status===103&&(rt.gzhead.hcrc?(rt.pending+2>rt.pending_buf_size&&ye(fe),rt.pending+2<=rt.pending_buf_size&&(ke(rt,255&fe.adler),ke(rt,fe.adler>>8&255),fe.adler=0,rt.status=te)):rt.status=te),rt.pending!==0){if(ye(fe),fe.avail_out===0)return rt.last_flush=-1,_}else if(fe.avail_in===0&&xe(Qe)<=xe(at)&&Qe!==v)return de(fe,-5);if(rt.status===666&&fe.avail_in!==0)return de(fe,-5);if(fe.avail_in!==0||rt.lookahead!==0||Qe!==g&&rt.status!==666){var ct=rt.strategy===2?function(We,Ze){for(var ht;;){if(We.lookahead===0&&(Ae(We),We.lookahead===0)){if(Ze===g)return Y;break}if(We.match_length=0,ht=i._tr_tally(We,0,We.window[We.strstart]),We.lookahead--,We.strstart++,ht&&(ve(We,!1),We.strm.avail_out===0))return Y}return We.insert=0,Ze===v?(ve(We,!0),We.strm.avail_out===0?oe:le):We.last_lit&&(ve(We,!1),We.strm.avail_out===0)?Y:ce}(rt,Qe):rt.strategy===3?function(We,Ze){for(var ht,Ke,qe,Je,Lt=We.window;;){if(We.lookahead<=U){if(Ae(We),We.lookahead<=U&&Ze===g)return Y;if(We.lookahead===0)break}if(We.match_length=0,We.lookahead>=H&&0We.lookahead&&(We.match_length=We.lookahead)}if(We.match_length>=H?(ht=i._tr_tally(We,1,We.match_length-H),We.lookahead-=We.match_length,We.strstart+=We.match_length,We.match_length=0):(ht=i._tr_tally(We,0,We.window[We.strstart]),We.lookahead--,We.strstart++),ht&&(ve(We,!1),We.strm.avail_out===0))return Y}return We.insert=0,Ze===v?(ve(We,!0),We.strm.avail_out===0?oe:le):We.last_lit&&(ve(We,!1),We.strm.avail_out===0)?Y:ce}(rt,Qe):o[rt.level].func(rt,Qe);if(ct!==oe&&ct!==le||(rt.status=666),ct===Y||ct===oe)return fe.avail_out===0&&(rt.last_flush=-1),_;if(ct===ce&&(Qe===1?i._tr_align(rt):Qe!==5&&(i._tr_stored_block(rt,0,0,!1),Qe===3&&(be(rt.head),rt.lookahead===0&&(rt.strstart=0,rt.block_start=0,rt.insert=0))),ye(fe),fe.avail_out===0))return rt.last_flush=-1,_}return Qe!==v?_:rt.wrap<=0?1:(rt.wrap===2?(ke(rt,255&fe.adler),ke(rt,fe.adler>>8&255),ke(rt,fe.adler>>16&255),ke(rt,fe.adler>>24&255),ke(rt,255&fe.total_in),ke(rt,fe.total_in>>8&255),ke(rt,fe.total_in>>16&255),ke(rt,fe.total_in>>24&255)):(Ge(rt,fe.adler>>>16),Ge(rt,65535&fe.adler)),ye(fe),0=at.w_size&&(mt===0&&(be(at.head),at.strstart=0,at.block_start=0,at.insert=0),Ze=new l.Buf8(at.w_size),l.arraySet(Ze,Qe,ht-at.w_size,at.w_size,0),Qe=Ze,ht=at.w_size),He=fe.avail_in,ct=fe.next_in,We=fe.input,fe.avail_in=ht,fe.next_in=0,fe.input=Qe,Ae(at);at.lookahead>=H;){for(rt=at.strstart,je=at.lookahead-(H-1);at.ins_h=(at.ins_h<>>=H=q>>>24,A-=H,(H=q>>>16&255)===0)ce[f++]=65535&q;else{if(!(16&H)){if(!(64&H)){q=I[(65535&q)+(S&(1<>>=H,A-=H),A<15&&(S+=Y[d++]<>>=H=q>>>24,A-=H,!(16&(H=q>>>16&255))){if(!(64&H)){q=L[(65535&q)+(S&(1<>>=H,A-=H,(H=f-g)>3,S&=(1<<(A-=U<<3))-1,o.next_in=d,o.next_out=f,o.avail_in=d>>24&255)+(se>>>8&65280)+((65280&se)<<8)+((255&se)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function A(se){var te;return se&&se.state?(te=se.state,se.total_in=se.total_out=te.total=0,se.msg="",te.wrap&&(se.adler=1&te.wrap),te.mode=b,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(w),te.distcode=te.distdyn=new o.Buf32(j),te.sane=1,te.back=-1,v):_}function I(se){var te;return se&&se.state?((te=se.state).wsize=0,te.whave=0,te.wnext=0,A(se)):_}function L(se,te){var Y,ce;return se&&se.state?(ce=se.state,te<0?(Y=0,te=-te):(Y=1+(te>>4),te<48&&(te&=15)),te&&(te<8||15=le.wsize?(o.arraySet(le.window,te,Y-le.wsize,le.wsize,0),le.wnext=0,le.whave=le.wsize):(ce<(oe=le.wsize-le.wnext)&&(oe=ce),o.arraySet(le.window,te,Y-ce,oe,le.wnext),(ce-=oe)?(o.arraySet(le.window,te,Y-ce,ce,0),le.wnext=ce,le.whave=le.wsize):(le.wnext+=oe,le.wnext===le.wsize&&(le.wnext=0),le.whave>>8&255,Y.check=i(Y.check,mt,2,0),ve=ye=0,Y.mode=2;break}if(Y.flags=0,Y.head&&(Y.head.done=!1),!(1&Y.wrap)||(((255&ye)<<8)+(ye>>8))%31){se.msg="incorrect header check",Y.mode=30;break}if((15&ye)!=8){se.msg="unknown compression method",Y.mode=30;break}if(ve-=4,fe=8+(15&(ye>>>=4)),Y.wbits===0)Y.wbits=fe;else if(fe>Y.wbits){se.msg="invalid window size",Y.mode=30;break}Y.dmax=1<>8&1),512&Y.flags&&(mt[0]=255&ye,mt[1]=ye>>>8&255,Y.check=i(Y.check,mt,2,0)),ve=ye=0,Y.mode=3;case 3:for(;ve<32;){if(xe===0)break e;xe--,ye+=ce[le++]<>>8&255,mt[2]=ye>>>16&255,mt[3]=ye>>>24&255,Y.check=i(Y.check,mt,4,0)),ve=ye=0,Y.mode=4;case 4:for(;ve<16;){if(xe===0)break e;xe--,ye+=ce[le++]<>8),512&Y.flags&&(mt[0]=255&ye,mt[1]=ye>>>8&255,Y.check=i(Y.check,mt,2,0)),ve=ye=0,Y.mode=5;case 5:if(1024&Y.flags){for(;ve<16;){if(xe===0)break e;xe--,ye+=ce[le++]<>>8&255,Y.check=i(Y.check,mt,2,0)),ve=ye=0}else Y.head&&(Y.head.extra=null);Y.mode=6;case 6:if(1024&Y.flags&&(xe<(Ne=Y.length)&&(Ne=xe),Ne&&(Y.head&&(fe=Y.head.extra_len-Y.length,Y.head.extra||(Y.head.extra=new Array(Y.head.extra_len)),o.arraySet(Y.head.extra,ce,le,Ne,fe)),512&Y.flags&&(Y.check=i(Y.check,ce,Ne,le)),xe-=Ne,le+=Ne,Y.length-=Ne),Y.length))break e;Y.length=0,Y.mode=7;case 7:if(2048&Y.flags){if(xe===0)break e;for(Ne=0;fe=ce[le+Ne++],Y.head&&fe&&Y.length<65536&&(Y.head.name+=String.fromCharCode(fe)),fe&&Ne>9&1,Y.head.done=!0),se.adler=Y.check=0,Y.mode=12;break;case 10:for(;ve<32;){if(xe===0)break e;xe--,ye+=ce[le++]<>>=7&ve,ve-=7&ve,Y.mode=27;break}for(;ve<3;){if(xe===0)break e;xe--,ye+=ce[le++]<>>=1)){case 0:Y.mode=14;break;case 1:if(U(Y),Y.mode=20,te!==6)break;ye>>>=2,ve-=2;break e;case 2:Y.mode=17;break;case 3:se.msg="invalid block type",Y.mode=30}ye>>>=2,ve-=2;break;case 14:for(ye>>>=7&ve,ve-=7&ve;ve<32;){if(xe===0)break e;xe--,ye+=ce[le++]<>>16^65535)){se.msg="invalid stored block lengths",Y.mode=30;break}if(Y.length=65535&ye,ve=ye=0,Y.mode=15,te===6)break e;case 15:Y.mode=16;case 16:if(Ne=Y.length){if(xe>>=5,ve-=5,Y.ndist=1+(31&ye),ye>>>=5,ve-=5,Y.ncode=4+(15&ye),ye>>>=4,ve-=4,286>>=3,ve-=3}for(;Y.have<19;)Y.lens[He[Y.have++]]=0;if(Y.lencode=Y.lendyn,Y.lenbits=7,at={bits:Y.lenbits},Qe=u(0,Y.lens,0,19,Y.lencode,0,Y.work,at),Y.lenbits=at.bits,Qe){se.msg="invalid code lengths set",Y.mode=30;break}Y.have=0,Y.mode=19;case 19:for(;Y.have>>16&255,Ve=65535&je,!((Fe=je>>>24)<=ve);){if(xe===0)break e;xe--,ye+=ce[le++]<>>=Fe,ve-=Fe,Y.lens[Y.have++]=Ve;else{if(Ve===16){for(rt=Fe+2;ve>>=Fe,ve-=Fe,Y.have===0){se.msg="invalid bit length repeat",Y.mode=30;break}fe=Y.lens[Y.have-1],Ne=3+(3&ye),ye>>>=2,ve-=2}else if(Ve===17){for(rt=Fe+3;ve>>=Fe)),ye>>>=3,ve-=3}else{for(rt=Fe+7;ve>>=Fe)),ye>>>=7,ve-=7}if(Y.have+Ne>Y.nlen+Y.ndist){se.msg="invalid bit length repeat",Y.mode=30;break}for(;Ne--;)Y.lens[Y.have++]=fe}}if(Y.mode===30)break;if(Y.lens[256]===0){se.msg="invalid code -- missing end-of-block",Y.mode=30;break}if(Y.lenbits=9,at={bits:Y.lenbits},Qe=u(f,Y.lens,0,Y.nlen,Y.lencode,0,Y.work,at),Y.lenbits=at.bits,Qe){se.msg="invalid literal/lengths set",Y.mode=30;break}if(Y.distbits=6,Y.distcode=Y.distdyn,at={bits:Y.distbits},Qe=u(g,Y.lens,Y.nlen,Y.ndist,Y.distcode,0,Y.work,at),Y.distbits=at.bits,Qe){se.msg="invalid distances set",Y.mode=30;break}if(Y.mode=20,te===6)break e;case 20:Y.mode=21;case 21:if(6<=xe&&258<=be){se.next_out=de,se.avail_out=be,se.next_in=le,se.avail_in=xe,Y.hold=ye,Y.bits=ve,d(se,Ge),de=se.next_out,oe=se.output,be=se.avail_out,le=se.next_in,ce=se.input,xe=se.avail_in,ye=Y.hold,ve=Y.bits,Y.mode===12&&(Y.back=-1);break}for(Y.back=0;Ie=(je=Y.lencode[ye&(1<>>16&255,Ve=65535&je,!((Fe=je>>>24)<=ve);){if(xe===0)break e;xe--,ye+=ce[le++]<>dt)])>>>16&255,Ve=65535&je,!(dt+(Fe=je>>>24)<=ve);){if(xe===0)break e;xe--,ye+=ce[le++]<>>=dt,ve-=dt,Y.back+=dt}if(ye>>>=Fe,ve-=Fe,Y.back+=Fe,Y.length=Ve,Ie===0){Y.mode=26;break}if(32&Ie){Y.back=-1,Y.mode=12;break}if(64&Ie){se.msg="invalid literal/length code",Y.mode=30;break}Y.extra=15&Ie,Y.mode=22;case 22:if(Y.extra){for(rt=Y.extra;ve>>=Y.extra,ve-=Y.extra,Y.back+=Y.extra}Y.was=Y.length,Y.mode=23;case 23:for(;Ie=(je=Y.distcode[ye&(1<>>16&255,Ve=65535&je,!((Fe=je>>>24)<=ve);){if(xe===0)break e;xe--,ye+=ce[le++]<>dt)])>>>16&255,Ve=65535&je,!(dt+(Fe=je>>>24)<=ve);){if(xe===0)break e;xe--,ye+=ce[le++]<>>=dt,ve-=dt,Y.back+=dt}if(ye>>>=Fe,ve-=Fe,Y.back+=Fe,64&Ie){se.msg="invalid distance code",Y.mode=30;break}Y.offset=Ve,Y.extra=15&Ie,Y.mode=24;case 24:if(Y.extra){for(rt=Y.extra;ve>>=Y.extra,ve-=Y.extra,Y.back+=Y.extra}if(Y.offset>Y.dmax){se.msg="invalid distance too far back",Y.mode=30;break}Y.mode=25;case 25:if(be===0)break e;if(Ne=Ge-be,Y.offset>Ne){if((Ne=Y.offset-Ne)>Y.whave&&Y.sane){se.msg="invalid distance too far back",Y.mode=30;break}Ae=Ne>Y.wnext?(Ne-=Y.wnext,Y.wsize-Ne):Y.wnext-Ne,Ne>Y.length&&(Ne=Y.length),Pe=Y.window}else Pe=oe,Ae=de-Y.offset,Ne=Y.length;for(be$?(H=Ae[Pe+j[te]],ve[ke+j[te]]):(H=96,0),S=1<>de)+(A-=S)]=q<<24|H<<16|U|0,A!==0;);for(S=1<>=1;if(S!==0?(ye&=S-1,ye+=S):ye=0,te++,--Ge[se]==0){if(se===ce)break;se=g[v+j[te]]}if(oe>>7)]}function ke(je,mt){je.pending_buf[je.pending++]=255&mt,je.pending_buf[je.pending++]=mt>>>8&255}function Ge(je,mt,He){je.bi_valid>N-He?(je.bi_buf|=mt<>N-je.bi_valid,je.bi_valid+=He-N):(je.bi_buf|=mt<>>=1,He<<=1,0<--mt;);return He>>>1}function Pe(je,mt,He){var ct,We,Ze=new Array(j+1),ht=0;for(ct=1;ct<=j;ct++)Ze[ct]=ht=ht+He[ct-1]<<1;for(We=0;We<=mt;We++){var Ke=je[2*We+1];Ke!==0&&(je[2*We]=Ae(Ze[Ke]++,Ke))}}function Fe(je){var mt;for(mt=0;mt>1;1<=He;He--)dt(je,Ze,He);for(We=qe;He=je.heap[1],je.heap[1]=je.heap[je.heap_len--],dt(je,Ze,1),ct=je.heap[1],je.heap[--je.heap_max]=He,je.heap[--je.heap_max]=ct,Ze[2*We]=Ze[2*He]+Ze[2*ct],je.depth[We]=(je.depth[He]>=je.depth[ct]?je.depth[He]:je.depth[ct])+1,Ze[2*He+1]=Ze[2*ct+1]=We,je.heap[1]=We++,dt(je,Ze,1),2<=je.heap_len;);je.heap[--je.heap_max]=je.heap[1],function(Lt,zt){var is,Kt,Qt,fs,dr,bt,ws=zt.dyn_tree,ir=zt.max_code,Rr=zt.stat_desc.static_tree,oa=zt.stat_desc.has_stree,ri=zt.stat_desc.extra_bits,no=zt.stat_desc.extra_base,Da=zt.stat_desc.max_length,yn=0;for(fs=0;fs<=j;fs++)Lt.bl_count[fs]=0;for(ws[2*Lt.heap[Lt.heap_max]+1]=0,is=Lt.heap_max+1;is>=7;We<_;We++)for(xe[We]=Ze<<7,mt=0;mt<1<>>=1)if(1&Je&&Ke.dyn_ltree[2*qe]!==0)return l;if(Ke.dyn_ltree[18]!==0||Ke.dyn_ltree[20]!==0||Ke.dyn_ltree[26]!==0)return i;for(qe=32;qe>>3,(Ze=je.static_len+3+7>>>3)<=We&&(We=Ze)):We=Ze=He+5,He+4<=We&&mt!==-1?rt(je,mt,He,ct):je.strategy===4||Ze===We?(Ge(je,2+(ct?1:0),3),Le(je,Q,se)):(Ge(je,4+(ct?1:0),3),function(Ke,qe,Je,Lt){var zt;for(Ge(Ke,qe-257,5),Ge(Ke,Je-1,5),Ge(Ke,Lt-4,4),zt=0;zt>>8&255,je.pending_buf[je.d_buf+2*je.last_lit+1]=255&mt,je.pending_buf[je.l_buf+je.last_lit]=255&He,je.last_lit++,mt===0?je.dyn_ltree[2*He]++:(je.matches++,mt--,je.dyn_ltree[2*(Y[He]+g+1)]++,je.dyn_dtree[2*ve(mt)]++),je.last_lit===je.lit_bufsize-1},a._tr_align=function(je){Ge(je,2,3),Ne(je,A,Q),function(mt){mt.bi_valid===16?(ke(mt,mt.bi_buf),mt.bi_buf=0,mt.bi_valid=0):8<=mt.bi_valid&&(mt.pending_buf[mt.pending++]=255&mt.bi_buf,mt.bi_buf>>=8,mt.bi_valid-=8)}(je)}},{"../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 d,u,f,g,v=1,_={},b=!1,w=l.document,j=Object.getPrototypeOf&&Object.getPrototypeOf(l);j=j&&j.setTimeout?j:l,d={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){S(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}}()?(g="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",A,!1):l.attachEvent("onmessage",A),function(I){l.postMessage(g+I,"*")}):l.MessageChannel?((f=new MessageChannel).port1.onmessage=function(I){S(I.data)},function(I){f.port2.postMessage(I)}):w&&"onreadystatechange"in w.createElement("script")?(u=w.documentElement,function(I){var L=w.createElement("script");L.onreadystatechange=function(){S(I),L.onreadystatechange=null,u.removeChild(L),L=null},u.appendChild(L)}):function(I){setTimeout(S,0,I)},j.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var L=new Array(arguments.length-1),F=0;F"u"?o===void 0?this:o:self)}).call(this,typeof a0<"u"?a0:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(eWe);var NPt=eWe.exports;const SPt=vo(NPt);function hme(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 CPt=()=>{const{isAdmin:t}=Qs(),[s,r]=M.useState(null),[n,a]=M.useState(null),[o,l]=M.useState("all"),[i,d]=M.useState(new Set),[u,f]=M.useState(!1),[g,v]=M.useState(!1),[_,b]=M.useState("images"),[w,j]=M.useState(null),{data:N=[],isLoading:S}=Tt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:xe,error:be}=await K.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(be)throw be;return xe}}),{data:A=[]}=Tt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:xe,error:be}=await K.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(be)throw be;return xe}}),{data:I=[]}=Tt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:xe,error:be}=await K.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(be)throw be;return xe}}),{data:L=[]}=Tt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:xe,error:be}=await K.from("social_accounts").select("id, platform").eq("is_active",!0);if(be)throw be;return xe||[]}}),F=L.length>0,$=M.useMemo(()=>o==="all"?null:I.find(xe=>xe.month===o)||null,[o,I]),q=M.useMemo(()=>[...new Set(N.map(be=>be.month))].sort((be,ye)=>ye.localeCompare(be)),[N]);M.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const H=xe=>{try{const be=U1e(xe,"yyyy-MM",new Date);return js(be,"MMMM yyyy")}catch{return xe}},U=M.useMemo(()=>o==="all"?N:N.filter(xe=>xe.month===o),[o,N]),Q=M.useMemo(()=>{var xe;return o==="all"?null:((xe=A.find(be=>be.month===o))==null?void 0:xe.canva_link)||null},[o,A]),se=async xe=>{try{await navigator.clipboard.writeText(xe),ge.success("Caption copied to clipboard!")}catch{ge.error("Failed to copy caption")}},te=async(xe,be)=>{try{const ve=await(await fetch(xe)).blob(),ke=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ge=navigator.canShare&&navigator.canShare({files:[new File([ve],"test.jpg",{type:"image/jpeg"})]});if(ke&&Ge){const Ne=new File([ve],`social-swag-${be}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Ne],title:"Social Swag Image"}),ge.success("Image ready to save!")}else{const Ne=window.URL.createObjectURL(ve),Ae=document.createElement("a");Ae.href=Ne,Ae.download=`social-swag-${be}.jpg`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),window.URL.revokeObjectURL(Ne),ge.success("Image downloaded!")}}catch(ye){ye.name!=="AbortError"&&ge.error("Failed to download image")}},Y=xe=>{d(be=>{const ye=new Set(be);return ye.has(xe)?ye.delete(xe):ye.add(xe),ye})},ce=()=>{d(new Set(U.map(xe=>xe.id)))},oe=()=>{d(new Set),f(!1)},le=async()=>{const xe=U.filter(be=>i.has(be.id));if(xe.length===0){ge.error("No images selected");return}v(!0),ge.info(`Preparing ${xe.length} images for download...`);try{const be=new SPt,ye=[...xe].sort((Ae,Pe)=>Ae.sort_order-Pe.sort_order);for(let Ae=0;Ae{u?Y(xe.id):r(xe)};return e.jsx(Ms,{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(nt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(gn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(nt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Xo,{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(Ia,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(Aa,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(Ts,{value:"gallery",className:"gap-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(Ts,{value:"scheduled",className:"gap-2",children:[e.jsx(jc,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(Vs,{value:"gallery",className:"space-y-6",children:[t?F?e.jsx(De,{className:"border rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),e.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),e.jsx(Z,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(yo,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(De,{className:"border-2 border-dashed border-primary/30 bg-gradient-to-r from-pink-500/5 via-purple-500/5 to-blue-500/5 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Fd,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(zd,{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(Z,{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(yo,{to:"/social-connections",children:[e.jsx(Al,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(De,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Fd,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(zd,{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(nt,{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:q.map(xe=>e.jsx("button",{onClick:()=>l(xe),className:It("px-4 py-2 rounded-full text-sm font-medium transition-all",o===xe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:H(xe)},xe))}),o!=="all"&&(Q?e.jsxs("a",{href:Q,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 ",H(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 ",H(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:()=>{b("images"),oe()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Xo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),oe()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(eu,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",U.length,")"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:oe,className:"gap-2",children:[e.jsx(Vr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Z,{size:"sm",onClick:le,disabled:g,className:"gap-2",children:[e.jsx(Ei,{className:"h-4 w-4"}),g?"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(Z,{variant:"outline",size:"sm",onClick:()=>f(!0),className:"gap-2",children:[e.jsx(ma,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&_==="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:U.map(xe=>{const be=i.has(xe.id);return e.jsx(De,{className:It("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&be&&"ring-2 ring-primary ring-offset-2"),onClick:()=>de(xe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:hme(xe.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"}),xe.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:js(new Date(xe.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:It("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",be?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:be&&e.jsx(ma,{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"})})]})},xe.id)})}),U.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Xo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(De,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:hme($.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(nt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(eu,{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(eu,{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(bs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(_s,{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:hme(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(nn,{className:"h-4 w-4"}),js(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(nn,{className:"h-3.5 w-3.5"}),"Post on ",js(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(Z,{onClick:()=>{j({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(Pa,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Z,{variant:"outline",onClick:()=>se(s.caption),className:"flex-1 gap-2",children:[e.jsx(Ni,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(Z,{variant:"outline",onClick:()=>te(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Ei,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(bs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(_s,{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(eu,{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(Z,{onClick:()=>se(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Ni,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(Z,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(un,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(jPt,{open:!!w,onOpenChange:xe=>!xe&&j(null),imageUrl:(w==null?void 0:w.imageUrl)||"",imageId:(w==null?void 0:w.imageId)||"",defaultCaption:(w==null?void 0:w.caption)||"",swagItemId:w==null?void 0:w.imageId})]}),e.jsx(Vs,{value:"scheduled",children:e.jsx(kPt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(De,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Fd,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(zd,{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(nt,{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:q.map(xe=>e.jsx("button",{onClick:()=>l(xe),className:It("px-4 py-2 rounded-full text-sm font-medium transition-all",o===xe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:H(xe)},xe))}),o!=="all"&&(Q?e.jsxs("a",{href:Q,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 ",H(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 ",H(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:()=>{b("images"),oe()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Xo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),oe()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(eu,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",U.length,")"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:oe,className:"gap-2",children:[e.jsx(Vr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(Z,{size:"sm",onClick:le,disabled:g,className:"gap-2",children:[e.jsx(Ei,{className:"h-4 w-4"}),g?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>f(!0),className:"gap-2",children:[e.jsx(ma,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&_==="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:U.map(xe=>{const be=i.has(xe.id);return e.jsx(De,{className:It("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&be&&"ring-2 ring-primary ring-offset-2"),onClick:()=>de(xe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:xe.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),u&&e.jsx("div",{className:It("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",be?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:be&&e.jsx(ma,{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"})})]})},xe.id)})}),U.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Xo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(De,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:$.image_url,alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(nt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(eu,{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(eu,{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(bs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(_s,{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(nn,{className:"h-4 w-4"}),js(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(Z,{variant:"outline",onClick:()=>se(s.caption),className:"flex-1 gap-2",children:[e.jsx(Ni,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(Z,{variant:"outline",onClick:()=>te(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Ei,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(bs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(_s,{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(eu,{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(Z,{onClick:()=>se(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Ni,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(Z,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(un,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},MPt=()=>{const{swagId:t}=Uo(),{user:s}=Qs(),{toast:r}=La(),n=ds(),{trackEngagement:a}=_L(),[o,l]=M.useState(""),{data:i,isLoading:d}=Tt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:N,error:S}=await K.from("social_swag").select("*").eq("id",t).single();if(S)throw S;const{data:A}=await K.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...N,links:A||[]}},enabled:!!t});M.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=Tt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:N,error:S}=await K.from("social_swag_likes").select("*").eq("swag_id",t);if(S)throw S;return N},enabled:!!t}),{data:f=[]}=Tt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:N,error:S}=await K.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(S)throw S;const A=[...new Set(N.map(F=>F.user_id))],{data:I}=await K.from("profiles").select("id, name").in("id",A),L=new Map((I==null?void 0:I.map(F=>[F.id,F.name]))||[]);return N.map(F=>({...F,user_name:L.get(F.user_id)||"Unknown User"}))},enabled:!!t}),g=Bt({mutationFn:async N=>{const{error:S}=await K.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:N});if(S)throw S},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"})}}),v=Bt({mutationFn:async N=>{const{error:S}=await K.from("social_swag_comments").delete().eq("id",N);if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Bt({mutationFn:async()=>{const N=u.find(S=>S.user_id===(s==null?void 0:s.id));if(N){const{error:S}=await K.from("social_swag_likes").delete().eq("id",N.id);if(S)throw S}else{const{error:S}=await K.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(S)throw S}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),b=u.some(N=>N.user_id===(s==null?void 0:s.id)),w=N=>N.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=N=>{N.preventDefault(),!(!o.trim()||!s)&&g.mutate(o.trim())};return d?e.jsx(Ms,{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(Ms,{title:i.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Z,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(yo,{to:"/social-swag",children:[e.jsx(Ba,{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(hM,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(Z,{variant:b?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(lu,{className:`h-4 w-4 ${b?"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(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Po,{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(Z,{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(un,{className:"h-4 w-4 text-muted-foreground"})]},N.id))})]})}),e.jsx(Jl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(mc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[e.jsx(Lr,{placeholder:"Add a comment...",value:o,onChange:N=>l(N.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(Z,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||g.isPending,children:e.jsx(Pa,{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(De,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(N=>e.jsx(De,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(mn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(pn,{className:"text-sm",children:w(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(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>v.mutate(N.id),children:e.jsx(Cr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:N.content})]})]})})},N.id))})]})]})}):e.jsx(Ms,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Po,{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(Z,{asChild:!0,className:"mt-4",children:e.jsx(yo,{to:"/social-swag",children:"Back to Social Swag"})})]})})},TPt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=M.useState(!0),[i,d]=M.useState(!0),[u,f]=M.useState(!0),g=v=>v.split(" ").map(_=>_[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(Z,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(e5,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(Eg,{open:o,onOpenChange:l,children:[e.jsx(Pg,{asChild:!0,children:e.jsxs(Z,{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(tl,{className:"h-4 w-4"}):e.jsx(ei,{className:"h-4 w-4"})]})}),e.jsx(Ig,{className:"space-y-1 pl-2",children:t.map(v=>e.jsxs(Z,{variant:r===v.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(v.id),children:[e.jsx("span",{className:"mr-2",children:v.icon||"📂"}),e.jsx("span",{className:"truncate",children:v.name})]},v.id))})]}),s.length>0&&e.jsxs(Eg,{open:i,onOpenChange:d,children:[e.jsx(Pg,{asChild:!0,children:e.jsxs(Z,{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(Pu,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(tl,{className:"h-4 w-4"}):e.jsx(ei,{className:"h-4 w-4"})]})}),e.jsx(Ig,{className:"space-y-1 pl-2",children:s.map(v=>e.jsxs(Z,{variant:r===`group:${v.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${v.id}`),children:[e.jsx("span",{className:"mr-2",children:v.icon||"🔒"}),e.jsx("span",{className:"truncate",children:v.name})]},v.id))})]}),e.jsxs(Eg,{open:u,onOpenChange:f,children:[e.jsx(Pg,{asChild:!0,children:e.jsxs(Z,{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(xr,{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(tl,{className:"h-4 w-4"}):e.jsx(ei,{className:"h-4 w-4"})]})}),e.jsx(Ig,{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(v=>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(mn,{className:"h-7 w-7",children:[e.jsx(ba,{src:v.avatarUrl}),e.jsx(pn,{className:"text-xs",children:g(v.name)})]}),e.jsx(qc,{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:v.name})]},v.id))})]})]})})})},APt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=M.useState(!1),i=u=>u.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),d=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const f=r.replace("group:",""),g=s.find(v=>v.id===f);return g?`🔒 ${g.name}`:"Private Group"}const u=t.find(f=>f.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(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:d()}),e.jsx(tl,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(mu,{className:"w-56 bg-background border",children:[e.jsxs(Wa,{onClick:()=>n("all"),children:[e.jsx(e5,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(g_,{}),e.jsx(hge,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Wa,{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(g_,{}),e.jsxs(hge,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Pu,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Wa,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(uL,{open:o,onOpenChange:l,children:[e.jsx(W1e,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(xr,{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(lM,{children:[e.jsx(hL,{children:e.jsxs(mL,{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Fi,{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(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:u.avatarUrl}),e.jsx(pn,{children:i(u.name)})]}),e.jsx(qc,{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 mme,nle="HoverCard",[tWe]=Cc(nle,[iy]),ale=iy(),[EPt,ybe]=tWe(nle),sWe=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=ale(s),u=M.useRef(0),f=M.useRef(0),g=M.useRef(!1),v=M.useRef(!1),[_,b]=uu({prop:n,defaultProp:a??!1,onChange:o,caller:nle}),w=M.useCallback(()=>{clearTimeout(f.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),j=M.useCallback(()=>{clearTimeout(u.current),!g.current&&!v.current&&(f.current=window.setTimeout(()=>b(!1),i))},[i,b]),N=M.useCallback(()=>b(!1),[b]);return M.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(f.current)},[]),e.jsx(EPt,{scope:s,open:_,onOpenChange:b,onOpen:w,onClose:j,onDismiss:N,hasSelectionRef:g,isPointerDownOnContentRef:v,children:e.jsx(Y6,{...d,children:r})})};sWe.displayName=nle;var rWe="HoverCardTrigger",nWe=M.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=ybe(rWe,r),o=ale(r);return e.jsx(J3,{asChild:!0,...o,children:e.jsx(Qr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Sr(t.onPointerEnter,iae(a.onOpen)),onPointerLeave:Sr(t.onPointerLeave,iae(a.onClose)),onFocus:Sr(t.onFocus,a.onOpen),onBlur:Sr(t.onBlur,a.onClose),onTouchStart:Sr(t.onTouchStart,l=>l.preventDefault())})})});nWe.displayName=rWe;var PPt="HoverCardPortal",[Vvs,IPt]=tWe(PPt,{forceMount:void 0}),aae="HoverCardContent",aWe=M.forwardRef((t,s)=>{const r=IPt(aae,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=ybe(aae,t.__scopeHoverCard);return e.jsx(od,{present:n||o.open,children:e.jsx(LPt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Sr(t.onPointerEnter,iae(o.onOpen)),onPointerLeave:Sr(t.onPointerLeave,iae(o.onClose)),ref:s})})});aWe.displayName=aae;var LPt=M.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=ybe(aae,r),u=ale(r),f=M.useRef(null),g=Sa(s,f),[v,_]=M.useState(!1);return M.useEffect(()=>{if(v){const b=document.body;return mme=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=mme,b.style.webkitUserSelect=mme}}},[v]),M.useEffect(()=>{if(f.current){const b=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var j;((j=document.getSelection())==null?void 0:j.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",b),()=>{document.removeEventListener("pointerup",b),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),M.useEffect(()=>{f.current&&RPt(f.current).forEach(w=>w.setAttribute("tabindex","-1"))}),e.jsx(C_,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Sr(o,b=>{b.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(X6,{...u,...i,onPointerDown:Sr(i.onPointerDown,b=>{b.currentTarget.contains(b.target)&&_(!0),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!0}),ref:g,style:{...i.style,userSelect:v?"text":void 0,WebkitUserSelect:v?"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)"}})})}),DPt="HoverCardArrow",OPt=M.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=ale(r);return e.jsx(Q6,{...a,...n,ref:s})});OPt.displayName=DPt;function iae(t){return s=>s.pointerType==="touch"?void 0:t()}function RPt(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 FPt=sWe,zPt=nWe,iWe=aWe;const BPt=FPt,$Pt=zPt,oWe=M.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(iWe,{ref:a,align:s,sideOffset:r,className:It("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));oWe.displayName=iWe.displayName;const qPt=[{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"}],UPt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),lWe=({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(BPt,{openDelay:200,closeDelay:100,children:[e.jsx($Pt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(oWe,{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=qPt.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(mn,{className:"h-6 w-6",children:[e.jsx(ba,{src:l.user_avatar||void 0}),e.jsx(pn,{className:"text-[10px]",children:UPt(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 VPt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=M.useState(s),[l,i]=M.useState(!1);M.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const d=()=>{o(v=>v>0?v-1:t.length-1),i(!1)},u=()=>{o(v=>v{r&&(v.key==="ArrowLeft"&&d(),v.key==="ArrowRight"&&u(),v.key==="Escape"&&n(!1))},[r,t.length]);M.useEffect(()=>(window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)),[f]);const g=t[a];return e.jsx(bs,{open:r,onOpenChange:n,children:e.jsxs(_s,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(Z,{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(Vr,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{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:d,children:e.jsx(ec,{className:"h-8 w-8"})}),e.jsx(Z,{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(ei,{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]}),(g==null?void 0:g.type)==="image"&&e.jsx(Z,{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(f5,{className:"h-5 w-5"}):e.jsx(p5,{className:"h-5 w-5"})}),e.jsx("div",{className:It("flex items-center justify-center w-full h-full min-h-[50vh] p-4",l?"cursor-zoom-out overflow-auto":"cursor-zoom-in"),onClick:()=>(g==null?void 0:g.type)==="image"&&i(!l),children:(g==null?void 0:g.type)==="video"?e.jsx("video",{src:g.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:v=>v.stopPropagation()}):e.jsx("img",{src:g==null?void 0:g.url,alt:"",className:It("object-contain transition-transform duration-200",l?"max-w-none max-h-none scale-150":"max-w-full max-h-[85vh]")})}),t.length>1&&e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 flex gap-2 bg-black/50 p-2 rounded-lg max-w-[90vw] overflow-x-auto",children:t.map((v,_)=>e.jsx("button",{onClick:()=>{o(_),i(!1)},className:It("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===_?"border-white":"border-transparent opacity-60 hover:opacity-100"),children:v.type==="video"?e.jsx("video",{src:v.url,className:"w-full h-full object-cover"}):e.jsx("img",{src:v.url,alt:"",className:"w-full h-full object-cover"})},_))})]})})}const F8=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],HPt=({commentId:t,reactions:s,currentUserId:r})=>{var u,f;const n=ds(),[a,o]=M.useState(!1),l=s.find(g=>g.user_id===r),i=Bt({mutationFn:async g=>{l?l.reaction_type===g?await K.from("community_comment_reactions").delete().eq("id",l.id):await K.from("community_comment_reactions").update({reaction_type:g}).eq("id",l.id):await K.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:g})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),d={};return s.forEach(g=>{d[g.reaction_type]=(d[g.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(lWe,{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(d).slice(0,2).map(g=>{var v;return e.jsx("span",{className:"text-sm",children:(v=F8.find(_=>_.type===g))==null?void 0:v.emoji},g)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(No,{open:a,onOpenChange:o,children:[e.jsx(So,{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=F8.find(g=>g.type===l.reaction_type))==null?void 0:u.emoji," ",(f=F8.find(g=>g.type===l.reaction_type))==null?void 0:f.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Oi,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(jo,{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:F8.map(g=>e.jsx("button",{onClick:()=>i.mutate(g.type),className:"text-xl hover:scale-125 transition-transform p-1",title:g.label,children:g.emoji},g.type))})})]})]})};function vbe({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],d=o[2],u=o[3],f=i==="#";n.push(e.jsx(yo,{to:f?`/templates/${u}`:`/profile?user=${u}`,className:It("font-medium hover:underline",f?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:g=>g.stopPropagation(),children:f?d:`@${d}`},`mention-${l++}`))}else if(o[4]){const i=o[4],d=i.replace(/[.,;:!?)]+$/,""),u=i.slice(d.length);let f;try{const g=new URL(d);f=g.hostname+(g.pathname!=="/"?g.pathname.slice(0,20)+(g.pathname.length>20?"...":""):"")}catch{f=d.length>40?d.slice(0,40)+"...":d}n.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",onClick:g=>g.stopPropagation(),children:f},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(M.Fragment,{children:i},d))})}function oae({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:d="encoded",enableTemplateMentions:u=!1}){const f=M.useRef(null),g=M.useRef(null),[v,_]=M.useState(!1),[b,w]=M.useState("user"),[j,N]=M.useState(""),[S,A]=M.useState(null),[I,L]=M.useState(0),[F,$]=M.useState({top:0,left:0,width:0}),q=M.useRef(new Map),H=M.useRef(new Map),U=ve=>{if(d==="plain"){const Ae=[];return q.current.forEach((Fe,Ie)=>{ve.includes(`@${Ie}`)&&Ae.push(Fe)}),[...new Set(Ae)]}const ke=/@\[([^\]]+)\]\(([^)]+)\)/g,Ge=[];let Ne;for(;(Ne=ke.exec(ve))!==null;)Ge.push(Ne[2]);return[...new Set(Ge)]},Q=ve=>{if(d==="plain"){const Ae=[];return H.current.forEach((Fe,Ie)=>{ve.includes(`#${Ie}`)&&Ae.push(Fe)}),[...new Set(Ae)]}const ke=/#\[([^\]]+)\]\(([^)]+)\)/g,Ge=[];let Ne;for(;(Ne=ke.exec(ve))!==null;)Ge.push(Ne[2]);return[...new Set(Ge)]};M.useEffect(()=>{if(o){const ve=U(t);o(ve)}if(l){const ve=Q(t);l(ve)}},[t,o,l,d]);const{data:se=[],isLoading:te}=Tt({queryKey:["mention-users",j],queryFn:async()=>{const ve=K.from("profiles").select("id, name").limit(8),ke=j.length>=1?ve.ilike("name",`%${j}%`):ve.order("name"),{data:Ge,error:Ne}=await ke;if(Ne)throw Ne;const Ae=Ge.map(Fe=>Fe.id),Pe=await C9e(Ae);return Ge.map(Fe=>({id:Fe.id,name:Fe.name||"Unknown",avatar_url:Pe.get(Fe.id)}))},enabled:v&&b==="user",staleTime:3e4}),{data:Y=[],isLoading:ce}=Tt({queryKey:["mention-templates",j],queryFn:async()=>{let ve=K.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);j.length>=1&&(ve=ve.ilike("name",`%${j}%`));const{data:ke,error:Ge}=await ve;if(Ge)throw Ge;return ke||[]},enabled:v&&b==="template"&&u,staleTime:3e4}),oe=b==="user"?te:ce,le=b==="user"?se:Y,de=ve=>ve.split(" ").map(ke=>ke[0]).join("").toUpperCase().slice(0,2),xe=ve=>{const ke=ve.target.value,Ge=ve.target.selectionStart;s(ke);const Ne=ke.substring(0,Ge),Ae=Ne.lastIndexOf("@"),Pe=u?Ne.lastIndexOf("#"):-1;let Fe=-1,Ie="user";if(Ae>Pe?(Fe=Ae,Ie="user"):Pe>Ae&&u&&(Fe=Pe,Ie="template"),Fe!==-1){const Ve=Ne.substring(Fe+1),dt=Ve.includes(" "),Le=Ve.includes(` `);if(!dt&&!Le&&Ve.length<=30){A(Fe),N(Ve),w(Ie),_(!0),L(0);return}}_(!1),A(null)},be=ve=>{if(S===null)return;const ke=t.substring(0,S),Ge=t.substring(S+j.length+1),Ne=b==="user"?"@":"#",Ae=d==="plain"?`${Ne}${ve.name} `:`${Ne}[${ve.name}](${ve.id}) `;d==="plain"&&(b==="user"?q.current.set(ve.name,ve.id):H.current.set(ve.name,ve.id));const Pe=ke+Ae+Ge;s(Pe),_(!1),A(null),N(""),setTimeout(()=>{if(f.current){const Fe=ke.length+Ae.length;f.current.focus(),f.current.setSelectionRange(Fe,Fe)}},0)},ye=ve=>{if(!(!v||le.length===0))switch(ve.key){case"ArrowDown":ve.preventDefault(),L(ke=>(ke+1)%le.length);break;case"ArrowUp":ve.preventDefault(),L(ke=>(ke-1+le.length)%le.length);break;case"Enter":le[I]&&(ve.preventDefault(),be(le[I]));break;case"Escape":ve.preventDefault(),_(!1);break;case"Tab":le[I]&&(ve.preventDefault(),be(le[I]));break}};return M.useEffect(()=>{const ve=ke=>{g.current&&!g.current.contains(ke.target)&&f.current&&!f.current.contains(ke.target)&&_(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[]),M.useEffect(()=>{if(!v)return;const ve=()=>{const ke=f.current;if(!ke)return;const Ge=ke.getBoundingClientRect();$({top:Ge.bottom+4,left:Ge.left,width:Ge.width})};return ve(),window.addEventListener("resize",ve),window.addEventListener("scroll",ve,!0),()=>{window.removeEventListener("resize",ve),window.removeEventListener("scroll",ve,!0)}},[v,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Lr,{ref:f,value:t,onChange:xe,onKeyDown:ve=>{ye(ve),ve.defaultPrevented||i==null||i(ve)},placeholder:r,className:It("resize-none",n),style:{minHeight:a}}),v&&xm.createPortal(e.jsxs("div",{ref:g,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:F.top,left:F.left,width:F.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:b==="user"?"👤 Mention a person":"📋 Link a template"}),oe?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):le.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:j.length<1?`Type to search ${b==="user"?"people":"templates"}...`:`No ${b==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:le.map((ve,ke)=>e.jsx("li",{className:It("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",ke===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>be(ve),onMouseEnter:()=>L(ke),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(mn,{className:"h-6 w-6",children:[e.jsx(ba,{src:ve.avatar_url}),e.jsx(pn,{className:"text-xs",children:de(ve.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:ve.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:ve.preview_image_url?e.jsx("img",{src:ve.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(El,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:ve.name})]})},ve.id))})]}),document.body)]})}function WPt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const aTe=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function cWe({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=ds(),[d,u]=M.useState(!1),[f,g]=M.useState(""),[v,_]=M.useState([]),b=Bt({mutationFn:async({content:S,parentCommentId:A})=>{const{data:I,error:L}=await K.from("community_comments").insert({post_id:s,user_id:r,content:S,parent_comment_id:A}).select("id").single();if(L)throw L;const F=v;if(F.length>0&&I){const $=F.filter(q=>q!==r).map(q=>({comment_id:I.id,mentioned_user_id:q,mentioned_by_user_id:r}));$.length>0&&await K.from("community_comment_mentions").insert($)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),g(""),_([]),u(!1)}}),w=Bt({mutationFn:async S=>{const{error:A}=await K.from("community_comments").delete().eq("id",S);if(A)throw A},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),j=()=>{f.trim()&&b.mutate({content:f,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(mn,{className:"h-8 w-8 shrink-0",children:[e.jsx(ba,{src:t.user_avatar||void 0}),e.jsx(pn,{className:"text-xs",children:aTe(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(vbe,{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(HPt,{commentId:t.id,reactions:t.reactions,currentUserId:r}),r&&l<2&&e.jsxs("button",{onClick:()=>u(!d),className:"hover:text-primary flex items-center gap-1",children:[e.jsx(dP,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>w.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),d&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(mn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(ba,{src:n||void 0}),e.jsx(pn,{className:"text-xs",children:aTe((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(oae,{placeholder:`Reply to ${t.user_name}...`,value:f,onChange:g,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:j,disabled:!f.trim()||b.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Pa,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(S=>e.jsx(cWe,{comment:S,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},S.id))})]})}const z8=[{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"}],GPt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Qs(),{avatarUrl:a}=S9e(t==null?void 0:t.id),{onlineUsers:o}=B$e(),{toast:l}=La(),i=ds(),d=M.useRef(null),[u,f]=M.useState("all"),[g,v]=M.useState(""),[_,b]=M.useState(""),[w,j]=M.useState(""),[N,S]=M.useState([]),[A,I]=M.useState([]),[L,F]=M.useState(""),[$,q]=M.useState(!1),[H,U]=M.useState(null),[Q,se]=M.useState(""),[te,Y]=M.useState(new Set),[ce,oe]=M.useState({}),[le,de]=M.useState({}),[xe,be]=M.useState([]),[ye,ve]=M.useState([]),[ke,Ge]=M.useState({open:!1,images:[],index:0});M.useEffect(()=>{if(u.startsWith("group:")){const Je=u.replace("group:","");j(Je),b("")}else u!=="all"?(b(u),j("")):(b(""),j(""))},[u]);const{data:Ne=[]}=Tt({queryKey:["community-categories"],queryFn:async()=>{const{data:Je,error:Lt}=await K.from("community_categories").select("*").order("sort_order");if(Lt)throw Lt;return Je}}),{data:Ae=[]}=Tt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:Je,error:Lt}=await K.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Lt)throw Lt;return Je}}),Pe=20,{data:Fe,isLoading:Ie,hasNextPage:Ve,fetchNextPage:dt,isFetchingNextPage:Le}=Udt({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:Je})=>{var ze;const Lt=Je*Pe,zt=Lt+Pe;let is=K.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Lt,zt);if(u.startsWith("group:")){const tt=u.replace("group:","");is=is.eq("private_group_id",tt)}else u==="all"||(is=is.eq("category_id",u).is("private_group_id",null));const{data:Kt,error:Qt}=await is;if(Qt)throw Qt;const fs=((Kt==null?void 0:Kt.length)||0)>Pe,dr=(Kt||[]).slice(0,Pe);if(dr.length===0)return{posts:[],hasMore:!1,nextPage:Je+1};const bt=dr.map(tt=>tt.id),ws=[...new Set(dr.filter(tt=>tt.category_id).map(tt=>tt.category_id))].filter(Boolean),[ir,Rr,oa,ri,no]=await Promise.all([ws.length?K.from("community_categories").select("*").in("id",ws):Promise.resolve({data:[]}),K.from("community_post_media").select("*").in("post_id",bt).order("sort_order"),K.from("community_reactions").select("*").in("post_id",bt),K.from("community_comments").select("*").in("post_id",bt).order("created_at",{ascending:!0}),K.from("community_post_resources").select("*").in("post_id",bt)]),Da=ir==null?void 0:ir.data,yn=Rr==null?void 0:Rr.data,ea=oa==null?void 0:oa.data,Zt=ri==null?void 0:ri.data,yr=no==null?void 0:no.data,Gr=(Zt||[]).map(tt=>tt.id),[Dn,rs]=await Promise.all([Gr.length?K.from("community_comment_reactions").select("*").in("comment_id",Gr):Promise.resolve({data:[]}),(()=>{const tt=(yr||[]).filter(Mt=>Mt.resource_type==="template").map(Mt=>Mt.resource_id);return tt.length===0?Promise.resolve({data:[]}):K.from("canva_templates").select("id, name, preview_image_url").in("id",tt)})()]),An=(Dn==null?void 0:Dn.data)||[],la=(rs==null?void 0:rs.data)||[],qa=new Map(la.map(tt=>[tt.id,{name:tt.name,preview_image_url:tt.preview_image_url}])),Jr=Array.from(new Set([...dr.map(tt=>tt.user_id),...(ea||[]).map(tt=>tt.user_id),...(Zt||[]).map(tt=>tt.user_id),...An.map(tt=>tt.user_id)])),[Ka,Dl]=await Promise.all([Jr.length?K.from("profiles").select("id, name").in("id",Jr):Promise.resolve({data:[]}),C9e(Jr)]),Lo=new Map(((ze=Ka==null?void 0:Ka.data)==null?void 0:ze.map(tt=>[tt.id,tt.name]))||[]),Kc=new Map((Da||[]).map(tt=>[tt.id,tt])),it=tt=>{const Mt=new Map,Nt=[];return tt.forEach(Ot=>{Mt.set(Ot.id,{...Ot,user_name:Lo.get(Ot.user_id)||"Unknown User",user_avatar:Dl.get(Ot.user_id),reactions:An.filter(Yt=>Yt.comment_id===Ot.id).map(Yt=>({...Yt,user_name:Lo.get(Yt.user_id)||"Unknown User",user_avatar:Dl.get(Yt.user_id)})),replies:[]})}),tt.forEach(Ot=>{const Yt=Mt.get(Ot.id);if(Ot.parent_comment_id&&Mt.has(Ot.parent_comment_id)){const qt=Mt.get(Ot.parent_comment_id);qt.replies=qt.replies||[],qt.replies.push(Yt)}else Nt.push(Yt)}),Nt};return{posts:dr.map(tt=>{const Mt=(yr||[]).filter(Nt=>Nt.post_id===tt.id).map(Nt=>{let Ot="",Yt=null;if(Nt.resource_type==="template"){const qt=qa.get(Nt.resource_id);Ot=(qt==null?void 0:qt.name)||"Unknown Template",Yt=(qt==null?void 0:qt.preview_image_url)||null}return{id:Nt.id,resource_type:Nt.resource_type,resource_id:Nt.resource_id,resource_name:Ot,resource_preview_url:Yt}});return{...tt,user_name:Lo.get(tt.user_id)||"Unknown User",user_avatar:Dl.get(tt.user_id),category:tt.category_id?Kc.get(tt.category_id):null,media:(yn||[]).filter(Nt=>Nt.post_id===tt.id),reactions:((ea||[]).filter(Nt=>Nt.post_id===tt.id)||[]).map(Nt=>({...Nt,user_name:Lo.get(Nt.user_id)||"Unknown User",user_avatar:Dl.get(Nt.user_id)})),comments:it((Zt||[]).filter(Nt=>Nt.post_id===tt.id)),resources:Mt}}),hasMore:fs,nextPage:Je+1}},getNextPageParam:Je=>Je.hasMore?Je.nextPage:void 0}),Rt=M.useMemo(()=>(Fe==null?void 0:Fe.pages.flatMap(Je=>Je.posts))??[],[Fe]),fe=Bt({mutationFn:async()=>{q(!0);const{data:Je,error:Lt}=await K.from("community_posts").insert({user_id:t.id,category_id:w?null:_||null,private_group_id:w||null,content:g,link_url:L||null}).select().single();if(Lt)throw Lt;for(let is=0;is0){const is=xe.filter(Kt=>Kt!==t.id).map(Kt=>({post_id:Je.id,mentioned_user_id:Kt,mentioned_by_user_id:t.id}));is.length>0&&await K.from("community_post_mentions").insert(is)}const zt=WPt(g);if(zt.length>0){const is=zt.map(Kt=>({post_id:Je.id,resource_type:"template",resource_id:Kt}));await K.from("community_post_resources").insert(is)}return Je},onSuccess:async Je=>{var Lt;i.invalidateQueries({queryKey:["community-posts"]}),v(""),be([]),ve([]),b(""),j(""),S([]),I([]),F(""),l({title:"Post created!"});try{const zt=((Lt=t==null?void 0:t.user_metadata)==null?void 0:Lt.name)||"Someone",is=g.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Kt=is.length>50?is.substring(0,50)+"...":is;await K.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${zt}: ${Kt}`,url:"/community"}})}catch(zt){console.error("Failed to send push notification:",zt)}},onError:Je=>{l({title:"Error creating post",description:Je.message,variant:"destructive"})},onSettled:()=>q(!1)}),Qe=Bt({mutationFn:async({postId:Je,content:Lt})=>{const{error:zt}=await K.from("community_posts").update({content:Lt}).eq("id",Je);if(zt)throw zt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),U(null),se(""),l({title:"Post updated!"})}}),at=Bt({mutationFn:async Je=>{const{error:Lt}=await K.from("community_posts").delete().eq("id",Je);if(Lt)throw Lt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),rt=Bt({mutationFn:async({postId:Je,isPinned:Lt})=>{const{error:zt}=await K.from("community_posts").update({is_pinned:!Lt,pinned_at:Lt?null:new Date().toISOString(),pinned_by:Lt?null:t==null?void 0:t.id}).eq("id",Je);if(zt)throw zt},onSuccess:(Je,{isPinned:Lt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Lt?"Post unpinned":"Post pinned to top"})}}),je=Bt({mutationFn:async({postId:Je,reactionType:Lt})=>{var is;const zt=(is=Rt.find(Kt=>Kt.id===Je))==null?void 0:is.reactions.find(Kt=>Kt.user_id===(t==null?void 0:t.id));zt?zt.reaction_type===Lt?await K.from("community_reactions").delete().eq("id",zt.id):await K.from("community_reactions").update({reaction_type:Lt}).eq("id",zt.id):await K.from("community_reactions").insert({post_id:Je,user_id:t.id,reaction_type:Lt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),mt=Bt({mutationFn:async({postId:Je,content:Lt})=>{const{data:zt,error:is}=await K.from("community_comments").insert({post_id:Je,user_id:t.id,content:Lt}).select("id").single();if(is)throw is;const Kt=le[Je]||[];if(Kt.length>0&&zt){const Qt=Kt.filter(fs=>fs!==t.id).map(fs=>({comment_id:zt.id,mentioned_user_id:fs,mentioned_by_user_id:t.id}));Qt.length>0&&await K.from("community_comment_mentions").insert(Qt)}},onSuccess:(Je,{postId:Lt})=>{i.invalidateQueries({queryKey:["community-posts"]}),oe(zt=>({...zt,[Lt]:""})),de(zt=>({...zt,[Lt]:[]}))}});Bt({mutationFn:async Je=>{const{error:Lt}=await K.from("community_comments").delete().eq("id",Je);if(Lt)throw Lt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const He=Je=>{const Lt=Array.from(Je.target.files||[]);if(Lt.length+N.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}S(zt=>[...zt,...Lt]),Lt.forEach(zt=>{const is=new FileReader;is.onloadend=()=>{I(Kt=>[...Kt,is.result])},is.readAsDataURL(zt)})},ct=Je=>{S(Lt=>Lt.filter((zt,is)=>is!==Je)),I(Lt=>Lt.filter((zt,is)=>is!==Je))},We=Je=>Je.split(" ").map(Lt=>Lt[0]).join("").toUpperCase().slice(0,2),Ze=Je=>{const Lt={};return Je.forEach(zt=>{Lt[zt.reaction_type]=(Lt[zt.reaction_type]||0)+1}),Lt},ht=Je=>{var Lt;return(Lt=Je.find(zt=>zt.user_id===(t==null?void 0:t.id)))==null?void 0:Lt.reaction_type},Ke=Je=>Je.reduce((Lt,zt)=>Lt+1+(zt.replies?Ke(zt.replies):0),0),qe=Je=>{if(n)return!0;if(!s||!Je.private_group_id)return!1;const Lt=Ae.find(zt=>zt.id===Je.private_group_id);return Lt!=null&&Lt.brokerage_id?r.some(zt=>zt.id===Lt.brokerage_id):!1};return e.jsx(Ms,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(TPt,{categories:Ne,privateGroups:Ae,selectedFilter:u,onFilterChange:f,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(APt,{categories:Ne,privateGroups:Ae,selectedFilter:u,onFilterChange:f,onlineUsers:o}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:a||void 0}),e.jsx(pn,{children:t!=null&&t.email?We(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(oae,{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:g,onChange:v,onMentionsChange:be,onTemplatesChange:ve,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),A.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:A.map((Je,Lt)=>{var zt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(zt=N[Lt])!=null&&zt.type.startsWith("video/")?e.jsx("video",{src:Je,className:"w-full h-full object-cover"}):e.jsx("img",{src:Je,alt:"",className:"w-full h-full object-cover"}),e.jsx(Z,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ct(Lt),children:e.jsx(Vr,{className:"h-3 w-3"})})]},Lt)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Po,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:L,onChange:Je=>F(Je.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>F(""),children:e.jsx(Vr,{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:d,onChange:He,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>{var Je;return(Je=d.current)==null?void 0:Je.click()},children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>{var Je;return(Je=d.current)==null?void 0:Je.click()},children:[e.jsx(Cn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>F("https://"),children:[e.jsx(Po,{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(tr,{value:w||_||"none",onValueChange:Je=>{Je==="none"?(b(""),j("")):Je.startsWith("group:")?(j(Je.replace("group:","")),b("")):(b(Je),j(""))},children:[e.jsx(Js,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(rr,{placeholder:"Select..."})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No category"}),Ne.map(Je=>e.jsxs(At,{value:Je.id,children:[Je.icon," ",Je.name]},Je.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(Je=>e.jsxs(At,{value:`group:${Je.id}`,children:[Je.icon||"🔒"," ",Je.name]},Je.id))]})]})]}):e.jsxs(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(rr,{placeholder:"Category"})}),e.jsx(er,{children:Ne.map(Je=>e.jsxs(At,{value:Je.id,children:[Je.icon," ",Je.name]},Je.id))})]}),e.jsxs(Z,{size:"sm",onClick:()=>fe.mutate(),disabled:!g.trim()||$,children:[e.jsx(Pa,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Ie?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((Je,Lt)=>e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gs,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(gs,{className:"h-4 w-32"}),e.jsx(gs,{className:"h-4 w-full"}),e.jsx(gs,{className:"h-4 w-3/4"})]})]})})},Lt))}):Rt.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(mc,{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:[Rt.map(Je=>{var Lt,zt,is,Kt;return e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex gap-3 min-w-0",children:[e.jsxs(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:Je.user_avatar||void 0}),e.jsx(pn,{children:We(Je.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:Je.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(Je.created_at),{addSuffix:!0})}),Je.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(nt,{variant:"secondary",className:"text-xs",children:[Je.category.icon," ",Je.category.name]})]})]})]})]}),(Je.user_id===(t==null?void 0:t.id)||qe(Je))&&e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Xp,{className:"h-4 w-4"})})}),e.jsxs(mu,{align:"end",children:[qe(Je)&&Je.private_group_id&&e.jsx(Wa,{onClick:()=>rt.mutate({postId:Je.id,isPinned:Je.is_pinned}),children:Je.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(aP,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(Y1,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),Je.user_id===(t==null?void 0:t.id)&&e.jsxs(Wa,{onClick:()=>{U(Je),se(Je.content)},children:[e.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Wa,{className:"text-destructive",onClick:()=>at.mutate(Je.id),children:[e.jsx(Cr,{className:"h-4 w-4 mr-2"}),Je.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),Je.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(Y1,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(vbe,{content:Je.content})}),Je.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${Je.media.length===1?"grid-cols-1":Je.media.length===2?"grid-cols-2":Je.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:Je.media.slice(0,4).map((Qt,fs)=>{const dr=fs===3&&Je.media.length>4,bt=Je.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${Je.media.length===1?"max-h-[500px]":Je.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>Ge({open:!0,images:Je.media.map(ws=>({url:ws.media_url,type:ws.media_type==="video"?"video":"image"})),index:fs}),children:[Qt.media_type==="video"?e.jsx("video",{src:Qt.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:Qt.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"})})})}),dr&&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:["+",bt]})})]},Qt.id)})}),Je.link_url&&e.jsxs("a",{href:Je.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[Je.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:Je.link_image,alt:Je.link_title||"Link preview",className:"w-full h-full object-cover",onError:Qt=>{Qt.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:Je.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:Je.link_title}),Je.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:Je.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(Je.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(Po,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:Je.link_url})]})})]}),Je.reactions.length>0&&e.jsx(lWe,{reactions:Je.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(Je.reactions)).slice(0,3).map(([Qt])=>{var fs;return e.jsx("span",{className:"text-base",children:(fs=z8.find(dr=>dr.type===Qt))==null?void 0:fs.emoji},Qt)})}),e.jsx("span",{children:Je.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"flex-1",children:[ht(Je.reactions)?e.jsx("span",{className:"mr-1",children:(Lt=z8.find(Qt=>Qt.type===ht(Je.reactions)))==null?void 0:Lt.emoji}):e.jsx(lu,{className:"h-4 w-4 mr-1"}),ht(Je.reactions)?(zt=z8.find(Qt=>Qt.type===ht(Je.reactions)))==null?void 0:zt.label:"Like"]})}),e.jsx(jo,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:z8.map(Qt=>e.jsx("button",{onClick:()=>je.mutate({postId:Je.id,reactionType:Qt.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:Qt.label,children:Qt.emoji},Qt.type))})})]}),e.jsxs(Z,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Y(Qt=>{const fs=new Set(Qt);return fs.has(Je.id)?fs.delete(Je.id):fs.add(Je.id),fs}),children:[e.jsx(mc,{className:"h-4 w-4 mr-1"}),(()=>{const Qt=Ke(Je.comments);return Qt>0?`Comment (${Qt})`:"Comment"})()]})]}),te.has(Je.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[Je.comments.map(Qt=>e.jsx(cWe,{comment:Qt,postId:Je.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:qe(Je)},Qt.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:a||void 0}),e.jsx(pn,{className:"text-xs",children:We(((is=t.email)==null?void 0:is.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(oae,{placeholder:"Write a comment... (use @ to mention)",value:ce[Je.id]||"",onChange:Qt=>oe(fs=>({...fs,[Je.id]:Qt})),onMentionsChange:Qt=>de(fs=>({...fs,[Je.id]:Qt})),mentionFormat:"plain",onKeyDown:Qt=>{var fs;Qt.defaultPrevented||Qt.key==="Enter"&&!Qt.shiftKey&&((fs=ce[Je.id])!=null&&fs.trim())&&(Qt.preventDefault(),mt.mutate({postId:Je.id,content:ce[Je.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>{var Qt;(Qt=ce[Je.id])!=null&&Qt.trim()&&mt.mutate({postId:Je.id,content:ce[Je.id]})},disabled:!((Kt=ce[Je.id])!=null&&Kt.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Pa,{className:"h-4 w-4"})})]})]})]})]})},Je.id)}),Ve&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(Z,{variant:"outline",onClick:()=>dt(),disabled:Le,children:Le?"Loading…":"Load more posts"})})]}),e.jsx(bs,{open:!!H,onOpenChange:()=>U(null),children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Edit Post"})}),e.jsx(Lr,{value:Q,onChange:Je=>se(Je.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>U(null),children:"Cancel"}),e.jsx(Z,{onClick:()=>{H&&Qe.mutate({postId:H.id,content:Q})},disabled:!Q.trim(),children:"Save Changes"})]})]})}),e.jsx(VPt,{images:ke.images,initialIndex:ke.index,open:ke.open,onOpenChange:Je=>Ge(Lt=>({...Lt,open:Je}))})]})]})})},e4={open:{label:"Open",icon:Tn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:mc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:hi,color:"bg-green-500"},closed:{label:"Closed",icon:bc,color:"bg-muted-foreground"}},iTe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function KPt(){const{user:t}=Qs(),s=ds(),[r,n]=M.useState(null),[a,o]=M.useState(""),{data:l=[],isLoading:i}=Tt({queryKey:["support-tickets"],queryFn:async()=>{const{data:g,error:v}=await K.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(v)throw v;return g},enabled:!!t}),{data:d=[]}=Tt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:g,error:v}=await K.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(v)throw v;return g},enabled:!!r}),u=Bt({mutationFn:async g=>{if(!r||!t)throw new Error("Missing data");const{error:v}=await K.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:g,is_admin_reply:!1});if(v)throw v},onSuccess:()=>{s.invalidateQueries({queryKey:["ticket-replies",r==null?void 0:r.id]}),o(""),ge.success("Reply sent!")},onError:()=>{ge.error("Failed to send reply")}}),f=()=>{a.trim()&&u.mutate(a)};if(r){const g=e4[r.status].icon;return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Ba,{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(nt,{variant:"secondary",children:iTe[r.category]}),e.jsxs(nt,{className:e4[r.status].color,children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),e4[r.status].label]})]})]})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(_r,{children:["Created on ",js(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Fi,{className:"h-[300px] pr-4",children:d.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:d.map(v=>{var _;return e.jsxs("div",{className:`p-4 rounded-lg ${v.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:v.is_admin_reply?"Support Team":((_=v.profiles)==null?void 0:_.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:js(new Date(v.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:v.content})]},v.id)})})}),r.status!=="closed"&&e.jsxs(e.Fragment,{children:[e.jsx(Jl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Lr,{placeholder:"Type your reply...",value:a,onChange:v=>o(v.target.value),className:"min-h-[80px]"}),e.jsx(Z,{onClick:f,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(Pa,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(De,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Oe,{className:"p-6 sm:p-8",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-6",children:[e.jsx("div",{className:"p-4 bg-primary/20 rounded-full",children:e.jsx(Qy,{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(Ege,{trigger:e.jsxs(Z,{size:"lg",className:"gap-2",children:[e.jsx(Ys,{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(ga,{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(Ege,{trigger:e.jsxs(Z,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Ys,{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(De,{className:"border-dashed",children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(mc,{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(g=>{const v=e4[g.status].icon;return e.jsx(De,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(g),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:g.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"outline",className:"text-xs",children:iTe[g.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:js(new Date(g.created_at),"MMM d, yyyy")})]})]}),e.jsxs(nt,{className:e4[g.status].color,children:[e.jsx(v,{className:"h-3 w-3 mr-1"}),e4[g.status].label]})]})})},g.id)})})]})})}function ZPt({open:t,onOpenChange:s}){return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{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(nn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ss,{children:"Schedule Agent Onboarding"}),e.jsx(Kr,{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 YPt({open:t,onOpenChange:s}){const{brokerageId:r}=Qs(),[n,a]=M.useState(""),[o,l]=M.useState([]),[i,d]=M.useState(!1),{data:u,isLoading:f}=Tt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:w,error:j}=await K.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(j)throw j;return w},enabled:t&&!!r}),g=u==null?void 0:u.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())||w.email.toLowerCase().includes(n.toLowerCase())),v=w=>{l(j=>j.includes(w)?j.filter(N=>N!==w):[...j,w])},_=async()=>{if(o.length===0){ge.error("Please select at least one agent");return}d(!0);try{const{data:w,error:j}=await K.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(j)throw j;ge.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(w){console.error("Error sending onboarding link:",w),ge.error(w.message||"Failed to send onboarding link")}finally{d(!1)}},b=w=>{w||(l([]),a("")),s(w)};return e.jsx(bs,{open:t,onOpenChange:b,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Cs,{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(Pa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ss,{children:"Send Onboarding Link"}),e.jsx(Kr,{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(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:n,onChange:w=>a(w.target.value),className:"pl-10"})]}),f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(g==null?void 0:g.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(xr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Fi,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:g==null?void 0:g.map(w=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>v(w.id),children:[e.jsx($o,{checked:o.includes(w.id),onCheckedChange:()=>v(w.id)}),e.jsx(mn,{className:"h-8 w-8",children:e.jsx(pn,{className:"text-xs",children:w.name.split(" ").map(j=>j[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:w.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w.email})]})]},w.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(Z,{onClick:_,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function XPt(){const[t,s]=M.useState(!1),[r,n]=M.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(De,{className:"mb-8",children:[e.jsx($t,{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(xr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Vt,{children:"Agent Onboarding"}),e.jsx(_r,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(Z,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(Z,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(Pa,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(ZPt,{open:t,onOpenChange:s}),e.jsx(YPt,{open:r,onOpenChange:n})]})}function QPt({open:t,onOpenChange:s}){return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{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($x,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ss,{children:"Schedule Launch Meeting"}),e.jsx(Kr,{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 JPt(){const[t,s]=M.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(De,{className:"mb-8",children:[e.jsx($t,{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($x,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Vt,{children:"Launch or ReLaunch Meeting"}),e.jsx(_r,{children:"Schedule a private LevelUp information session for your brokerage. Have one of our staff host a meeting to help your team get the most out of all our trainings, tools, and resources."})]})]})}),e.jsx(Oe,{children:e.jsxs(Z,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx($x,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(QPt,{open:t,onOpenChange:s})]})}function eIt(){const t=Or(),[s,r]=M.useState(""),[n,a]=M.useState(null),{data:o,isLoading:l}=Tt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:w,error:j}=await K.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(j)throw j;return w}}),{data:i}=Tt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:w,error:j}=await K.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(j)throw j;return w}}),{data:d}=Tt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:w,error:j}=await K.from("brokerage_resource_pdfs").select("resource_id");if(j)throw j;return w}}),{data:u}=Tt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:w,error:j}=await K.from("brokerage_resource_videos").select("resource_id");if(j)throw j;return w}}),{data:f}=Tt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:w,error:j}=await K.from("brokerage_resource_links").select("resource_id");if(j)throw j;return w}}),g=o==null?void 0:o.filter(w=>{var S;const j=w.title.toLowerCase().includes(s.toLowerCase())||((S=w.description)==null?void 0:S.toLowerCase().includes(s.toLowerCase())),N=!n||w.category_id===n;return j&&N}),v=i==null?void 0:i.filter(w=>o==null?void 0:o.some(j=>j.category_id===w.id)),_=w=>{const j=(d==null?void 0:d.filter(A=>A.resource_id===w).length)||0,N=(u==null?void 0:u.filter(A=>A.resource_id===w).length)||0,S=(f==null?void 0:f.filter(A=>A.resource_id===w).length)||0;return{pdfCount:j,videoCount:N,linkCount:S}},b=w=>{t(`/brokerage-resources/${w}`)};return e.jsx(Ms,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(XPt,{}),e.jsx(JPt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search resources...",value:s,onChange:w=>r(w.target.value),className:"pl-10"})]}),v&&v.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(nt,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),v.map(w=>e.jsx(nt,{variant:n===w.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(w.id),children:w.name},w.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(g==null?void 0:g.length)||0," resource",(g==null?void 0:g.length)!==1?"s":""," available"]}),l?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((w,j)=>e.jsxs(De,{children:[e.jsx(gs,{className:"h-40 w-full"}),e.jsx($t,{children:e.jsx(gs,{className:"h-5 w-3/4"})}),e.jsxs(Oe,{children:[e.jsx(gs,{className:"h-4 w-full mb-2"}),e.jsx(gs,{className:"h-4 w-2/3"})]})]},j))}):(g==null?void 0:g.length)===0?e.jsxs(De,{className:"p-12 text-center",children:[e.jsx(Zu,{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:g==null?void 0:g.map(w=>{const{pdfCount:j,videoCount:N,linkCount:S}=_(w.id),A=i==null?void 0:i.find(I=>I.id===w.category_id);return e.jsxs(De,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>b(w.id),children:[w.preview_image_url?e.jsx("img",{src:w.preview_image_url,alt:w.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(Zu,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx($t,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Vt,{className:"text-lg line-clamp-1",children:w.title}),A&&e.jsx(nt,{variant:"secondary",className:"shrink-0 text-xs",children:A.name})]})}),e.jsxs(Oe,{children:[w.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:w.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[j>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-4 w-4"}),j]}),N>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cn,{className:"h-4 w-4"}),N]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Po,{className:"h-4 w-4"}),S]})]})]})]},w.id)})})]})})}const tIt=()=>{const{resourceId:t}=Uo(),{data:s,isLoading:r}=Tt({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await K.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await K.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await K.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:d}=await K.from("brokerage_resource_links").select("*").eq("resource_id",t).order("sort_order");return{...a,pdfs:l||[],videos:i||[],links:d||[]}},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(Ms,{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(Ms,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Z,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(yo,{to:"/brokerage-resources",children:[e.jsx(Ba,{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(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Cn,{className:"h-4 w-4"}),"Videos (",s.videos.length,")"]}),e.jsx("div",{className:"space-y-4",children:s.videos.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:a.title}),e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:a.video_url,className:"absolute top-0 left-0 w-full h-full rounded-lg border",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})]},a.id))})]})}),s.pdfs&&s.pdfs.length>0&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Un,{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(Un,{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(Ei,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(un,{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(un,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Ms,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Zu,{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(Z,{asChild:!0,className:"mt-4",children:e.jsx(yo,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function sIt(){const{onlineUsers:t,totalOnline:s}=B$e();return e.jsxs(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(xr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(nt,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(qc,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No other users online right now"}):e.jsx(Fi,{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(mn,{className:"h-9 w-9",children:[e.jsx(ba,{src:r.avatarUrl,alt:r.name}),e.jsx(pn,{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 oTe={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:xr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:yP,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:cp,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:UE,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:pp,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:nd,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:xr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Mm,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:pc,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:El,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Yu,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Vx,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:gn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:gn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:j0,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:jc,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:Zu,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Zu,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:Ar,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:Zk,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:Ym,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:Ar,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:Ag,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:X4,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:qx,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:uo,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:so,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:Al,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:xr,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:Ag,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:ho,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:n5,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:G1,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Gn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:Ar,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:ol,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:nu,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:Yu,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:Oi,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:Hn,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:lf,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:nu,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:Xo,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:"Send physical postcards via Lob — manage templates, orders, and agent credits",icon:Ar,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:W1,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]}};function rIt(){const t=Or();return e.jsx(Ms,{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(sIt,{})})]}),e.jsxs(Ia,{defaultValue:"users",className:"w-full",children:[e.jsx(Aa,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(oTe).map(([s,r])=>e.jsx(Ts,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(oTe).map(([s,r])=>e.jsx(Vs,{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(De,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs($t,{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(Vt,{className:"text-base",children:n.title})]}),e.jsx(Oe,{className:"pt-0",children:e.jsx(_r,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Pn=M.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:It("w-full caption-bottom text-sm",t),...s})}));Pn.displayName="Table";const In=M.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:It("[&_tr]:border-b",t),...s}));In.displayName="TableHeader";const Ln=M.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:It("[&_tr:last-child]:border-0",t),...s}));Ln.displayName="TableBody";const nIt=M.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:It("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));nIt.displayName="TableFooter";const ks=M.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:It("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));ks.displayName="TableRow";const kt=M.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:It("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));kt.displayName="TableHead";const lt=M.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:It("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));lt.displayName="TableCell";const aIt=M.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:It("mt-4 text-sm text-muted-foreground",t),...s}));aIt.displayName="TableCaption";const iIt=()=>{const{isAdmin:t}=Qs(),s=Or(),[r,n]=M.useState([]),[a,o]=M.useState(!0),[l,i]=M.useState(!1),[d,u]=M.useState(null);M.useEffect(()=>{if(!t){s("/dashboard");return}f()},[t]);const f=async()=>{try{const{data:w,error:j}=await K.from("app_tiles").select("*").order("name");if(j)throw j;n(w||[])}catch(w){console.error("Error loading apps:",w),ge.error("Failed to load apps")}finally{o(!1)}},g=async w=>{w.preventDefault();const j=new FormData(w.currentTarget),N={name:j.get("name"),description:j.get("description"),icon:j.get("icon"),app_id:j.get("app_id"),target_url:j.get("target_url"),required_tags:j.get("required_tags").split(",").map(S=>S.trim()).filter(Boolean)};try{if(d){const{error:S}=await K.from("app_tiles").update(N).eq("id",d.id);if(S)throw S;ge.success("App updated successfully")}else{const{error:S}=await K.from("app_tiles").insert([N]);if(S)throw S;ge.success("App created successfully")}i(!1),u(null),f()}catch(S){console.error("Error saving app:",S),ge.error("Failed to save app")}},v=async w=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:j}=await K.from("app_tiles").delete().eq("id",w);if(j)throw j;ge.success("App deleted successfully"),f()}catch(j){console.error("Error deleting app:",j),ge.error("Failed to delete app")}},_=w=>{u(w),i(!0)},b=()=>{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(Z,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(Ba,{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(bs,{open:l,onOpenChange:i,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{onClick:b,children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(_s,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:d?"Edit App":"Create New App"}),e.jsx(Kr,{children:"Configure the application tile settings"})]}),e.jsxs("form",{onSubmit:g,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(_e,{htmlFor:"name",children:"App Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:d==null?void 0:d.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"app_id",children:"App ID"}),e.jsx(Re,{id:"app_id",name:"app_id",defaultValue:d==null?void 0:d.app_id,placeholder:"agent_connect",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",name:"description",defaultValue:d==null?void 0:d.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(Re,{id:"icon",name:"icon",defaultValue:d==null?void 0:d.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"target_url",children:"Target URL"}),e.jsx(Re,{id:"target_url",name:"target_url",type:"url",defaultValue:d==null?void 0:d.target_url,required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(Re,{id:"required_tags",name:"required_tags",defaultValue:d==null?void 0:d.required_tags.join(", "),placeholder:"levelup-member, agent-connect"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",children:d?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Application Tiles"}),e.jsx(_r,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Oe,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(Z,{onClick:b,children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:r.map(w=>e.jsxs(ks,{children:[e.jsx(lt,{className:"text-2xl",children:w.icon}),e.jsx(lt,{className:"font-medium",children:w.name}),e.jsx(lt,{className:"font-mono text-sm",children:w.app_id}),e.jsx(lt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:w.target_url}),e.jsx(lt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:w.required_tags.map(j=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:j},j))})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>_(w),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>v(w.id),children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},w.id))})]})})]})})]})};function pu({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(yo,{to:"/admin",children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Ba,{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 lTe=({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(nt,{variant:"destructive",className:It("gap-1",s),children:[e.jsx(jh,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(nt,{variant:"destructive",className:It("gap-1",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(nt,{className:It("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(nt,{variant:"secondary",className:It("gap-1",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},dWe=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=La(),l=M.useRef(null),[i,d]=M.useState([]),[u,f]=M.useState(""),[g,v]=M.useState(!1),[_,b]=M.useState("upload"),[w,j]=M.useState(null),N=()=>{d([]),f(""),b("upload"),j(null),l.current&&(l.current.value="")},S=()=>{N(),s(!1)},A=q=>{const H=q.split(` `).map(Y=>Y.trim()).filter(Y=>Y);if(H.length===0)return[];const U=H[0].toLowerCase(),se=U.includes("first")||U.includes("last")||U.includes("email")||U.includes("name")||U.includes("phone")||U.includes("sms")||U.includes("consent")?H.slice(1):H,te=[];for(const Y of se){const oe=(Y.includes(" ")?Y.split(" "):Y.split(",")).map(le=>le.trim().replace(/^["']|["']$/g,""));if(oe.length>=2){let le="",de="",xe="",be="",ye;if(oe.length===2){const Ge=oe[0].split(" ");le=Ge[0]||"",de=Ge.slice(1).join(" ")||"",xe=oe[1]}else if(oe.length===3)le=oe[0],de=oe[1],xe=oe[2];else if(oe.length===4)le=oe[0],de=oe[1],xe=oe[2],be=oe[3];else if(oe.length>=5){le=oe[0],de=oe[1],xe=oe[2],be=oe[3];const Ge=oe[4].toLowerCase();ye=Ge==="true"||Ge==="yes"||Ge==="1"||Ge==="y"}const ke=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(xe);te.push({firstName:le.trim(),lastName:de.trim(),email:xe.trim().toLowerCase(),phone:be.trim()||void 0,smsConsent:ye,isValid:ke&&le.trim().length>0,error:ke?le.trim()?void 0:"Missing name":"Invalid email"})}}return te},I=q=>{var Q;const H=(Q=q.target.files)==null?void 0:Q[0];if(!H)return;const U=new FileReader;U.onload=se=>{var ce;const te=(ce=se.target)==null?void 0:ce.result,Y=A(te);if(Y.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}d(Y),b("preview")},U.readAsText(H)},L=async()=>{const q=i.filter(U=>U.isValid);if(q.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const H=n||u||null;v(!0);try{const{data:{session:U}}=await K.auth.getSession(),Q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U==null?void 0:U.access_token}`},body:JSON.stringify({users:q.map(te=>({firstName:te.firstName,lastName:te.lastName,email:te.email,phone:te.phone,smsConsent:te.smsConsent})),brokerageId:H})}),se=await Q.json();if(!Q.ok)throw new Error(se.error||"Failed to import users");j(se),b("result"),se.created>0&&a(),o({title:"Import Complete",description:`${se.created} user(s) created successfully.${se.failed>0?` ${se.failed} failed.`:""}`})}catch(U){console.error("Import error:",U),o({title:"Import Failed",description:U.message||"Failed to import users",variant:"destructive"})}finally{v(!1)}},F=i.filter(q=>q.isValid).length,$=i.filter(q=>!q.isValid).length;return e.jsx(bs,{open:t,onOpenChange:S,children:e.jsxs(_s,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(x0,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Kr,{children:"Upload a CSV file with agent information. Each row should contain First Name, Last Name, and Email."})]}),_==="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(xi,{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(Z,{onClick:()=>{var q;return(q=l.current)==null?void 0:q.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."})]})]}),_==="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(_e,{children:"Assign to Brokerage (optional)"}),e.jsxs(tr,{value:u||"none",onValueChange:q=>f(q==="none"?"":q),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select a brokerage..."})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No brokerage"}),r.map(q=>e.jsx(At,{value:q.id,children:q.name},q.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(Ma,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[F," valid"]})]}),$>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Yo,{className:"h-4 w-4"}),e.jsxs("span",{children:[$," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:i.slice(0,100).map((q,H)=>e.jsxs(ks,{children:[e.jsx(lt,{children:q.firstName}),e.jsx(lt,{children:q.lastName}),e.jsx(lt,{children:q.email}),e.jsx(lt,{className:"text-muted-foreground",children:q.phone||"-"}),e.jsx(lt,{className:"text-muted-foreground",children:q.smsConsent===!0?"✓":q.smsConsent===!1?"✗":"-"}),e.jsx(lt,{children:q.isValid?e.jsx(nt,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(nt,{variant:"destructive",children:q.error||"Invalid"})})]},H))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),_==="result"&&w&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(Ma,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:[w.created," agent(s) created and invited"]}),w.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[w.failed," failed to create"]})]}),w.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[w.errors.slice(0,10).map((q,H)=>e.jsxs("li",{children:["• ",q]},H)),w.errors.length>10&&e.jsxs("li",{children:["...and ",w.errors.length-10," more"]})]})]})]}),e.jsxs(qn,{children:[_==="upload"&&e.jsx(Z,{variant:"outline",onClick:S,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{variant:"outline",onClick:N,children:"Back"}),e.jsx(Z,{onClick:L,disabled:g||F===0,children:g?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${F} Agent${F!==1?"s":""}`})]}),_==="result"&&e.jsx(Z,{onClick:S,children:"Done"})]})]})})};function Qo({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(kt,{className:It("cursor-pointer select-none",o),...l,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 font-semibold hover:text-foreground transition-colors w-full text-left",onClick:()=>n(t),children:[a,i?r==="asc"?e.jsx(Rd,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Ku,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx($c,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function NL(t=null,s=null){const[r,n]=M.useState(t),[a,o]=M.useState(s),l=M.useCallback(d=>{r===d?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(d),o("asc"))},[r,a]),i=M.useCallback((d,u)=>{if(!r||!a||!u[r])return d;const f=u[r];return[...d].sort((g,v)=>{const _=f(g),b=f(v);if(_==null&&b==null)return 0;if(_==null)return 1;if(b==null)return-1;let w;return typeof _=="string"&&typeof b=="string"?w=_.localeCompare(b,void 0,{sensitivity:"base"}):w=_-b,a==="asc"?w:-w})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const oIt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Gn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:so},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:bd}];function uWe({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=M.useState("custom"),[l,i]=M.useState(""),[d,u]=M.useState(""),f=Ext(),g=_=>{o(_.type),i(_.title),u(_.message)},v=async _=>{if(_.preventDefault(),!l.trim()){dn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await f.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:d.trim()||void 0}),dn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{dn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(bd,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(Kr,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(_e,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:oIt.map((_,b)=>e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>g(_),className:"text-xs",children:[e.jsx(_.icon,{className:"h-3 w-3 mr-1"}),_.title]},b))})]}),e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(tr,{value:a,onValueChange:_=>o(_),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(At,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(At,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(At,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Uc,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:l,onChange:_=>i(_.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Lr,{id:"message",value:d,onChange:_=>u(_.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:f.isPending,children:[e.jsx(bd,{className:"h-4 w-4 mr-2"}),f.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const pme={points_earned:{label:"Points Earned",icon:so,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Hn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:Uc,color:"bg-green-500"},custom:{label:"Custom",icon:gn,color:"bg-purple-500"}};function lIt(){const[t,s]=M.useState(""),[r,n]=M.useState("all"),[a,o]=M.useState("all"),{data:l=[],isLoading:i}=Tt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:f,error:g}=await K.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(g)throw g;const v=[...new Set([...f.map(w=>w.user_id),...f.map(w=>w.created_by).filter(Boolean)])],{data:_}=await K.from("profiles").select("id, name, email").in("id",v),b=new Map((_==null?void 0:_.map(w=>[w.id,w]))||[]);return f.map(w=>{var j,N,S;return{...w,user_name:((j=b.get(w.user_id))==null?void 0:j.name)||"Unknown",user_email:((N=b.get(w.user_id))==null?void 0:N.email)||"",creator_name:w.created_by?((S=b.get(w.created_by))==null?void 0:S.name)||"System":"Auto-triggered"}})}}),d=l.filter(f=>{var b,w;const g=((b=f.user_name)==null?void 0:b.toLowerCase().includes(t.toLowerCase()))||((w=f.user_email)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||f.title.toLowerCase().includes(t.toLowerCase()),v=r==="all"||f.celebration_type===r,_=a==="all"||a==="seen"&&f.seen_at||a==="unseen"&&!f.seen_at;return g&&v&&_}),u={total:l.length,seen:l.filter(f=>f.seen_at).length,unseen:l.filter(f=>!f.seen_at).length,byType:Object.keys(pme).reduce((f,g)=>(f[g]=l.filter(v=>v.celebration_type===g).length,f),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Rs,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(bd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(_r,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by agent name, email, or title...",value:t,onChange:f=>s(f.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Filter by type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),Object.entries(pme).map(([f,g])=>e.jsx(At,{value:f,children:g.label},f))]})]}),e.jsxs(tr,{value:a,onValueChange:o,children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(rr,{placeholder:"Status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Status"}),e.jsx(At,{value:"seen",children:"Seen"}),e.jsx(At,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:d.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(f=>{const g=pme[f.celebration_type],v=g.icon;return e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(v,{className:"h-3 w-3"}),g.label]})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:f.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:f.user_email})]})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:f.title}),f.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:f.message})]})}),e.jsx(lt,{children:f.points_amount?e.jsxs(nt,{variant:"secondary",children:["+",f.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:f.creator_name})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:js(new Date(f.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(lt,{children:f.seen_at?e.jsx(nt,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(nt,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},f.id)})})]})}),d.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",d.length," of ",l.length," celebrations"]})]})]})]})}const cIt=()=>{const{user:t}=Qs(),{toast:s}=La(),[r,n]=M.useState([]),[a,o]=M.useState(!0),[l,i]=M.useState(!1),[d,u]=M.useState("all"),[f,g]=M.useState("all"),[v,_]=M.useState("new"),[b,w]=M.useState(new Set),j=M.useCallback(async()=>{try{o(!0);const{data:te,error:Y}=await K.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(Y)throw Y;const{data:ce,error:oe}=await K.from("trial_email_exports").select("user_id");if(oe)throw oe;const le=new Set((ce||[]).map(xe=>xe.user_id)),de=(te||[]).map(xe=>({...xe,converted_from_trial_at:xe.converted_from_trial_at??null,already_exported:le.has(xe.id)}));de.sort((xe,be)=>new Date(be.created_at).getTime()-new Date(xe.created_at).getTime()),n(de)}catch(te){console.error("Error loading trial users:",te),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);M.useEffect(()=>{j()},[j]);const N=te=>te.trial_started_at?"ghl":"stripe",S=te=>te.trial_expires_at?te.trial_expires_at:te.subscription_end_date?te.subscription_end_date:null,A=te=>te.converted_from_trial_at!==null,I=te=>{if(A(te))return!1;const Y=S(te);return Y?new Date(Y).getTime()<=Date.now():!1},L=r.filter(te=>!(d!=="all"&&N(te)!==d||f==="active"&&(I(te)||A(te))||f==="expired"&&!I(te)||f==="converted"&&!A(te)||v==="new"&&te.already_exported||v==="exported"&&!te.already_exported)),F=()=>{b.size===L.length?w(new Set):w(new Set(L.map(te=>te.id)))},$=te=>{const Y=new Set(b);Y.has(te)?Y.delete(te):Y.add(te),w(Y)},q=async()=>{if(b.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const te=r.filter(ye=>b.has(ye.id)),Y="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ce=te.map(ye=>{const ve=(ye.name||"").split(" "),ke=ve[0]||"",Ge=ve.slice(1).join(" ")||"",Ne=N(ye)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Ae=A(ye)?"Converted":I(ye)?"Expired":"Active",Pe=ye.created_at?new Date(ye.created_at).toLocaleDateString():"",Fe=S(ye)?new Date(S(ye)).toLocaleDateString():"";return`"${ke}","${Ge}","${ye.email}","${ye.phone||""}","${Ne}","${Ae}","${Pe}","${Fe}"`}),oe=[Y,...ce].join(` `),le=new Blob([oe],{type:"text/csv"}),de=URL.createObjectURL(le),xe=document.createElement("a");xe.href=de,xe.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,xe.click(),URL.revokeObjectURL(de);const be=te.filter(ye=>!ye.already_exported).map(ye=>({user_id:ye.id,exported_by:t.id}));if(be.length>0){const{error:ye}=await K.from("trial_email_exports").upsert(be,{onConflict:"user_id"});ye&&console.error("Error marking exports:",ye)}s({title:"Export complete",description:`Downloaded ${te.length} trial user(s). ${be.length} newly marked as exported.`}),w(new Set),j()}catch(te){console.error("Export error:",te),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},H=r.filter(te=>!te.already_exported).length,U=r.filter(te=>te.already_exported).length,Q=r.filter(te=>A(te)).length,se=r.filter(te=>!I(te)&&!A(te)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Rs,{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(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"Total"}),e.jsx(Vt,{className:"text-2xl",children:r.length})]})}),e.jsx(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"New (Not Exported)"}),e.jsx(Vt,{className:"text-2xl text-green-600",children:H})]})}),e.jsx(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"Active Trials"}),e.jsx(Vt,{className:"text-2xl",children:se})]})}),e.jsx(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"Converted 🎉"}),e.jsx(Vt,{className:"text-2xl text-primary",children:Q})]})}),e.jsx(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"Already Exported"}),e.jsx(Vt,{className:"text-2xl text-muted-foreground",children:U})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(tr,{value:v,onValueChange:te=>_(te),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Users"}),e.jsx(At,{value:"new",children:"New Only"}),e.jsx(At,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(tr,{value:d,onValueChange:te=>u(te),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Trial Types"}),e.jsx(At,{value:"stripe",children:"Credit Card Trial"}),e.jsx(At,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(tr,{value:f,onValueChange:te=>g(te),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),e.jsx(At,{value:"active",children:"Active Trial"}),e.jsx(At,{value:"expired",children:"Expired"}),e.jsx(At,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(Z,{onClick:q,disabled:l||b.size===0,children:[l?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Export Selected (",b.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx($o,{checked:L.length>0&&b.size===L.length,onCheckedChange:F})}),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(Ln,{children:L.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):L.map(te=>{const Y=N(te),ce=A(te),oe=I(te),le=S(te);return e.jsxs(ks,{className:`hover:bg-muted/30 ${ce?"bg-primary/5":""}`,children:[e.jsx(lt,{children:e.jsx($o,{checked:b.has(te.id),onCheckedChange:()=>$(te.id)})}),e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[te.name,ce&&e.jsx(Vc,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(lt,{className:"text-muted-foreground",children:te.email}),e.jsx(lt,{children:Y==="stripe"?e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(cp,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Ar,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(lt,{children:ce?e.jsxs(nt,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Vc,{className:"h-3 w-3"}),"Converted"]}):oe?e.jsx(nt,{variant:"destructive",children:"Expired"}):e.jsx(nt,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(lt,{className:"text-sm",children:te.created_at?new Date(te.created_at).toLocaleDateString():"—"}),e.jsx(lt,{className:"text-sm",children:ce&&le?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(le).toLocaleDateString()]}):le?new Date(le).toLocaleDateString():"—"}),e.jsx(lt,{children:te.already_exported?e.jsx(Ma,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(nt,{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 · ",Q," converted to paid"]})]})},dIt=()=>{const[t,s]=M.useState([]),[r,n]=M.useState(!0);return M.useEffect(()=>{(async()=>{const{data:o,error:l}=await K.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(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Cr,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Oe,{children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:t.map(a=>e.jsxs(ks,{children:[e.jsx(lt,{className:"whitespace-nowrap text-sm",children:js(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(lt,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(lt,{children:a.brokerage_name||"—"}),e.jsx(lt,{children:e.jsx(nt,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(lt,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},YN=t=>{const{user:s}=Qs(),r=ds(),n=Tt({queryKey:["teams",t],queryFn:async()=>{let g=K.from("teams").select("*").order("created_at",{ascending:!1});t&&(g=g.eq("brokerage_id",t));const{data:v,error:_}=await g;if(_)throw _;return v||[]},enabled:!!s}),a=g=>Tt({queryKey:["team-members",g],queryFn:async()=>{const{data:v,error:_}=await K.from("team_members").select("*").eq("team_id",g).order("role",{ascending:!0});if(_)throw _;const b=(v||[]).map(N=>N.user_id),{data:w}=await K.from("profiles").select("id, name, email, avatar_url").in("id",b),j=new Map((w||[]).map(N=>[N.id,N]));return(v||[]).map(N=>({...N,profile:j.get(N.user_id)||null}))},enabled:!!g}),o=Bt({mutationFn:async g=>{const v={name:g.name,created_by:s.id,description:g.description,contact_visibility:g.contact_visibility,lead_pond_enabled:g.lead_pond_enabled,shared_assets_enabled:g.shared_assets_enabled};g.brokerage_id&&(v.brokerage_id=g.brokerage_id);const{data:_,error:b}=await K.from("teams").insert(v).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),ge.success("Team created!")},onError:g=>{ge.error("Failed to create team: "+g.message)}}),l=Bt({mutationFn:async({id:g,...v})=>{const{data:_,error:b}=await K.from("teams").update(v).eq("id",g).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),ge.success("Team updated")},onError:g=>{ge.error("Failed to update team: "+g.message)}}),i=Bt({mutationFn:async g=>{const{error:v}=await K.from("teams").delete().eq("id",g);if(v)throw v},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),ge.success("Team deleted")},onError:g=>{ge.error("Failed to delete team: "+g.message)}}),d=Bt({mutationFn:async g=>{const{data:v,error:_}=await K.from("team_members").insert({team_id:g.team_id,user_id:g.user_id,role:g.role||"team_member"}).select().single();if(_)throw _.message.includes("duplicate")||_.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):_;return v},onSuccess:(g,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),ge.success("Member added to team")},onError:g=>{ge.error(g.message)}}),u=Bt({mutationFn:async g=>{const{error:v}=await K.from("team_members").delete().eq("id",g.member_id);if(v)throw v},onSuccess:(g,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),ge.success("Member removed from team")},onError:g=>{ge.error("Failed to remove member: "+g.message)}}),f=Bt({mutationFn:async g=>{const{error:v}=await K.from("team_members").update({role:g.role}).eq("id",g.member_id);if(v)throw v},onSuccess:(g,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),ge.success("Member role updated")},onError:g=>{ge.error("Failed to update role: "+g.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:d,removeMember:u,updateMemberRole:f,useTeamMembers:a}},uIt=()=>{const{user:t}=Qs();return Tt({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},hWe=t=>{const{user:s}=Qs(),r=ds(),n=Tt({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:d}=await K.from("team_lead_pond").select("*").eq("team_id",t).order("created_at",{ascending:!1});if(d)throw d;if(!i||i.length===0)return[];const u=i.map(N=>N.contact_id),f=[...new Set(i.map(N=>N.added_by))],g=i.filter(N=>N.claimed_by).map(N=>N.claimed_by),v=[...new Set([...f,...g])],[_,b]=await Promise.all([K.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",u),K.from("profiles").select("id, name, avatar_url").in("id",v)]),w=new Map((_.data||[]).map(N=>[N.id,N])),j=new Map((b.data||[]).map(N=>[N.id,N]));return i.map(N=>({...N,status:N.claimed_by?"claimed":"available",contact:w.get(N.contact_id)||null,contributor:j.get(N.added_by)||null,claimer:N.claimed_by&&j.get(N.claimed_by)||null}))},enabled:!!t&&!!s}),a=Bt({mutationFn:async i=>{const{data:d,error:u}=await K.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(u)throw u;return d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),ge.success("Contact added to Lead Pond")},onError:i=>{ge.error(i.message)}}),o=Bt({mutationFn:async i=>{const{error:d}=await K.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),ge.success("Lead claimed!")},onError:i=>{ge.error(i.message)}}),l=Bt({mutationFn:async i=>{const{error:d}=await K.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),ge.success("Lead returned to pond")},onError:i=>{ge.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},hIt=()=>{const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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"]}),ge.success("Contact transferred successfully")},onError:s=>{ge.error(s.message||"Failed to transfer contact")}})};function mWe({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=Qs(),{data:l}=Ug(),{useTeamMembers:i}=YN(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),u=hIt(),[f,g]=M.useState(null),[v,_]=M.useState(""),[b,w]=M.useState(!1),j=d.filter(F=>F.user_id!==(o==null?void 0:o.id)),N=async()=>{if(f){w(!0);try{for(const F of r)await u.mutateAsync({contactId:F,toUserId:f,notes:v||void 0});s(!1),g(null),_(""),a==null||a()}catch{}finally{w(!1)}}},S=j.find(F=>F.user_id===f),A=r.length>1,I=n.length>0?A?`${n.length} contacts`:n[0]:A?`${r.length} contacts`:"this contact";return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(p0,{className:"h-5 w-5"}),"Transfer ",I]}),e.jsxs(Kr,{children:["Select a team member to transfer ",A?"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(_e,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):j.map(F=>{var $,q,H;return e.jsxs("button",{onClick:()=>g(F.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${f===F.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:(($=F.profile)==null?void 0:$.avatar_url)||""}),e.jsx(pn,{className:"text-xs",children:(((q=F.profile)==null?void 0:q.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((H=F.profile)==null?void 0:H.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:F.role.replace("_"," ")})]})]},F.user_id)})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Lr,{id:"transfer-notes",value:v,onChange:F=>_(F.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{onClick:N,disabled:!f||b,children:[b?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(p0,{className:"h-4 w-4 mr-2"}),"Transfer",S?` to ${(L=S.profile)==null?void 0:L.name}`:""]})]})]})})}const _be=()=>{const t=Or(),{data:s,isLoading:r}=uIt(),{data:n}=Ug(),[a,o]=M.useState(""),[l,i]=M.useState("all"),[d,u]=M.useState(null),[f,g]=M.useState(""),v=(n==null?void 0:n.role)==="team_leader",_=M.useMemo(()=>{if(!s)return[];const w=new Map;return s.forEach(j=>{w.has(j.owner_user_id)||w.set(j.owner_user_id,{id:j.owner_user_id,name:j.owner_name||"Unknown",avatar:j.owner_avatar_url})}),Array.from(w.values())},[s]),b=M.useMemo(()=>{if(!s)return[];let w=s;if(l!=="all"&&(w=w.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();w=w.filter(N=>{var S,A,I;return(N.first_name+" "+(N.last_name||"")).toLowerCase().includes(j)||((S=N.email)==null?void 0:S.toLowerCase().includes(j))||((A=N.phone)==null?void 0:A.includes(j))||((I=N.owner_name)==null?void 0:I.toLowerCase().includes(j))})}return w},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"h-10 w-full"}),e.jsx(gs,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(xr,{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(De,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:w=>o(w.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:l,onValueChange:i,children:[e.jsx(Js,{className:"w-[200px]",children:e.jsx(rr,{placeholder:"Filter by agent"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Team Members"}),_.map(w=>e.jsx(At,{value:w.id,children:w.name},w.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[b.length," contact",b.length!==1?"s":""," from ",_.length," teammate",_.length!==1?"s":""]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Pn,{className:"min-w-[800px]",children:[e.jsx(In,{children:e.jsxs(ks,{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"}),v&&e.jsx(kt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Ln,{children:b.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:v?7:6,className:"text-center py-8 text-muted-foreground",children:a||l!=="all"?"No contacts match your filters":"No team contacts available"})}):b.map(w=>e.jsxs(ks,{className:`hover:bg-accent/50 ${v?"cursor-pointer":""}`,onClick:v?()=>t(`/mission-control/contacts/${w.id}`):void 0,children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("span",{className:v?"hover:text-primary hover:underline transition-colors":"",children:[w.first_name," ",w.last_name||""]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(mn,{className:"h-6 w-6",children:[e.jsx(ba,{src:w.owner_avatar_url||""}),e.jsx(pn,{className:"text-[10px]",children:(w.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:w.owner_name||"Unknown"})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[w.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Ar,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:w.email})]}),w.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ga,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:w.phone})]}),!w.email&&!w.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(lt,{children:w.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Pi,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:w.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(lt,{children:w.lead_source?e.jsx(nt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:w.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:js(new Date(w.created_at),"MMM d, yyyy")})}),v&&e.jsx(lt,{children:e.jsx(Z,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:j=>{j.stopPropagation(),u(w.id),g(`${w.first_name} ${w.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(p0,{className:"h-4 w-4"})})})]},w.id))})]})})}),e.jsx(mWe,{open:!!d,onOpenChange:w=>{w||u(null)},contactIds:d?[d]:[],contactNames:f?[f]:[],onComplete:()=>u(null)})]})},bbe=({teamId:t})=>{const{user:s}=Qs(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=hWe(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(d=>e.jsx(gs,{className:"h-20 w-full"},d))});if(r.length===0)return e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(zx,{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(d=>d.status==="available"),i=r.filter(d=>d.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(d=>{var u,f,g,v,_,b,w;return e.jsx(De,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((f=d.contact)==null?void 0:f.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((g=d.contact)==null?void 0:g.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ar,{className:"h-3 w-3"})," ",d.contact.email]}),((v=d.contact)==null?void 0:v.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ga,{className:"h-3 w-3"})," ",d.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(mn,{className:"h-4 w-4",children:[e.jsx(ba,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(pn,{className:"text-[8px]",children:(((b=d.contributor)==null?void 0:b.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((w=d.contributor)==null?void 0:w.name)||"Unknown"]})]})]}),e.jsxs(Z,{size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[e.jsx(HE,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},d.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(d=>{var u,f,g;return e.jsx(De,{className:"opacity-75",children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((f=d.contact)==null?void 0:f.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(nt,{variant:"secondary",className:"text-xs",children:["Claimed by ",((g=d.claimer)==null?void 0:g.name)||"Unknown"]})})]}),d.claimed_by===(s==null?void 0:s.id)&&e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>o.mutate(d.id),disabled:o.isPending,children:[e.jsx(k0,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},pWe=({teamId:t})=>{const{useTeamMembers:s}=YN(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=Tt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await K.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(b)throw b;return _||[]},enabled:n.length>0}),{data:i=[],isLoading:d}=Tt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await K.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(b)throw b;return _||[]},enabled:n.length>0}),{data:u=[],isLoading:f}=Tt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await K.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(b)throw b;return _||[]},enabled:n.length>0});if(l||d||f)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(gs,{className:"h-20 w-full"},_))});const v=_=>{const b=a.get(_);return{name:(b==null?void 0:b.name)||"Unknown",avatar:(b==null?void 0:b.avatar_url)||"",initials:((b==null?void 0:b.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(De,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(lf,{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(De,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Hn,{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(De,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Cn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:u.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]}),e.jsxs(Ia,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsxs(Ts,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(Ts,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(Ts,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(Vs,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(fme,{icon:e.jsx(lf,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const b=v(_.owner_user_id);return e.jsx(De,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(mn,{className:"h-8 w-8 shrink-0",children:[e.jsx(ba,{src:b.avatar}),e.jsx(pn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",js(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(nt,{variant:_.status==="published"?"default":"secondary",className:"text-xs capitalize",children:_.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Na,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})}),e.jsx(Vs,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(fme,{icon:e.jsx(Hn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=v(_.agent_id);return e.jsx(De,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(mn,{className:"h-8 w-8 shrink-0",children:[e.jsx(ba,{src:b.avatar}),e.jsx(pn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",js(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(nt,{className:"text-xs",children:"Active"}):e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(xr,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx(Vs,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(fme,{icon:e.jsx(Cn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=v(_.owner_user_id);return e.jsx(De,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(mn,{className:"h-8 w-8 shrink-0",children:[e.jsx(ba,{src:b.avatar}),e.jsx(pn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.title||_.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",js(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(nt,{variant:"secondary",className:"text-xs capitalize",children:_.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Na,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},fme=({icon:t,label:s})=>e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center text-muted-foreground",children:[t,e.jsx("p",{className:"mt-2 text-sm",children:s})]})}),fWe=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:d,isAddingMember:u})=>{var $,q;const{useTeamMembers:f}=YN(),{data:g=[],isLoading:v}=f(t.id),[_,b]=M.useState(!1),[w,j]=M.useState(""),[N,S]=M.useState("team_member"),{data:A}=Tt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:H}=await K.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),U=new Map;return(H||[]).forEach(Q=>{var se;U.set(Q.user_id,((se=Q.teams)==null?void 0:se.name)||"another team")}),U}}),I=new Set(g.map(H=>H.user_id)),L=s.filter(H=>!I.has(H.id)),F=async()=>{w&&(await a(w,N),j(""),S("team_member"),b(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Z,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(Ia,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"members",children:"Members"}),e.jsxs(Ts,{value:"contacts",children:[e.jsx(Wk,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(Ts,{value:"lead-pond",children:[e.jsx(zx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(Ts,{value:"shared-assets",children:[e.jsx(Oh,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(Ts,{value:"settings",children:"Settings"})]}),e.jsxs(Vs,{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(bs,{open:_,onOpenChange:b,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{size:"sm",children:[e.jsx(pc,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Add Team Member"}),e.jsxs(Kr,{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(_e,{children:"Agent"}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[w&&((($=L.find(H=>H.id===w))==null?void 0:$.name)||((q=L.find(H=>H.id===w))==null?void 0:q.email))||"Select an agent",e.jsx(of,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search agents..."}),e.jsxs(yf,{children:[e.jsx(vf,{children:"No agents found."}),e.jsx(_f,{children:L.map(H=>{const U=A==null?void 0:A.get(H.id);return e.jsxs(_m,{value:H.name||H.email||H.id,disabled:!!U,onSelect:()=>j(H.id),children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",w===H.id?"opacity-100":"opacity-0")}),H.name||H.email,U&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",U,")"]})]},H.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Role"}),e.jsxs(tr,{value:N,onValueChange:S,children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"team_leader",children:"Team Leader"}),e.jsx(At,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(Z,{onClick:F,disabled:!w||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),v?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(H=>e.jsx(gs,{className:"h-16 w-full"},H))}):g.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(xr,{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:g.map(H=>{var U,Q,se,te,Y;return e.jsx(De,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:((U=H.profile)==null?void 0:U.avatar_url)||""}),e.jsx(pn,{children:(((Q=H.profile)==null?void 0:Q.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((se=H.profile)==null?void 0:se.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(te=H.profile)==null?void 0:te.email})]}),H.role==="team_leader"?e.jsxs(nt,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Dh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(nt,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(tr,{value:H.role,onValueChange:ce=>l(H.id,ce),children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"team_leader",children:"Team Leader"}),e.jsx(At,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(bP,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Remove Member?"}),e.jsxs(Xl,{children:["Remove ",((Y=H.profile)==null?void 0:Y.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>o(H.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},H.id)})})]}),e.jsx(Vs,{value:"contacts",className:"space-y-4",children:e.jsx(_be,{})}),t.lead_pond_enabled&&e.jsx(Vs,{value:"lead-pond",className:"space-y-4",children:e.jsx(bbe,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(Vs,{value:"shared-assets",className:"space-y-4",children:e.jsx(pWe,{teamId:t.id})}),e.jsxs(Vs,{value:"settings",className:"space-y-4",children:[e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{className:"text-lg",children:"Team Settings"}),e.jsx(_r,{children:"Configure how this team operates."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Team Name"}),e.jsx(Re,{defaultValue:t.name,onBlur:H=>{H.target.value!==t.name&&n({name:H.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{defaultValue:t.description||"",onBlur:H=>{H.target.value!==(t.description||"")&&n({description:H.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Contact Visibility"}),e.jsxs(tr,{defaultValue:t.contact_visibility,onValueChange:H=>n({contact_visibility:H}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(At,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(At,{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(_e,{children:"Lead Pond"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable a shared lead pool where leaders can drop leads for members to claim."})]}),e.jsx(qr,{checked:t.lead_pond_enabled,onCheckedChange:H=>n({lead_pond_enabled:H})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Shared Assets"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow team members to access shared presentations, guest books, and videos."})]}),e.jsx(qr,{checked:t.shared_assets_enabled,onCheckedChange:H=>n({shared_assets_enabled:H})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Shared Video Library"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Let team members browse and use each other's videos from the Video Library."})]}),e.jsx(qr,{checked:t.shared_videos_enabled??!1,onCheckedChange:H=>n({shared_videos_enabled:H})})]})]})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsxs(Z,{variant:"destructive",size:"sm",children:[e.jsx(Cr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete Team?"}),e.jsxs(Xl,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},gWe=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,u]=M.useState(1),[f,g]=M.useState(""),[v,_]=M.useState(""),[b,w]=M.useState(""),[j,N]=M.useState(""),[S,A]=M.useState([]),I=()=>{u(1),g(""),_(""),w(""),N(""),A([])},L=H=>{H||I(),s(H)},F=async()=>{const H=b&&b!=="none"?b:i||null;await r({name:f.trim(),description:v.trim()||void 0,brokerage_id:H,leaderId:j||void 0,memberIds:S.length>0?S:void 0}),I()},$=H=>{H!==j&&A(U=>U.includes(H)?U.filter(Q=>Q!==H):[...U,H])},q=a.filter(H=>H.id!==j);return e.jsx(bs,{open:t,onOpenChange:L,children:e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:d===1?"Create New Team":"Assign Team Members"}),e.jsx(Kr,{children:d===1?"Name your team and add a description.":"Pick a leader and optionally add initial members."}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("div",{className:It("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:It("h-1.5 flex-1 rounded-full transition-colors",d===2?"bg-primary":"bg-muted")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 pr-1",children:d===1?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(Re,{id:"team-name",value:f,onChange:H=>g(H.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"team-desc",children:"Description"}),e.jsx(Lr,{id:"team-desc",value:v,onChange:H=>_(H.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(_e,{children:"Brokerage"}),e.jsxs(tr,{value:b,onValueChange:w,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"No brokerage (independent team)"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No brokerage (independent)"}),l.map(H=>e.jsx(At,{value:H.id,children:H.name},H.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-1.5",children:[e.jsx(Dh,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(tr,{value:j,onValueChange:H=>{N(H),A(U=>U.filter(Q=>Q!==H))},children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select a team leader (optional)"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No leader for now"}),a.map(H=>e.jsx(At,{value:H.id,children:H.name||H.email||"Unknown"},H.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-1.5",children:[e.jsx(pc,{className:"h-3.5 w-3.5"}),"Initial Members",S.length>0&&e.jsxs(nt,{variant:"secondary",className:"ml-1 text-xs",children:[S.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:q.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(xr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):q.map(H=>{const U=S.includes(H.id);return e.jsxs("button",{type:"button",className:It("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",U&&"bg-primary/5"),onClick:()=>$(H.id),children:[e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:H.avatar_url||""}),e.jsx(pn,{className:"text-xs",children:(H.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:H.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:H.email})]}),e.jsx("div",{className:It("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",U?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:U&&e.jsx(ma,{className:"h-3 w-3"})})]},H.id)})})]})]})}),e.jsx(qn,{className:"gap-2 sm:gap-0",children:d===1?e.jsxs(e.Fragment,{children:[e.jsx(Z,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(Z,{onClick:()=>u(2),disabled:!f.trim(),children:["Next",e.jsx(Ai,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Ba,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(Z,{onClick:F,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},mIt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=YN(),[d,u]=M.useState(!1),[f,g]=M.useState(null),[v,_]=M.useState(""),{data:b}=Tt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:L,error:F}=await K.from("brokerages").select("id, name").order("name");if(F)throw F;return L||[]}}),{data:w}=Tt({queryKey:["admin-team-member-info",t.map(L=>L.id).join(",")],queryFn:async()=>{var H;if(t.length===0)return{};const{data:L}=await K.from("team_members").select("team_id, user_id, role").in("team_id",t.map(U=>U.id));if(!L)return{};const F=L.filter(U=>U.role==="team_leader").map(U=>U.user_id);let $={};if(F.length>0){const{data:U}=await K.from("profiles").select("id, name").in("id",F);U&&($=Object.fromEntries(U.map(Q=>[Q.id,{name:Q.name}])))}const q={};for(const U of t){const Q=L.filter(te=>te.team_id===U.id),se=Q.find(te=>te.role==="team_leader");q[U.id]={count:Q.length,leaderName:se&&((H=$[se.user_id])==null?void 0:H.name)||null}}return q},enabled:t.length>0}),j=(f==null?void 0:f.brokerage_id)||null,{data:N}=Tt({queryKey:["brokerage-agents-for-teams",j],queryFn:async()=>{let L=K.from("profiles").select("id, name, email, avatar_url").order("name");j&&(L=L.eq("brokerage_id",j));const{data:F,error:$}=await L;if($)throw $;return F||[]},enabled:!!f}),S=Object.fromEntries((b||[]).map(L=>[L.id,L.name])),A=async L=>{const F=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:F.id,user_id:L.leaderId,role:"team_leader"}),L.memberIds)for(const $ of L.memberIds)await o.mutateAsync({team_id:F.id,user_id:$,role:"team_member"});u(!1)};if(f)return e.jsx(fWe,{team:f,brokerageAgents:N||[],onBack:()=>g(null),onUpdate:L=>n.mutateAsync({id:f.id,...L}).then(F=>g(F)),onAddMember:(L,F)=>o.mutateAsync({team_id:f.id,user_id:L,role:F}),onRemoveMember:L=>l.mutateAsync({team_id:f.id,member_id:L}),onUpdateRole:(L,F)=>i.mutateAsync({team_id:f.id,member_id:L,role:F}),onDeleteTeam:()=>{a.mutate(f.id),g(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const I=t.filter(L=>L.name.toLowerCase().includes(v.toLowerCase())||(L.description||"").toLowerCase().includes(v.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(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search teams...",value:v,onChange:L=>_(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(Z,{size:"sm",onClick:()=>u(!0),children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(gWe,{open:d,onOpenChange:u,onCreateTeam:A,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:b,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsx(gs,{className:"h-4 w-32"})}),e.jsx(lt,{children:e.jsx(gs,{className:"h-4 w-24"})}),e.jsx(lt,{children:e.jsx(gs,{className:"h-4 w-28"})}),e.jsx(lt,{children:e.jsx(gs,{className:"h-4 w-12"})}),e.jsx(lt,{children:e.jsx(gs,{className:"h-4 w-20"})}),e.jsx(lt,{children:e.jsx(gs,{className:"h-4 w-16"})})]},L))}):I.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:v?"No teams match your search":"No teams found. Create one to get started."})}):I.map(L=>{const F=w==null?void 0:w[L.id];return e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsxs(lt,{children:[e.jsx("button",{onClick:()=>g(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(lt,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:S[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(lt,{children:F!=null&&F.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Dh,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),F.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(lt,{children:e.jsxs(nt,{variant:"secondary",className:"text-xs",children:[e.jsx(xr,{className:"h-3 w-3 mr-1"}),(F==null?void 0:F.count)??0]})}),e.jsx(lt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(Xu,{className:"h-3 w-3"}),L.contact_visibility.replace("_"," ")]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>g(L),title:"Edit team",children:e.jsx(Ga,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{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(Cr,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},pIt=()=>{const t=Or(),{user:s,isAdmin:r}=Qs(),{startImpersonation:n,isLoading:a}=x1e(),{toast:o}=La(),[l,i]=M.useState([]),[d,u]=M.useState([]),[f,g]=M.useState([]),[v,_]=M.useState({}),[b,w]=M.useState(!0),[j,N]=M.useState({}),[S,A]=M.useState(!1),[I,L]=M.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[F,$]=M.useState(!1),[q,H]=M.useState(""),[U,Q]=M.useState(1),[se,te]=M.useState(50),[Y,ce]=M.useState("all"),[oe,le]=M.useState("all"),[de,xe]=M.useState("all"),[be,ye]=M.useState("all"),[ve,ke]=M.useState(!1),[Ge,Ne]=M.useState(!1),[Ae,Pe]=M.useState(null),[Fe,Ie]=M.useState(null),[Ve,dt]=M.useState(!1),[Le,Rt]=M.useState({name:"",email:"",brokerage_id:"",phone:""}),[fe,Qe]=M.useState(null),[at,rt]=M.useState(!1),[je,mt]=M.useState(""),[He,ct]=M.useState(!1),[We,Ze]=M.useState(!1),[ht,Ke]=M.useState(null),[qe,Je]=M.useState(""),[Lt,zt]=M.useState(!1),[is,Kt]=M.useState(!1),[Qt,fs]=M.useState(null),[dr,bt]=M.useState(!1),[ws,ir]=M.useState(!1),[Rr,oa]=M.useState(null),[ri,no]=M.useState(""),[Da,yn]=M.useState(!1),[ea,Zt]=M.useState({email:"",name:"",password:"",phone:""}),[yr,Gr]=M.useState(!1),[Dn,rs]=M.useState(!1),[An,la]=M.useState(""),[qa,Jr]=M.useState(!1),[Ka,Dl]=M.useState(!1),[Lo,Kc]=M.useState(""),[it,Se]=M.useState(new Set),[ze,tt]=M.useState(!1),[Mt,Nt]=M.useState(!1),[Ot,Yt]=M.useState(null),[qt,Jt]=M.useState(!1),[Ps,xs]=M.useState(null),[hr,Br]=M.useState([]),[cr,Nn]=M.useState([]),[Sn,wn]=M.useState(!1),[ca,ao]=M.useState({});M.useEffect(()=>{!s||!r||(Ua(),Vo())},[s,r]);const zo=async()=>{try{const{data:yt,error:Ns}=await K.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Ns)throw Ns;const Hs={};for(const an of yt??[])Hs[an.brokerage_id]||(Hs[an.brokerage_id]=[]),Hs[an.brokerage_id].push(an.user_id);_(Hs)}catch(yt){console.error("Error loading brokerage manager assignments:",yt)}},Ua=async()=>{try{w(!0);const{data:yt,error:Ns}=await K.functions.invoke("get-user-details");if(Ns)throw Ns;const Hs=yt.users||[];i(Hs),g(yt.brokerages||[]),await zo();const an=Hs.filter(on=>on.roles.includes("assistant"));if(an.length>0){const on=an.map(Fr=>Fr.id),{data:Jn}=await K.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",on);if(Jn&&Jn.length>0){const Fr=[...new Set(Jn.map(Rm=>Rm.agent_id))],{data:Xi}=await K.from("profiles").select("id, name, email").in("id",Fr),Tf={};for(const Rm of Jn){const Ur=Xi==null?void 0:Xi.find(gy=>gy.id===Rm.agent_id);Ur&&(Tf[Rm.assistant_id]={agent_name:Ur.name||"",agent_email:Ur.email||""})}ao(Tf)}}}catch(yt){console.error("Error loading members:",yt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{w(!1)}},Vo=async()=>{try{const{data:yt,error:Ns}=await K.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Ns)throw Ns;u(yt||[])}catch(yt){console.error("Error loading apps:",yt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},Ki=async yt=>{if(!Le.name.trim()||!Le.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Le.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Hs}=await K.from("profiles").update({name:Le.name.trim(),email:Le.email.trim(),brokerage_id:Le.brokerage_id||null,phone:Le.phone.trim()||null}).eq("id",yt);if(Hs)throw Hs;o({title:"Success",description:"Member details updated successfully"}),Pe(null),Ua()}catch(Hs){console.error("Error updating member:",Hs),o({title:"Error",description:Hs.message||"Failed to update member",variant:"destructive"})}},xa=async yt=>{try{const{data:{session:Ns}}=await K.auth.getSession(),Hs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ns==null?void 0:Ns.access_token}`},body:JSON.stringify({userId:yt})}),an=await Hs.json();if(!Hs.ok)throw new Error(an.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Ns){console.error("Error resending welcome email:",Ns),o({title:"Error",description:Ns.message||"Failed to resend welcome email",variant:"destructive"})}},Zi=async(yt,Ns)=>{try{const{error:Hs}=await K.functions.invoke("send-password-reset",{body:{email:yt,redirectTo:window.location.origin}});if(Hs)throw Hs;o({title:"Password Reset Sent",description:`Password reset email sent to ${Ns}`})}catch(Hs){console.error("Error sending password reset:",Hs),o({title:"Error",description:Hs.message||"Failed to send password reset email",variant:"destructive"})}},mi=async(yt,Ns)=>{if(confirm(`Are you sure you want to delete ${Ns}? This action cannot be undone.`))try{const{data:{session:Hs}}=await K.auth.getSession(),an=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Hs==null?void 0:Hs.access_token}`},body:JSON.stringify({userId:yt})}),on=await an.json();if(!an.ok)throw new Error(on.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Ua()}catch(Hs){console.error("Error deleting user:",Hs),o({title:"Error",description:Hs.message||"Failed to delete user",variant:"destructive"})}},ta=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}A(!0);try{const{data:{session:yt}}=await K.auth.getSession(),Ns=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yt==null?void 0:yt.access_token}`},body:JSON.stringify(I)}),Hs=await Ns.json();if(!Ns.ok)throw new Error(Hs.error||"Failed to create user");if(I.role&&I.role!=="user"&&Hs.userId){const an=I.role==="brokerage_manager"?I.brokerage_id:void 0;await Yi(Hs.userId,I.role,"add",an)}o({title:"Success",description:`User ${I.email} created successfully`}),L({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),$(!1),Ua()}catch(yt){console.error("Error creating user:",yt),o({title:"Error",description:yt.message||"Failed to create user",variant:"destructive"})}finally{A(!1)}},Yi=async(yt,Ns,Hs,an)=>{try{const{data:{session:on}}=await K.auth.getSession(),Jn={userId:yt,role:Ns,action:Hs};if(Ns==="brokerage_manager"){if(!an){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}Jn.brokerageId=an}const Fr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${on==null?void 0:on.access_token}`},body:JSON.stringify(Jn)}),Xi=await Fr.json();if(!Fr.ok)throw new Error(Xi.error||"Failed to manage user role");o({title:"Success",description:`Role ${Hs==="add"?"added":"removed"} successfully`}),Ua()}catch(on){console.error("Error managing user role:",on),o({title:"Error",description:on.message||"Failed to manage user role",variant:"destructive"})}},tc=(yt,Ns)=>Ns.length===0?!0:Ns.some(Hs=>yt.includes(Hs)),fc=async(yt,Ns,Hs)=>{const an=`${yt}-${Ns.id}`;Qe(an);try{if(Hs){const on=l.find(Fr=>Fr.id===yt),Jn=Ns.required_tags.filter(Fr=>on==null?void 0:on.tags.includes(Fr));for(const Fr of Jn){const{error:Xi}=await K.from("user_tags").delete().eq("user_id",yt).eq("tag",Fr);if(Xi)throw Xi}o({title:"Access Removed",description:`Removed access to ${Ns.name}`})}else if(Ns.required_tags.length>0){const{error:on}=await K.from("user_tags").insert({user_id:yt,tag:Ns.required_tags[0]});if(on)throw on;o({title:"Access Granted",description:`Granted access to ${Ns.name}`})}await Ua()}catch(on){console.error("Error toggling access:",on),o({title:"Error",description:on.message||"Failed to update access",variant:"destructive"})}finally{Qe(null)}},jd=async()=>{const yt=je.trim();if(!yt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(yt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(f.find(Hs=>Hs.name.toLowerCase()===yt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}ct(!0);try{const{error:Hs}=await K.from("brokerages").insert({name:yt});if(Hs)throw Hs;o({title:"Success",description:`Brokerage "${yt}" created successfully`}),mt(""),rt(!1),Ua()}catch(Hs){console.error("Error creating brokerage:",Hs),o({title:"Error",description:Hs.message||"Failed to create brokerage",variant:"destructive"})}finally{ct(!1)}},kp=yt=>{Ke(yt),Je(yt.name),Ze(!0)},gl=()=>{Ke(null),Je(""),Ze(!1)},gu=async()=>{if(!ht)return;const yt=qe.trim();if(!yt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(yt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}zt(!0);try{const{error:Ns}=await K.from("brokerages").update({name:yt}).eq("id",ht.id);if(Ns)throw Ns;o({title:"Success",description:"Brokerage updated successfully"}),gl(),Ua()}catch(Ns){console.error("Error updating brokerage:",Ns),o({title:"Error",description:Ns.message||"Failed to update brokerage",variant:"destructive"})}finally{zt(!1)}},Zc=async(yt,Ns)=>{var Hs;if(!Ns||typeof Ns!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const an={userId:yt,role:"brokerage_manager",action:"add",brokerageId:Ns};console.debug("[assignManagerToBrokerage] payload",an);const{data:{session:on}}=await K.auth.getSession(),Jn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${on==null?void 0:on.access_token}`},body:JSON.stringify(an)}),Fr=await Jn.json();if(!Jn.ok&&!((Hs=Fr.error)!=null&&Hs.includes("duplicate")))throw new Error(Fr.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Ua()}catch(an){console.error("Error assigning manager:",an),o({title:"Error",description:an.message||"Failed to assign manager",variant:"destructive"})}},Zh=yt=>{fs(yt),Kt(!0)},xl=async()=>{if(Qt){bt(!0);try{const yt=l.filter(an=>an.brokerage_id===Qt.id),{data:{session:Ns}}=await K.auth.getSession();for(const an of yt){const on=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ns==null?void 0:Ns.access_token}`},body:JSON.stringify({userId:an.id})});if(!on.ok){const Jn=await on.json();console.error(`Failed to delete user ${an.email}:`,Jn.error)}}const{error:Hs}=await K.from("brokerages").delete().eq("id",Qt.id);if(Hs)throw Hs;o({title:"Success",description:`Brokerage "${Qt.name}" and ${yt.length} member(s) deleted`}),Kt(!1),fs(null),Ua()}catch(yt){console.error("Error deleting brokerage:",yt),o({title:"Error",description:yt.message||"Failed to delete brokerage",variant:"destructive"})}finally{bt(!1)}}},Sf=yt=>{oa(yt),no(""),ir(!0)},Kg=()=>{oa(null),no(""),ir(!1)},Q0=async yt=>{try{const{error:Ns}=await K.from("profiles").update({brokerage_id:null}).eq("id",yt);if(Ns)throw Ns;o({title:"Success",description:"User removed from brokerage"}),Ua()}catch(Ns){console.error("Error removing user from brokerage:",Ns),o({title:"Error",description:Ns.message||"Failed to remove user",variant:"destructive"})}},J0=async(yt,Ns)=>{try{const{error:Hs}=await K.from("profiles").update({brokerage_id:Ns}).eq("id",yt);if(Hs)throw Hs;o({title:"Success",description:"User added to brokerage"}),Ua()}catch(Hs){console.error("Error adding user to brokerage:",Hs),o({title:"Error",description:Hs.message||"Failed to add user",variant:"destructive"})}},ev=async()=>{if(!Rr||!ea.email||!ea.name||!ea.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Gr(!0);try{const{data:{session:yt}}=await K.auth.getSession(),Ns=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yt==null?void 0:yt.access_token}`},body:JSON.stringify({...ea,brokerage_id:Rr.id,role:"user"})}),Hs=await Ns.json();if(!Ns.ok)throw new Error(Hs.error||"Failed to create agent");o({title:"Success",description:`Agent ${ea.email} created successfully`}),Zt({email:"",name:"",password:"",phone:""}),yn(!1),Ua()}catch(yt){console.error("Error creating agent:",yt),o({title:"Error",description:yt.message||"Failed to create agent",variant:"destructive"})}finally{Gr(!1)}},Om=yt=>l.filter(Ns=>Ns.brokerage_id===yt),ih=yt=>{const Ns=Om(yt);if(!ri)return Ns;const Hs=ri.toLowerCase();return Ns.filter(an=>an.name.toLowerCase().includes(Hs)||an.email.toLowerCase().includes(Hs))},kd=yt=>l.filter(Ns=>Ns.brokerage_id!==yt),oh=l.filter(yt=>{var Hs;if(q){const an=q.toLowerCase();if(!(yt.name.toLowerCase().includes(an)||yt.email.toLowerCase().includes(an)||((Hs=yt.brokerage_name)==null?void 0:Hs.toLowerCase().includes(an))))return!1}if(Y==="claimed"&&!yt.claimed||Y==="unclaimed"&&yt.claimed||oe!=="all"&&!yt.roles.includes(oe))return!1;const Ns=yt.is_trial||yt.subscription_status==="trialing";return!(de==="trial"&&!Ns||de==="non-trial"&&Ns||be==="none"&&yt.brokerage_id||be!=="all"&&be!=="none"&&yt.brokerage_id!==be)}),{sortKey:ld,sortDirection:Yc,handleSort:Nd,sortData:Np}=NL("created_at","desc"),Sp=Np(oh,{name:yt=>{var Ns;return((Ns=yt.name)==null?void 0:Ns.toLowerCase())||""},brokerage:yt=>{var Ns;return((Ns=yt.brokerage_name)==null?void 0:Ns.toLowerCase())||""},status:yt=>yt.claimed?"active":"pending",role:yt=>yt.roles[0]||"",last_login:yt=>yt.last_sign_in_at?new Date(yt.last_sign_in_at).getTime():null,created_at:yt=>yt.created_at?new Date(yt.created_at).getTime():null}),Yh=Sp.length,Xh=se===0,Xc=Xh?1:Math.ceil(Yh/se),hy=Xh?0:(U-1)*se,Cf=Xh?Yh:hy+se,ul=Sp.slice(hy,Cf),tv=yt=>{H(yt),Q(1)},Mf=yt=>{te(yt),Q(1)},Ru=(yt,Ns)=>{yt(Ns),Q(1)},G_=async(yt,Ns)=>{ke(!0);try{const Hs=l.find(Fr=>Fr.id===yt);if(!Hs)return;const an=Hs.trial_expires_at?new Date(Hs.trial_expires_at):new Date,on=new Date(an.getTime()+Ns*24*60*60*1e3),{error:Jn}=await K.from("profiles").update({trial_expires_at:on.toISOString()}).eq("id",yt);if(Jn)throw Jn;o({title:"Trial Extended",description:`Trial extended by ${Ns} days`}),Ua()}catch(Hs){console.error("Error extending trial:",Hs),o({title:"Error",description:Hs.message||"Failed to extend trial",variant:"destructive"})}finally{ke(!1)}},rS=async yt=>{Ne(!0);try{const{error:Ns}=await K.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",yt);if(Ns)throw Ns;o({title:"Account Converted",description:"User has been converted to a full account"}),Ua(),Zg()}catch(Ns){console.error("Error converting trial:",Ns),o({title:"Error",description:Ns.message||"Failed to convert account",variant:"destructive"})}finally{Ne(!1)}},my=async yt=>{wn(!0);try{const{data:Ns}=await K.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",yt);if(Ns&&Ns.length>0){const an=Ns.map(Jn=>Jn.assistant_id),{data:on}=await K.from("profiles").select("id, name, email").in("id",an);Br(Ns.map(Jn=>{const Fr=on==null?void 0:on.find(Xi=>Xi.id===Jn.assistant_id);return{id:Jn.id,assistant_id:Jn.assistant_id,assistant_name:(Fr==null?void 0:Fr.name)||"Unknown",assistant_email:(Fr==null?void 0:Fr.email)||"",permissions:Jn.permissions||{}}}))}else Br([]);const{data:Hs}=await K.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",yt);if(Hs&&Hs.length>0){const an=Hs.map(Jn=>Jn.agent_id),{data:on}=await K.from("profiles").select("id, name, email").in("id",an);Nn(Hs.map(Jn=>{const Fr=on==null?void 0:on.find(Xi=>Xi.id===Jn.agent_id);return{id:Jn.id,agent_id:Jn.agent_id,agent_name:(Fr==null?void 0:Fr.name)||"Unknown",agent_email:(Fr==null?void 0:Fr.email)||"",permissions:Jn.permissions||{}}}))}else Nn([])}catch(Ns){console.error("Error loading assistant data:",Ns)}finally{wn(!1)}},ya=yt=>{Ie(yt),Rt({name:yt.name,email:yt.email,brokerage_id:yt.brokerage_id||"",phone:yt.phone||""}),dt(!0),my(yt.id)},Zg=()=>{Ie(null),dt(!1),Rt({name:"",email:"",brokerage_id:"",phone:""})},K_=async()=>{Fe&&(await Ki(Fe.id),Zg())},nS=yt=>{Se(Ns=>{const Hs=new Set(Ns);return Hs.has(yt)?Hs.delete(yt):Hs.add(yt),Hs})},aS=()=>{if(it.size===ul.length&&ul.every(yt=>it.has(yt.id))){const yt=new Set(it);ul.forEach(Ns=>yt.delete(Ns.id)),Se(yt)}else{const yt=new Set(it);ul.forEach(Ns=>yt.add(Ns.id)),Se(yt)}},lh=()=>{Se(new Set)},py=async()=>{if(it.size===0)return;tt(!0);let yt=0,Ns=0;try{const{data:{session:Hs}}=await K.auth.getSession();for(const an of it)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Hs==null?void 0:Hs.access_token}`},body:JSON.stringify({userId:an})})).ok?yt++:Ns++}catch{Ns++}o({title:"Bulk Email Complete",description:`Sent ${yt} emails${Ns>0?`, ${Ns} failed`:""}`}),lh()}catch(Hs){o({title:"Error",description:Hs.message||"Failed to send emails",variant:"destructive"})}finally{tt(!1)}},fy=async()=>{if(it.size===0)return;tt(!0);let yt=0,Ns=0;try{const{data:{session:Hs}}=await K.auth.getSession();for(const an of it)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Hs==null?void 0:Hs.access_token}`},body:JSON.stringify({userId:an})})).ok?yt++:Ns++}catch{Ns++}o({title:"Bulk Password Reset Complete",description:`Sent ${yt} reset emails${Ns>0?`, ${Ns} failed`:""}`}),lh()}catch(Hs){o({title:"Error",description:Hs.message||"Failed to send password reset emails",variant:"destructive"})}finally{tt(!1)}},Z_=async()=>{if(it.size===0)return;const yt=l.filter(on=>it.has(on.id)).map(on=>on.name).slice(0,5).join(", "),Ns=it.size>5?` and ${it.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${it.size} users (${yt}${Ns})? This action cannot be undone.`))return;tt(!0);let Hs=0,an=0;try{const{data:{session:on}}=await K.auth.getSession();for(const Jn of it)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${on==null?void 0:on.access_token}`},body:JSON.stringify({userId:Jn})})).ok?Hs++:an++}catch{an++}o({title:"Bulk Delete Complete",description:`Deleted ${Hs} users${an>0?`, ${an} failed`:""}`}),lh(),Ua()}catch(on){o({title:"Error",description:on.message||"Failed to delete users",variant:"destructive"})}finally{tt(!1)}},sv=async()=>{Nt(!0);try{const{data:{session:yt}}=await K.auth.getSession(),Ns=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yt==null?void 0:yt.access_token}`}});if(!Ns.ok){const an=await Ns.json();throw new Error(an.error||"Failed to sync phones")}const Hs=await Ns.json();o({title:"Phone Sync Complete",description:`Pulled ${Hs.summary.pulledFromGHL} from GHL, pushed ${Hs.summary.pushedToGHL} to GHL, ${Hs.summary.alreadySynced} already synced`}),Ua()}catch(yt){o({title:"Error",description:yt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{Nt(!1)}},Qh=async(yt,Ns)=>{Yt(yt);try{const{data:{session:Hs}}=await K.auth.getSession(),{data:an}=await K.from("profiles").select("phone").eq("id",yt).single(),on=(an==null?void 0:an.phone)||"",Jn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Hs==null?void 0:Hs.access_token}`},body:JSON.stringify({email:Ns,action:"update",phone:on||void 0})});if(!Jn.ok){const Xi=await Jn.json();throw new Error(Xi.error||"Failed to sync with GHL")}const Fr=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Ns)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:on?`Phone ${on} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),Ua()}catch(Hs){o({title:"Error",description:Hs.message||"Failed to sync phone",variant:"destructive"})}finally{Yt(null)}},Yg=async yt=>{await n(yt)},Y_=()=>{if(it.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const yt=l.filter(Xi=>it.has(Xi.id)),Ns=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Hs=yt.map(Xi=>[Xi.name,Xi.email,Xi.phone||"",Xi.brokerage_name||"",Xi.roles.join("; "),Xi.claimed?"Claimed":"Unclaimed",new Date(Xi.created_at).toLocaleDateString()]),an=[Ns.join(","),...Hs.map(Xi=>Xi.map(Tf=>`"${(Tf||"").replace(/"/g,'""')}"`).join(","))].join(` `),on=new Blob([an],{type:"text/csv"}),Jn=URL.createObjectURL(on),Fr=document.createElement("a");Fr.href=Jn,Fr.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Fr.click(),URL.revokeObjectURL(Jn),o({title:"Export complete",description:`Exported ${yt.length} member(s)`})};return b?e.jsx(Ms,{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(Ms,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{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(Z,{size:"sm",variant:"outline",onClick:sv,disabled:Mt,children:[Mt?e.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(ga,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:Mt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:Mt?"Syncing...":"Sync GHL"})]}),e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>rs(!0),children:[e.jsx(x0,{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(bs,{open:F,onOpenChange:$,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{size:"sm",children:[e.jsx(pc,{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(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create New User"}),e.jsx(Kr,{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(_e,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",placeholder:"John Doe",value:I.name,onChange:yt=>L({...I,name:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",placeholder:"john@example.com",value:I.email,onChange:yt=>L({...I,email:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"password",children:"Password"}),e.jsx(Re,{id:"password",type:"password",placeholder:"Min 6 characters",value:I.password,onChange:yt=>L({...I,password:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"555-123-4567",value:I.phone,onChange:yt=>L({...I,phone:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"brokerage",children:["Brokerage",I.role==="brokerage_manager"?" (required)":""]}),e.jsxs(tr,{value:I.brokerage_id||"none",onValueChange:yt=>L({...I,brokerage_id:yt==="none"?"":yt}),children:[e.jsx(Js,{id:"brokerage",children:e.jsx(rr,{placeholder:I.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"None"}),f.map(yt=>e.jsx(At,{value:yt.id,children:yt.name},yt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"role",children:"Role"}),e.jsxs(tr,{value:I.role,onValueChange:yt=>L({...I,role:yt}),children:[e.jsx(Js,{id:"role",children:e.jsx(rr,{placeholder:"Select role"})}),e.jsxs(er,{children:[e.jsx(At,{value:"user",children:"User"}),e.jsx(At,{value:"moderator",children:"Moderator"}),e.jsx(At,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(At,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(tr,{value:I.trial_days||"none",onValueChange:yt=>L({...I,trial_days:yt==="none"?"":yt}),children:[e.jsx(Js,{id:"trial_days",children:e.jsx(rr,{placeholder:"No trial (full access)"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No trial (full access)"}),e.jsx(At,{value:"7",children:"7-day trial"}),e.jsx(At,{value:"30",children:"30-day trial"}),e.jsx(At,{value:"60",children:"60-day trial"}),e.jsx(At,{value:"90",children:"90-day trial"}),e.jsx(At,{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(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(Z,{onClick:ta,disabled:S,children:S?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(Ia,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"members",children:"Members"}),e.jsx(Ts,{value:"brokerages",children:"Brokerages"}),e.jsx(Ts,{value:"teams",children:"Teams"}),e.jsx(Ts,{value:"trials",children:"Trial Users"}),e.jsx(Ts,{value:"access",children:"Access Matrix"}),e.jsx(Ts,{value:"celebrations",children:"Celebrations"}),e.jsx(Ts,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(Vs,{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(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search members...",value:q,onChange:yt=>tv(yt.target.value),className:"pl-10 h-9"})]}),e.jsxs(tr,{value:Y,onValueChange:yt=>Ru(ce,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Status"}),e.jsx(At,{value:"claimed",children:"Active"}),e.jsx(At,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(tr,{value:oe,onValueChange:yt=>Ru(le,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Roles"}),e.jsx(At,{value:"admin",children:"Admin"}),e.jsx(At,{value:"brokerage_manager",children:"Manager"}),e.jsx(At,{value:"assistant",children:"Assistant"}),e.jsx(At,{value:"user",children:"User"})]})]}),e.jsxs(tr,{value:de,onValueChange:yt=>Ru(xe,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Users"}),e.jsx(At,{value:"trial",children:"Trial Only"}),e.jsx(At,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(tr,{value:be,onValueChange:yt=>Ru(ye,yt),children:[e.jsx(Js,{className:"w-[150px] h-9",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Brokerages"}),e.jsx(At,{value:"none",children:"No Brokerage"}),f.map(yt=>e.jsx(At,{value:yt.id,children:yt.name},yt.id))]})]}),(q||Y!=="all"||oe!=="all"||de!=="all"||be!=="all")&&e.jsxs(Z,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{H(""),ce("all"),le("all"),xe("all"),ye("all"),Q(1)},children:[e.jsx(Vr,{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:Xh?`Showing all ${Yh} members`:`Showing ${hy+1}-${Math.min(Cf,Yh)} of ${Yh} members`}),e.jsxs(tr,{value:se.toString(),onValueChange:yt=>Mf(Number(yt)),children:[e.jsx(Js,{className:"h-9 w-[110px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"50",children:"50 / page"}),e.jsx(At,{value:"100",children:"100 / page"}),e.jsx(At,{value:"250",children:"250 / page"}),e.jsx(At,{value:"0",children:"All"})]})]})]})]}),it.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(e0,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[it.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Z,{size:"sm",variant:"outline",onClick:py,disabled:ze,children:[ze?e.jsx(Rs,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Ar,{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(Z,{size:"sm",variant:"outline",onClick:fy,disabled:ze,children:[ze?e.jsx(Rs,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Sm,{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(Z,{size:"sm",variant:"outline",onClick:Y_,children:[e.jsx(Ei,{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(Z,{size:"sm",variant:"destructive",onClick:Z_,disabled:ze,children:[ze?e.jsx(Rs,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Cr,{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(Z,{size:"sm",variant:"ghost",onClick:lh,disabled:ze,children:e.jsx(Vr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"w-[50px]",children:e.jsx($o,{checked:ul.length>0&&ul.every(yt=>it.has(yt.id)),onCheckedChange:aS,"aria-label":"Select all on page"})}),e.jsx(Qo,{sortKey:"name",currentSortKey:ld,currentDirection:Yc,onSort:Nd,children:"Name"}),e.jsx(Qo,{sortKey:"brokerage",currentSortKey:ld,currentDirection:Yc,onSort:Nd,children:"Brokerage"}),e.jsx(Qo,{sortKey:"status",currentSortKey:ld,currentDirection:Yc,onSort:Nd,children:"Status"}),e.jsx(Qo,{sortKey:"role",currentSortKey:ld,currentDirection:Yc,onSort:Nd,children:"Role"}),e.jsx(Qo,{sortKey:"last_login",currentSortKey:ld,currentDirection:Yc,onSort:Nd,children:"Last Login"}),e.jsx(Qo,{sortKey:"created_at",currentSortKey:ld,currentDirection:Yc,onSort:Nd,children:"Member Since"}),e.jsx(kt,{className:"w-[100px]"})]})}),e.jsx(Ln,{children:ul.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):ul.map(yt=>e.jsxs(ks,{className:`hover:bg-muted/30 ${it.has(yt.id)?"bg-primary/5":""}`,children:[e.jsx(lt,{children:e.jsx($o,{checked:it.has(yt.id),onCheckedChange:()=>nS(yt.id),"aria-label":`Select ${yt.name}`})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>ya(yt),className:"text-primary hover:underline font-medium text-left",children:yt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:yt.email})]})}),e.jsx(lt,{className:"text-muted-foreground",children:yt.brokerage_name||"—"}),e.jsx(lt,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Ns=yt.is_trial&&yt.trial_expires_at||!yt.is_trial&&yt.subscription_status==="trialing"&&yt.subscription_end_date,Hs=yt.trial_expires_at||yt.subscription_end_date;if(Ns&&Hs){const an=Math.ceil((new Date(Hs).getTime()-Date.now())/864e5),on=an<=0,Jn=an<=3;return e.jsx(nt,{variant:"outline",className:It("w-fit",on?"border-destructive text-destructive":Jn?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:on?"Trial Expired":`Trial · ${an}d left`})}return e.jsx(nt,{variant:yt.claimed?"default":"secondary",className:yt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:yt.claimed?"Active":"Pending"})})()})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col",children:[yt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:yt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),yt.roles.includes("assistant")&&ca[yt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",ca[yt.id].agent_name||ca[yt.id].agent_email]})]})}),e.jsx(lt,{className:"text-muted-foreground",children:yt.last_sign_in_at?new Date(yt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(lt,{className:"text-muted-foreground",children:yt.created_at?new Date(yt.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{xs(yt),Jt(!0)},title:"Send celebration",children:e.jsx(bd,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ya(yt),title:"Edit member",children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Qh(yt.id,yt.email),disabled:Ot===yt.id,title:"Sync phone with GHL",children:Ot===yt.id?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>xa(yt.id),title:"Resend welcome email",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Zi(yt.email,yt.name),title:"Send password reset",children:e.jsx(Kk,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>Yg(yt.id),disabled:a||yt.id===(s==null?void 0:s.id),title:yt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${yt.name}`,children:a?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(a5,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>mi(yt.id,yt.name),title:"Delete user",children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},yt.id))})]})}),Xc>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 ",U," of ",Xc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>Q(1),disabled:U===1,children:"First"}),e.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Q(yt=>Math.max(1,yt-1)),disabled:U===1,children:e.jsx(ec,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Xc)},(yt,Ns)=>{let Hs;return Xc<=5||U<=3?Hs=Ns+1:U>=Xc-2?Hs=Xc-4+Ns:Hs=U-2+Ns,e.jsx(Z,{variant:U===Hs?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>Q(Hs),children:Hs},Hs)})}),e.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Q(yt=>Math.min(Xc,yt+1)),disabled:U===Xc,children:e.jsx(ei,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>Q(Xc),disabled:U===Xc,children:"Last"})]})]})]}),e.jsx(bs,{open:Ve,onOpenChange:dt,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Member"}),e.jsx(Kr,{children:"Update member details, roles, and app access"})]}),Fe&&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(_e,{htmlFor:"edit-name",children:"Name"}),e.jsx(Re,{id:"edit-name",value:Le.name,onChange:yt=>Rt({...Le,name:yt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"edit-email",children:"Email"}),e.jsx(Re,{id:"edit-email",type:"email",value:Le.email,onChange:yt=>Rt({...Le,email:yt.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(_e,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Re,{id:"edit-phone",type:"tel",value:Le.phone,onChange:yt=>Rt({...Le,phone:yt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(tr,{value:Le.brokerage_id||"none",onValueChange:yt=>Rt({...Le,brokerage_id:yt==="none"?"":yt}),children:[e.jsx(Js,{id:"edit-brokerage",children:e.jsx(rr,{placeholder:"Select brokerage"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"None"}),f.map(yt=>e.jsx(At,{value:yt.id,children:yt.name},yt.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:[Fe.roles.map(yt=>e.jsxs(nt,{variant:"default",className:"gap-1",children:[e.jsx(Xu,{className:"h-3 w-3"}),yt,yt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>Yi(Fe.id,yt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Vr,{className:"h-3 w-3"})})]},yt)),Fe.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(tr,{onValueChange:yt=>Yi(Fe.id,yt,"add"),children:[e.jsx(Js,{className:"w-[200px]",children:e.jsx(rr,{placeholder:"Add role..."})}),e.jsxs(er,{children:[!Fe.roles.includes("admin")&&e.jsx(At,{value:"admin",children:"Admin"}),!Fe.roles.includes("user")&&e.jsx(At,{value:"user",children:"User"})]})]}),!Fe.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"})]}),(hr.length>0||cr.length>0||Fe.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(xr,{className:"h-4 w-4"}),"Assistant Relationships"]}),Sn?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Rs,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[hr.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:"}),hr.map(yt=>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:yt.assistant_name}),e.jsx(nt,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:yt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(yt.permissions).filter(([,Ns])=>Ns).map(([Ns])=>e.jsx(nt,{variant:"secondary",className:"text-[10px] capitalize",children:Ns},Ns))})]},yt.id))]}),cr.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:"}),cr.map(yt=>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:yt.agent_name}),e.jsx(nt,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:yt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(yt.permissions).filter(([,Ns])=>Ns).map(([Ns])=>e.jsx(nt,{variant:"secondary",className:"text-[10px] capitalize",children:Ns},Ns))})]},yt.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:d.map(yt=>{const Ns=tc(Fe.tags,yt.required_tags),Hs=`${Fe.id}-${yt.id}`,an=fe===Hs,on=yt.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:yt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:yt.name}),on&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:an?e.jsx(Rs,{className:"h-4 w-4 animate-spin text-muted-foreground"}):on?e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(qr,{checked:Ns,onCheckedChange:()=>fc(Fe.id,yt,Ns)})})]},yt.id)})})]}),(Fe.is_trial||Fe.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(Tn,{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:[Fe.trial_expires_at&&e.jsx(lTe,{expiresAt:Fe.trial_expires_at}),!Fe.trial_expires_at&&Fe.subscription_status==="trialing"&&Fe.subscription_end_date&&e.jsx(lTe,{expiresAt:Fe.subscription_end_date})]}),(Fe.trial_expires_at||Fe.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Fe.trial_expires_at||Fe.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>G_(Fe.id,7),disabled:ve,children:[e.jsx(V1,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>G_(Fe.id,14),disabled:ve,children:[e.jsx(V1,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>G_(Fe.id,30),disabled:ve,children:[e.jsx(V1,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(Z,{size:"sm",variant:"default",onClick:()=>rS(Fe.id),disabled:Ge,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(J1,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Fe.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Fe.trial_started_at).toLocaleDateString(),Fe.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Fe.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:[Fe.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Fe.email_confirmed_at).toLocaleString()]}),Fe.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Fe.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Fe.created_at).toLocaleString()]})]})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:Zg,children:"Cancel"}),e.jsx(Z,{onClick:K_,children:"Save Changes"})]})]})}),e.jsxs(Vs,{value:"access",children:[d.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(Z,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Member Access Matrix"}),e.jsx(_r,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),d.map(yt=>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:yt.icon}),e.jsx("span",{className:"text-sm",children:yt.name})]})},yt.id))]})}),e.jsxs("tbody",{children:[ul.map(yt=>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:yt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:yt.email})]})}),d.map(Ns=>{const Hs=tc(yt.tags,Ns.required_tags),an=`${yt.id}-${Ns.id}`,on=fe===an;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:on?e.jsx(Rs,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(qr,{checked:Hs,onCheckedChange:()=>fc(yt.id,Ns,Hs),disabled:Ns.required_tags.length===0})})},Ns.id)})]},yt.id)),ul.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:d.length+1,className:"p-8 text-center text-muted-foreground",children:"No members found"})})]})]})}),Xc>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 ",hy+1,"-",Math.min(Cf,Yh)," of ",Yh," • Page ",U," of ",Xc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Q(yt=>Math.max(1,yt-1)),disabled:U===1,children:e.jsx(ec,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Q(yt=>Math.min(Xc,yt+1)),disabled:U===Xc,children:e.jsx(ei,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(Z,{variant:"outline",onClick:()=>t("/admin/apps"),children:"Manage Apps"})})]}),e.jsxs(Vs,{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(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search brokerages...",value:An,onChange:yt=>la(yt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[f.filter(yt=>yt.name.toLowerCase().includes(An.toLowerCase())).length," of ",f.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>{const yt=[];for(const Fr of f){const Xi=v[Fr.id]??[];for(const Tf of Xi){const Rm=l.find(Ur=>Ur.id===Tf);if(Rm){const Ur=(Rm.name||"").trim().split(/\s+/),gy=Ur[0]||"",xy=Ur.slice(1).join(" ")||"";yt.push({firstName:gy,lastName:xy,email:Rm.email,brokerageName:Fr.name})}}}if(yt.length===0){o({title:"No managers found to export"});return}const Hs=[["First Name","Last Name","Email","Brokerage Name"].join(","),...yt.map(Fr=>[Fr.firstName,Fr.lastName,Fr.email,Fr.brokerageName].map(Xi=>`"${(Xi||"").replace(/"/g,'""')}"`).join(","))].join(` `),an=new Blob([Hs],{type:"text/csv"}),on=URL.createObjectURL(an),Jn=document.createElement("a");Jn.href=on,Jn.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,Jn.click(),URL.revokeObjectURL(on),o({title:`Exported ${yt.length} managers`})},children:[e.jsx(Ei,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(bs,{open:at,onOpenChange:rt,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{size:"sm",children:[e.jsx(_a,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create New Brokerage"}),e.jsx(Kr,{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(_e,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Re,{id:"brokerage-name",placeholder:"Enter brokerage name",value:je,onChange:yt=>mt(yt.target.value),maxLength:100})]})}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>rt(!1),children:"Cancel"}),e.jsx(Z,{onClick:jd,disabled:He,children:He?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:(()=>{const yt=f.filter(Ns=>Ns.name.toLowerCase().includes(An.toLowerCase()));return yt.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:An?"No brokerages match your search":"No brokerages found"})}):yt.map(Ns=>{const Hs=l.filter(Fr=>Fr.brokerage_id===Ns.id),on=(v[Ns.id]??[]).map(Fr=>l.find(Xi=>Xi.id===Fr)).filter(Boolean),Jn=Hs.length;return e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsx(lt,{children:e.jsx("button",{onClick:()=>kp(Ns),className:"text-primary hover:underline font-medium",children:Ns.name})}),e.jsx(lt,{children:on.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:on.map(Fr=>e.jsx(nt,{variant:"secondary",className:"text-xs",children:Fr.name},Fr.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(lt,{children:[Jn," member",Jn!==1?"s":""]}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(Z,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Sf(Ns),children:[e.jsx(xr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>kp(Ns),title:"Edit brokerage",children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Zh(Ns),title:"Delete brokerage",children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},Ns.id)})})()})]})}),e.jsx(bs,{open:We,onOpenChange:Ze,children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Brokerage"}),e.jsx(Kr,{children:"Update brokerage details and manage managers"})]}),ht&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(Re,{id:"edit-brokerage-name",value:qe,onChange:yt=>Je(yt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{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 Ns=(v[ht.id]??[]).map(Hs=>l.find(an=>an.id===Hs)).filter(Boolean);return Ns.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Ns.map(Hs=>e.jsxs(nt,{variant:"default",className:"gap-1",children:[e.jsx(Xu,{className:"h-3 w-3"}),Hs.name,e.jsx("button",{onClick:()=>Yi(Hs.id,"brokerage_manager","remove",ht.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Vr,{className:"h-3 w-3"})})]},Hs.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(No,{open:qa,onOpenChange:Jr,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",role:"combobox","aria-expanded":qa,className:"w-full justify-between",children:["Search for a member...",e.jsx(xn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-full p-0",align:"start",children:e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search by name or email..."}),e.jsxs(yf,{className:"max-h-[200px]",children:[e.jsx(vf,{children:"No members found."}),e.jsx(_f,{children:(()=>{const yt=new Set(v[ht.id]??[]);return l.filter(Ns=>!yt.has(Ns.id)&&(r||Ns.brokerage_id===ht.id)).map(Ns=>e.jsxs(_m,{value:`${Ns.name} ${Ns.email}`,onSelect:()=>{Zc(Ns.id,ht.id),Jr(!1)},children:[Ns.name," (",Ns.email,")"]},Ns.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(yt=>yt.brokerage_id===ht.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(yt=>yt.brokerage_id===ht.id).map(yt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:yt.name}),yt.roles.includes("brokerage_manager")&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Manager"})]},yt.id))})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:gl,children:"Cancel"}),e.jsx(Z,{onClick:gu,disabled:Lt,children:Lt?"Saving...":"Save Changes"})]})]})}),e.jsx(bs,{open:is,onOpenChange:Kt,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Kr,{children:['Are you sure you want to delete "',Qt==null?void 0:Qt.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 "',Qt==null?void 0:Qt.name,'"']}),e.jsxs("li",{children:["All ",l.filter(yt=>yt.brokerage_id===(Qt==null?void 0:Qt.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>Kt(!1),children:"Cancel"}),e.jsx(Z,{variant:"destructive",onClick:xl,disabled:dr,children:dr?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(bs,{open:ws,onOpenChange:ir,children:e.jsxs(_s,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(_a,{className:"h-5 w-5"}),"Manage ",Rr==null?void 0:Rr.name]}),e.jsx(Kr,{children:"Add, remove, or manage users in this brokerage"})]}),Rr&&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(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search members...",value:ri,onChange:yt=>no(yt.target.value),className:"pl-10 h-9"})]}),e.jsxs(bs,{open:Da,onOpenChange:yn,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{size:"sm",children:[e.jsx(pc,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Add New Agent"}),e.jsxs(Kr,{children:["Create a new agent for ",Rr.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"agent-name",children:"Name"}),e.jsx(Re,{id:"agent-name",placeholder:"John Doe",value:ea.name,onChange:yt=>Zt({...ea,name:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"agent-email",children:"Email"}),e.jsx(Re,{id:"agent-email",type:"email",placeholder:"john@example.com",value:ea.email,onChange:yt=>Zt({...ea,email:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"agent-password",children:"Password"}),e.jsx(Re,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:ea.password,onChange:yt=>Zt({...ea,password:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(Re,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:ea.phone,onChange:yt=>Zt({...ea,phone:yt.target.value})})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>yn(!1),children:"Cancel"}),e.jsx(Z,{onClick:ev,disabled:yr,children:yr?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(No,{open:Ka,onOpenChange:Dl,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",role:"combobox","aria-expanded":Ka,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(xn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search users...",value:Lo,onValueChange:Kc}),e.jsxs(yf,{children:[e.jsx(vf,{children:"No users found."}),e.jsx(_f,{children:kd(Rr.id).filter(yt=>Lo===""||yt.name.toLowerCase().includes(Lo.toLowerCase())||yt.email.toLowerCase().includes(Lo.toLowerCase())).map(yt=>e.jsxs(_m,{value:`${yt.name} ${yt.email}`,onSelect:()=>{J0(yt.id,Rr.id),Dl(!1),Kc("")},children:[yt.name," (",yt.email,")"]},yt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:ih(Rr.id).length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:ri?"No matching members found":"No members in this brokerage"})}):ih(Rr.id).map(yt=>e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsx(lt,{className:"font-medium",children:yt.name}),e.jsx(lt,{className:"text-muted-foreground",children:yt.email}),e.jsx(lt,{children:yt.claimed?e.jsx(nt,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(nt,{variant:"secondary",children:"Pending"})}),e.jsx(lt,{children:yt.roles.includes("brokerage_manager")?e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(Xu,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!yt.claimed&&e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>xa(yt.id),title:"Resend welcome email",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Q0(yt.id),title:"Remove from brokerage",children:e.jsx(Vr,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>Yg(yt.id),disabled:a||yt.id===(s==null?void 0:s.id),title:yt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${yt.name}`,children:a?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(a5,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>mi(yt.id,yt.name),title:"Delete user",children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},yt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Om(Rr.id).length," total member",Om(Rr.id).length!==1?"s":""," •",Om(Rr.id).filter(yt=>yt.roles.includes("brokerage_manager")).length," manager",Om(Rr.id).filter(yt=>yt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(qn,{children:e.jsx(Z,{variant:"outline",onClick:Kg,children:"Close"})})]})})]}),e.jsx(Vs,{value:"teams",children:e.jsx(mIt,{})}),e.jsx(Vs,{value:"trials",children:e.jsx(cIt,{})}),e.jsx(Vs,{value:"celebrations",children:e.jsx(lIt,{})}),e.jsx(Vs,{value:"deletions",children:e.jsx(dIt,{})})]})]}),e.jsx(dWe,{open:Dn,onOpenChange:rs,brokerages:f,onSuccess:Ua}),Ps&&e.jsx(uWe,{open:qt,onOpenChange:yt=>{Jt(yt),yt||xs(null)},userId:Ps.id,userName:Ps.name})]})},fIt=()=>{const[t,s]=M.useState([]),[r,n]=M.useState(!0),[a,o]=M.useState(!1),[l,i]=M.useState(""),[d,u]=M.useState(""),[f,g]=M.useState(""),[v,_]=M.useState("");M.useEffect(()=>{b()},[]);const b=async()=>{const{data:L,error:F}=await K.from("invite_codes").select("*").order("created_at",{ascending:!1});F?(ge.error("Failed to load invite codes"),console.error(F)):s(L||[]),n(!1)},w=async L=>{if(L.preventDefault(),!l.trim()){ge.error("Please enter a code");return}o(!0);const{error:F}=await K.from("invite_codes").insert({code:l.trim().toUpperCase(),description:d.trim()||null,max_uses:f?parseInt(f):null,trial_days:v?parseInt(v):null});F?F.code==="23505"?ge.error("This code already exists"):(ge.error("Failed to create invite code"),console.error(F)):(ge.success("Invite code created"),i(""),u(""),g(""),_(""),b()),o(!1)},j=async(L,F)=>{const{error:$}=await K.from("invite_codes").update({is_active:!F}).eq("id",L);$?ge.error("Failed to update code"):s(t.map(q=>q.id===L?{...q,is_active:!F}:q))},N=async L=>{const{error:F}=await K.from("invite_codes").delete().eq("id",L);F?ge.error("Failed to delete code"):(ge.success("Code deleted"),s(t.filter($=>$.id!==L)))},S="https://dashboard.relevelup.com",A=L=>{const F=`${S}/join?code=${L}`;navigator.clipboard.writeText(F),ge.success("Link copied to clipboard")},I=`${S}/join`;return e.jsx(Ms,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Create New Code"}),e.jsxs(_r,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:I})]})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:w,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"code",children:"Code"}),e.jsx(Re,{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(_e,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Re,{id:"description",placeholder:"For marketing campaign",value:d,onChange:L=>u(L.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(Re,{id:"maxUses",type:"number",placeholder:"Unlimited",value:f,onChange:L=>g(L.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(Re,{id:"trialDays",type:"number",placeholder:"None",value:v,onChange:L=>_(L.target.value),className:"w-28"})]}),e.jsxs(Z,{type:"submit",disabled:a,children:[a?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Active Codes"})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Rs,{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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:t.map(L=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-mono font-medium",children:L.code}),e.jsx(lt,{className:"text-muted-foreground",children:L.description||"—"}),e.jsxs(lt,{children:[L.uses_count,L.max_uses&&` / ${L.max_uses}`]}),e.jsx(lt,{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(lt,{className:"text-muted-foreground",children:js(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsx(qr,{checked:L.is_active,onCheckedChange:()=>j(L.id,L.is_active)})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>A(L.code),title:"Copy invite link",children:e.jsx(Ni,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>N(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},SL=async t=>{try{const{data:s,error:r}=await K.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}},mM=async t=>{try{const{data:s,error:r}=await K.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}}},gIt=async(t,s)=>await SL("new_templates")?mM({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}),xIt=async(t,s)=>mM({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),yIt=async(t,s)=>await SL("new_events")?mM({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),vIt=async(t,s)=>await SL("new_toolbox")?mM({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),wxe=async(t,s)=>await SL("new_social_swag")?mM({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}),_It=async(t,s)=>await SL("new_newsletters")?mM({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),B8={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 bIt(){const t=Or(),s=ds(),[r,n]=M.useState(!1),[a,o]=M.useState(null),[l,i]=M.useState(B8),[d,u]=M.useState(null),[f,g]=M.useState(null),[v,_]=M.useState(!1),b=M.useRef(null),[w,j]=M.useState(!1),[N,S]=M.useState(null),[A,I]=M.useState(!1),[L,F]=M.useState(null),[$,q]=M.useState(null),[H,U]=M.useState(!0),[Q,se]=M.useState(""),{data:te,isLoading:Y}=Tt({queryKey:["admin-events"],queryFn:async()=>{const{data:je,error:mt}=await K.from("events").select("*").order("event_date",{ascending:!0});if(mt)throw mt;return je}}),{data:ce}=Tt({queryKey:["event-registrations-count"],queryFn:async()=>{const{data:je,error:mt}=await K.from("event_registrations").select("event_id");if(mt)throw mt;const He={};return je.forEach(ct=>{He[ct.event_id]=(He[ct.event_id]||0)+1}),He}}),{data:oe,isLoading:le}=Tt({queryKey:["event-registrations-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:je,error:mt}=await K.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(mt)throw mt;if(!je||je.length===0)return[];const He=je.map(Ze=>Ze.user_id).filter(Boolean);let ct=[];if(He.length>0){const{data:Ze,error:ht}=await K.from("profiles").select("id, name, email").in("id",He);if(ht)throw ht;ct=Ze||[]}const We=new Map((ct==null?void 0:ct.map(Ze=>[Ze.id,Ze]))||[]);return je.map(Ze=>({...Ze,profiles:Ze.user_id&&We.get(Ze.user_id)||null}))},enabled:!!N}),{data:de,isLoading:xe}=Tt({queryKey:["event-attendees-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:je,error:mt}=await K.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(mt)throw mt;if(!je||je.length===0)return[];const He=je.map(Ke=>Ke.user_id).filter(Boolean);let ct=[];if(He.length>0){const{data:Ke,error:qe}=await K.from("profiles").select("id, name, email").in("id",He);if(qe)throw qe;ct=Ke||[]}const{data:We}=await K.from("agent_points").select("user_id").eq("event_id",N.id),Ze=new Set((We==null?void 0:We.map(Ke=>Ke.user_id))||[]),ht=new Map((ct==null?void 0:ct.map(Ke=>[Ke.id,Ke]))||[]);return je.map(Ke=>({...Ke,profiles:Ke.user_id&&ht.get(Ke.user_id)||null,points_awarded:Ke.user_id?Ze.has(Ke.user_id):!1}))},enabled:!!N}),be=je=>{S(je),j(!0)},ye=Bt({mutationFn:async je=>{const{data:{session:mt}}=await K.auth.getSession();if(!mt)throw new Error("Not authenticated");const He=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${mt.access_token}`},body:JSON.stringify({event_id:je})}),ct=await He.json();if(!He.ok)throw new Error(ct.error||"Failed to sync");return ct},onSuccess:je=>{s.invalidateQueries({queryKey:["event-registrations-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),ge.success(je.message)},onError:je=>{ge.error("Failed to sync: "+je.message)}}),ve=Bt({mutationFn:async je=>{const{data:{session:mt}}=await K.auth.getSession();if(!mt)throw new Error("Not authenticated");const He=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${mt.access_token}`},body:JSON.stringify({event_id:je})}),ct=await He.json();if(!He.ok)throw new Error(ct.error||"Failed to sync attendees");return ct},onSuccess:je=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),je!=null&&je.message?ge.success(je.message):ge.success(`Synced ${je.synced||0} attendees. ${je.points_awarded||0} points awarded!`)},onError:je=>{ge.error("Failed to sync attendees: "+je.message)}}),ke=Bt({mutationFn:async({eventId:je,testMode:mt})=>{const{data:{session:He}}=await K.auth.getSession();if(!He)throw new Error("Not authenticated");const ct=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${He.access_token}`},body:JSON.stringify({event_id:je,test_mode:mt})}),We=await ct.json();if(!ct.ok)throw new Error(We.error||"Failed to send reminders");return We},onSuccess:je=>{je.test?ge.success(je.message||"Test email sent!"):ge.success(je.message||`Reminder emails sent to ${je.sent} registrants!`)},onError:je=>{ge.error("Failed to send reminders: "+je.message)}}),{data:Ge}=Tt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let je=[],mt=0;const He=1e3;for(;;){const{data:ct,error:We}=await K.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(mt,mt+He-1);if(We)throw We;if(!ct||ct.length===0||(je=[...je,...ct],ct.length{const{error:We}=await K.from("event_attendees").update({user_id:mt}).eq("id",je);if(We)throw We;if(ct&&He){const{error:ht}=await K.from("zoom_email_aliases").upsert({user_id:mt,zoom_email:He.toLowerCase()},{onConflict:"zoom_email"});ht&&console.error("Failed to save alias:",ht)}const Ze=N==null?void 0:N.id;if(Ze){const{data:ht}=await K.from("user_roles").select("id").eq("user_id",mt).eq("role","admin").single();if(!ht){const{data:Ke}=await K.from("agent_points").select("id").eq("user_id",mt).eq("event_id",Ze).single();Ke||(await K.rpc("award_attendance_points",{p_user_id:mt,p_event_id:Ze,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await K.rpc("check_and_award_badges",{p_user_id:mt}))}}return{userId:mt,zoomEmail:He,shouldSaveAlias:ct}},onSuccess:je=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let mt="Attendee linked and points awarded!";je.shouldSaveAlias&&je.zoomEmail&&(mt+=` Email "${je.zoomEmail}" will be auto-matched in the future.`),ge.success(mt),I(!1),F(null),q(null),se("")},onError:je=>{ge.error("Failed to link attendee: "+je.message)}}),Ae=je=>{F(je),q(null),U(!0),se(""),I(!0)},Pe=()=>{!L||!$||Ne.mutate({attendeeId:L.id,userId:$,zoomEmail:L.zoom_email,shouldSaveAlias:H})},Fe=(Ge==null?void 0:Ge.filter(je=>{var He,ct;if(!Q)return!0;const mt=Q.toLowerCase();return((He=je.name)==null?void 0:He.toLowerCase().includes(mt))||((ct=je.email)==null?void 0:ct.toLowerCase().includes(mt))}))||[],Ie=async je=>{const mt=je.name.split(".").pop(),ct=`${`${crypto.randomUUID()}.${mt}`}`,{error:We}=await K.storage.from("event-images").upload(ct,je);if(We)throw We;const{data:{publicUrl:Ze}}=K.storage.from("event-images").getPublicUrl(ct);return Ze},Ve=je=>{var He;const mt=(He=je.target.files)==null?void 0:He[0];if(mt){if(mt.size>5*1024*1024){ge.error("Image must be less than 5MB");return}u(mt),g(URL.createObjectURL(mt))}},dt=()=>{u(null),g(null),i({...l,image_url:""}),b.current&&(b.current.value="")},Le=Bt({mutationFn:async je=>{_(!0);let mt=je.image_url;d&&(mt=await Ie(d)||"");const He=new Date(je.event_date),[ct,We]=je.event_time.split(":");He.setHours(parseInt(ct),parseInt(We));const Ze=[new Date(He)];if(je.is_recurring&&je.recurrence_end_date){let Je=new Date(He);for(;je.recurrence_pattern==="weekly"?Je=vk(Je,1):je.recurrence_pattern==="biweekly"?Je=vk(Je,2):Je=$h(Je,1),!(Je>je.recurrence_end_date);)Ze.push(new Date(Je))}const ht=Ze.map(Je=>({title:je.title,description:je.description||null,image_url:mt||null,video_url:je.video_url||null,event_date:Je.toISOString(),zoom_link:je.zoom_link,zoom_meeting_id:je.zoom_meeting_id||null,capacity:je.capacity?parseInt(je.capacity):null,is_published:je.is_published})),{data:Ke,error:qe}=await K.from("events").insert(ht).select();if(qe)throw qe;return Ke&&Ke.length>0&&yIt(je.title,Ke[0].id),Ze.length},onSuccess:je=>{s.invalidateQueries({queryKey:["admin-events"]}),ge.success(je>1?`${je} recurring events created successfully`:"Event created successfully"),n(!1),i(B8),u(null),g(null),_(!1)},onError:je=>{ge.error("Failed to create event: "+je.message),_(!1)}}),Rt=Bt({mutationFn:async({id:je,data:mt})=>{_(!0);let He=mt.image_url;d&&(He=await Ie(d)||"");const ct=new Date(mt.event_date),[We,Ze]=mt.event_time.split(":");ct.setHours(parseInt(We),parseInt(Ze));const{error:ht}=await K.from("events").update({title:mt.title,description:mt.description||null,image_url:He||null,video_url:mt.video_url||null,event_date:ct.toISOString(),zoom_link:mt.zoom_link,zoom_meeting_id:mt.zoom_meeting_id||null,capacity:mt.capacity?parseInt(mt.capacity):null,is_published:mt.is_published}).eq("id",je);if(ht)throw ht},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),ge.success("Event updated successfully"),n(!1),o(null),i(B8),u(null),g(null),_(!1)},onError:je=>{ge.error("Failed to update event: "+je.message),_(!1)}}),fe=Bt({mutationFn:async je=>{const{error:mt}=await K.from("events").delete().eq("id",je);if(mt)throw mt},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),ge.success("Event deleted successfully")},onError:je=>{ge.error("Failed to delete event: "+je.message)}}),Qe=je=>{var He;const mt=new Date(je.event_date);o(je),i({title:je.title,description:je.description||"",image_url:je.image_url||"",video_url:je.video_url||"",event_date:mt,event_time:js(mt,"HH:mm"),zoom_link:je.zoom_link,zoom_meeting_id:je.zoom_meeting_id||"",capacity:((He=je.capacity)==null?void 0:He.toString())||"",is_published:je.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),g(je.image_url||null),u(null),n(!0)},at=je=>{if(je.preventDefault(),!l.event_date){ge.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){ge.error("Please select an end date for recurring events");return}a?Rt.mutate({id:a.id,data:l}):Le.mutate(l)},rt=()=>{n(!1),o(null),i(B8),u(null),g(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(Z,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(Ba,{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(De,{className:"mb-6",children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsx(Vt,{children:"All Events"}),e.jsxs(bs,{open:r,onOpenChange:je=>!je&&rt(),children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{onClick:()=>n(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:at,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:l.title,onChange:je=>i({...l,title:je.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Wg,{content:l.description,onChange:je=>i({...l,description:je}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Event Image"}),e.jsx("input",{type:"file",ref:b,accept:"image/*",onChange:Ve,className:"hidden"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(Z,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:dt,children:e.jsx(Vr,{className:"h-4 w-4"})})]}):e.jsxs(Z,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var je;return(je=b.current)==null?void 0:je.click()},children:[e.jsx(xi,{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(_e,{children:"Date *"}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),l.event_date?js(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:l.event_date,onSelect:je=>i({...l,event_date:je}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"time",children:"Time *"}),e.jsx(Re,{id:"time",type:"time",value:l.event_time,onChange:je=>i({...l,event_time:je.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(Re,{id:"zoom_link",value:l.zoom_link,onChange:je=>i({...l,zoom_link:je.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(Re,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:je=>i({...l,zoom_meeting_id:je.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(_e,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(Re,{id:"video_url",value:l.video_url,onChange:je=>i({...l,video_url:je.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(_e,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(Re,{id:"capacity",type:"number",value:l.capacity,onChange:je=>i({...l,capacity:je.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(cP,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(qr,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:je=>i({...l,is_recurring:je})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Frequency"}),e.jsxs(tr,{value:l.recurrence_pattern,onValueChange:je=>i({...l,recurrence_pattern:je}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"weekly",children:"Weekly"}),e.jsx(At,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(At,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Repeat Until"}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?js(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:l.recurrence_end_date,onSelect:je=>i({...l,recurrence_end_date:je}),disabled:je=>je<(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 je=1,mt=new Date(l.event_date);for(;mt=l.recurrence_pattern==="weekly"?vk(mt,1):l.recurrence_pattern==="biweekly"?vk(mt,2):$h(mt,1),!(mt>l.recurrence_end_date);)je++;return je})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{htmlFor:"is_published",children:"Published"}),e.jsx(qr,{id:"is_published",checked:l.is_published,onCheckedChange:je=>i({...l,is_published:je})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:rt,className:"flex-1",children:"Cancel"}),e.jsx(Z,{type:"submit",className:"flex-1",disabled:Le.isPending||Rt.isPending||v,children:v?"Uploading...":a?"Update Event":l.is_recurring&&l.event_date&&l.recurrence_end_date?"Create Recurring Events":"Create Event"})]})]})]})]})]}),e.jsx(Oe,{children:Y?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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:te==null?void 0:te.map(je=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:je.title}),e.jsx(lt,{children:js(new Date(je.event_date),"PPP p")}),e.jsx(lt,{children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>be(je),children:[e.jsx(xr,{className:"h-4 w-4"}),(ce==null?void 0:ce[je.id])||0,je.capacity&&` / ${je.capacity}`]})}),e.jsx(lt,{children:e.jsx("span",{className:It("px-2 py-1 rounded-full text-xs font-medium",je.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:je.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>window.open(je.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(un,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>Qe(je),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&fe.mutate(je.id)},children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},je.id))})]})})]}),e.jsx(bs,{open:w,onOpenChange:j,children:e.jsxs(_s,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),N==null?void 0:N.title]}),e.jsx(Kr,{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(Z,{variant:"ghost",size:"sm",onClick:()=>ke.mutate({eventId:N.id,testMode:!0}),disabled:ke.isPending,children:[e.jsx(Ar,{className:It("h-4 w-4 mr-2",ke.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>ke.mutate({eventId:N.id}),disabled:ke.isPending||!(oe!=null&&oe.length),children:[e.jsx(Ar,{className:It("h-4 w-4 mr-2",ke.isPending&&"animate-spin")}),ke.isPending?"Sending...":"Send Reminder to All"]}),(N==null?void 0:N.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>ye.mutate(N.id),disabled:ye.isPending,children:[e.jsx(Ao,{className:It("h-4 w-4 mr-2",ye.isPending&&"animate-spin")}),ye.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(Z,{variant:"default",size:"sm",onClick:()=>ve.mutate(N.id),disabled:ve.isPending,children:[e.jsx(so,{className:It("h-4 w-4 mr-2",ve.isPending&&"animate-spin")}),ve.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(Ia,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ts,{value:"registrations",className:"gap-2",children:[e.jsx(xr,{className:"h-4 w-4"}),"Registrations (",(oe==null?void 0:oe.length)||0,")"]}),e.jsxs(Ts,{value:"attendees",className:"gap-2",children:[e.jsx(Ma,{className:"h-4 w-4"}),"Attendees (",(de==null?void 0:de.length)||0,")"]})]}),e.jsx(Vs,{value:"registrations",className:"mt-4",children:le?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(oe==null?void 0:oe.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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Registered"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(Ln,{children:oe==null?void 0:oe.map(je=>{var We,Ze;const mt=((We=je.profiles)==null?void 0:We.name)||je.zoom_name||"Unknown",He=((Ze=je.profiles)==null?void 0:Ze.email)||je.zoom_email||null,ct=!je.user_id;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[mt,ct&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(lt,{children:He?e.jsxs("a",{href:`mailto:${He}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(Ar,{className:"h-3 w-3"}),He]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(lt,{className:"text-muted-foreground text-sm",children:js(new Date(je.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(lt,{children:je.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"})})]},je.id)})})]})}),e.jsx(Vs,{value:"attendees",className:"mt-4",children:xe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(de==null?void 0:de.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:[(de==null?void 0:de.filter(je=>!je.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(Yo,{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 (",de==null?void 0:de.filter(je=>!je.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:de==null?void 0:de.filter(je=>!je.user_id).map(je=>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:je.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:je.zoom_email||"No email"})]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>Ae(je),className:"gap-1",children:[e.jsx(Al,{className:"h-3 w-3"}),"Link to Profile"]})]},je.id))})]}),e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Duration"}),e.jsx(kt,{children:"Points"})]})}),e.jsx(Ln,{children:de==null?void 0:de.filter(je=>je.user_id).map(je=>{var ct,We;const mt=((ct=je.profiles)==null?void 0:ct.name)||je.zoom_name||"Unknown",He=((We=je.profiles)==null?void 0:We.email)||je.zoom_email||null;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[mt,je.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(lt,{children:He?e.jsxs("a",{href:`mailto:${He}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(Ar,{className:"h-3 w-3"}),He]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(lt,{children:je.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(Tn,{className:"h-3 w-3"}),je.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:je.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(so,{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"})})]},je.id)})})]})]})})]})]})}),e.jsx(bs,{open:A,onOpenChange:I,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Al,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(Kr,{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(_e,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:Q,onChange:je=>se(je.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Fe.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:Fe.slice(0,20).map(je=>e.jsxs("button",{type:"button",onClick:()=>q(je.id),className:It("w-full p-3 text-left hover:bg-muted/50 transition-colors",$===je.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:je.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:je.email})]},je.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx($o,{id:"save-alias",checked:H,onCheckedChange:je=>U(je)}),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(Z,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(Z,{onClick:Pe,disabled:!$||Ne.isPending,children:Ne.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function wIt({selectedKitIds:t,onChange:s}){const[r,n]=M.useState(""),[a,o]=M.useState(!1),{data:l=[]}=Tt({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:g,error:v}=await K.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(v)throw v;return g}}),i=l.filter(g=>t.includes(g.id)),d=l.filter(g=>!t.includes(g.id)&&g.name.toLowerCase().includes(r.toLowerCase())),u=g=>{s([...t,g])},f=g=>{s(t.filter(v=>v!==g))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{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(g=>e.jsxs(nt,{variant:"secondary",className:"gap-1 pr-1",children:[g.name,e.jsx("button",{type:"button",onClick:()=>f(g.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Vr,{className:"h-3 w-3"})})]},g.id))}),e.jsxs(No,{open:a,onOpenChange:o,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(cl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(jo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(xn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search toolkits...",value:r,onChange:g=>n(g.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:d.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No toolkits found":"All toolkits selected"}):d.map(g=>e.jsxs("button",{type:"button",onClick:()=>{u(g.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:[g.featured_image_url?e.jsx("img",{src:g.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:g.name})]},g.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link toolkits that agents can download alongside this template."})]})}const jIt=()=>{const{user:t}=Qs(),{toast:s}=La(),r=ds(),[n,a]=Gc(),[o,l]=M.useState(!1),[i,d]=M.useState(null),[u,f]=M.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:""}),[g,v]=M.useState(null),[_,b]=M.useState(0),[w,j]=M.useState(!1),[N,S]=M.useState(null),[A,I]=M.useState(""),[L,F]=M.useState([]),[$,q]=M.useState(""),[H,U]=M.useState(""),[Q,se]=M.useState(!1),[te,Y]=M.useState(!1),{data:ce=[]}=Tt({queryKey:["template-categories"],queryFn:async()=>{const{data:Qe,error:at}=await K.from("template_categories").select("*").order("name");if(at)throw at;return Qe}}),{data:oe=[]}=Tt({queryKey:["template-types"],queryFn:async()=>{const{data:Qe,error:at}=await K.from("template_types").select("*").order("name");if(at)throw at;return Qe}}),{data:le=[],isLoading:de}=Tt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Qe,error:at}=await K.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(at)throw at;const{data:rt,error:je}=await K.from("template_links").select("*").order("sort_order");if(je)throw je;const{data:mt,error:He}=await K.from("template_guides").select("*").order("sort_order");if(He)throw He;return Qe.map(We=>({...We,links:(rt==null?void 0:rt.filter(Ze=>Ze.template_id===We.id))||[],guides:(mt==null?void 0:mt.filter(Ze=>Ze.template_id===We.id))||[]}))}});M.useEffect(()=>{const Qe=n.get("edit");if(Qe&&le.length>0){const at=le.find(rt=>rt.id===Qe);at&&(Ge(at),a({},{replace:!0}))}},[le,n]);const xe=Bt({mutationFn:async Qe=>{const{data:at,error:rt}=await K.from("template_categories").insert({name:Qe}).select().single();if(rt)throw rt;return at},onSuccess:Qe=>{r.invalidateQueries({queryKey:["template-categories"]}),f({...u,category_id:Qe.id}),q(""),se(!1),s({title:"Category added"})},onError:Qe=>{s({title:"Error adding category",description:Qe.message,variant:"destructive"})}}),be=Bt({mutationFn:async Qe=>{const{data:at,error:rt}=await K.from("template_types").insert({name:Qe}).select().single();if(rt)throw rt;return at},onSuccess:Qe=>{r.invalidateQueries({queryKey:["template-types"]}),f({...u,type_id:Qe.id}),U(""),Y(!1),s({title:"Type added"})},onError:Qe=>{s({title:"Error adding type",description:Qe.message,variant:"destructive"})}}),ye=Bt({mutationFn:async Qe=>{var He;let at=Qe.existingImageUrl;if(Qe.image){const ct=Qe.image.name.split(".").pop(),We=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ct}`,{error:Ze}=await K.storage.from("template-previews").upload(We,Qe.image);if(Ze)throw Ze;const{data:ht}=K.storage.from("template-previews").getPublicUrl(We);at=ht.publicUrl}const rt={name:Qe.template.name,description:Qe.template.description||null,category_id:Qe.template.category_id||null,type_id:Qe.template.type_id||null,preview_image_url:at,video_url:Qe.videoUrl||null,publish_date:Qe.template.publish_date?new Date(Qe.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let je=Qe.templateId;if(je){const{error:ct}=await K.from("canva_templates").update(rt).eq("id",je);if(ct)throw ct;const{error:We}=await K.from("template_links").delete().eq("template_id",je);if(We)throw We;const Ze=((He=Qe.existingGuides)==null?void 0:He.map(qe=>qe.id).filter(Boolean))||[],ht=Qe.template.guides.map(qe=>qe.id).filter(Boolean),Ke=Ze.filter(qe=>!ht.includes(qe));Ke.length>0&&await K.from("template_guides").delete().in("id",Ke)}else{const{data:ct,error:We}=await K.from("canva_templates").insert(rt).select().single();if(We)throw We;je=ct.id,gIt(Qe.template.name,ct.id)}const mt=Qe.template.links.filter(ct=>ct.title.trim()&&ct.canva_share_link.trim());if(mt.length>0){const ct=mt.map((Ze,ht)=>({template_id:je,title:Ze.title.trim(),canva_share_link:Ze.canva_share_link.trim(),sort_order:ht})),{error:We}=await K.from("template_links").insert(ct);if(We)throw We}for(let ct=0;ct0)){const{error:ct}=await K.from("resource_kit_templates").insert(Qe.linkedKitIds.map(We=>({template_id:je,kit_id:We})));if(ct)throw ct}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),ke(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Qe=>{s({title:"Error saving template",description:Qe.message,variant:"destructive"})}}),ve=Bt({mutationFn:async Qe=>{const{error:at}=await K.from("canva_templates").delete().eq("id",Qe);if(at)throw at},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Qe=>{s({title:"Error deleting template",description:Qe.message,variant:"destructive"})}}),ke=()=>{f({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),S(null),I(""),d(null),se(!1),Y(!1),q(""),U(""),v(null),b(0),j(!1),F([])},Ge=async Qe=>{var rt;d(Qe),f({name:Qe.name,description:Qe.description||"",category_id:Qe.category_id||"",type_id:Qe.type_id||"",publish_date:Qe.publish_date?new Date(Qe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Qe.links&&Qe.links.length>0?Qe.links.map(je=>({id:je.id,title:je.title,canva_share_link:je.canva_share_link,sort_order:je.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((rt=Qe.guides)==null?void 0:rt.map(je=>({id:je.id,name:je.name,file_url:je.file_url,file_type:je.file_type,file_size:je.file_size,sort_order:je.sort_order})))||[],video_url:Qe.video_url||""}),I(Qe.preview_image_url||""),v(null);const{data:at}=await K.from("resource_kit_templates").select("kit_id").eq("template_id",Qe.id);F((at||[]).map(je=>je.kit_id)),l(!0)},Ne=Qe=>{var rt;const at=(rt=Qe.target.files)==null?void 0:rt[0];at&&(S(at),I(URL.createObjectURL(at)))},Ae=()=>{f({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Pe=Qe=>{if(u.links.length<=1)return;const at=u.links.filter((rt,je)=>je!==Qe);f({...u,links:at})},Fe=(Qe,at,rt)=>{const je=[...u.links];je[Qe]={...je[Qe],[at]:rt},f({...u,links:je})},Ie=Qe=>{const at=Qe.target.files;if(!at)return;const rt=Array.from(at).map((je,mt)=>({name:je.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:je.type,file_size:je.size,sort_order:u.guides.length+mt,file:je}));f({...u,guides:[...u.guides,...rt]}),Qe.target.value=""},Ve=Qe=>{const at=u.guides.filter((rt,je)=>je!==Qe);f({...u,guides:at})},dt=(Qe,at)=>{const rt=[...u.guides];rt[Qe]={...rt[Qe],name:at},f({...u,guides:rt})},Le=async()=>{if(!g)return null;j(!0),b(0);try{const{data:Qe,error:at}=await K.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||g.name}});if(at)throw new Error(at.message);const{videoId:rt,libraryId:je}=Qe,{data:mt,error:He}=await K.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:rt}});if(He)throw new Error(He.message);const ct=new XMLHttpRequest;return await new Promise((Ze,ht)=>{ct.upload.addEventListener("progress",Ke=>{if(Ke.lengthComputable){const qe=Math.round(Ke.loaded/Ke.total*100);b(qe)}}),ct.addEventListener("load",()=>{ct.status>=200&&ct.status<300?Ze():ht(new Error(`Upload failed with status ${ct.status}`))}),ct.addEventListener("error",()=>ht(new Error("Upload failed"))),ct.open("PUT",mt.uploadUrl),ct.setRequestHeader("AccessKey",mt.apiKey),ct.send(g)}),`https://player.mediadelivery.net/embed/${je}/${rt}`}catch(Qe){return console.error("Bunny upload error:",Qe),s({title:"Video upload failed",description:Qe instanceof Error?Qe.message:"Unknown error",variant:"destructive"}),null}finally{j(!1)}},Rt=Qe=>{var rt;const at=(rt=Qe.target.files)==null?void 0:rt[0];at&&v(at),Qe.target.value=""},fe=async Qe=>{if(Qe.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(je=>je.title.trim()&&je.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let rt=u.video_url;if(g){const je=await Le();if(!je)return;rt=je}ye.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:rt,linkedKitIds:L})};return e.jsx(Ms,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:le.length})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ce.length})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:oe.length})})]})]}),e.jsxs(bs,{open:o,onOpenChange:Qe=>{l(Qe),Qe||ke()},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:fe,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name *"}),e.jsx(Re,{id:"name",value:u.name,onChange:Qe=>f({...u,name:Qe.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Wg,{content:u.description,onChange:Qe=>f({...u,description:Qe}),placeholder:"Brief description of the template",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Canva Links *"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:Ae,className:"gap-1",children:[e.jsx(Ys,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((Qe,at)=>e.jsxs("div",{className:"flex gap-2 items-start p-3 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Re,{value:Qe.title,onChange:rt=>Fe(at,"title",rt.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Re,{value:Qe.canva_share_link,onChange:rt=>Fe(at,"canva_share_link",rt.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Pe(at),children:e.jsx(Vr,{className:"h-4 w-4"})})]},at))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Category"}),Q?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:$,onChange:Qe=>q(Qe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(Z,{type:"button",size:"sm",onClick:()=>$.trim()&&xe.mutate($.trim()),disabled:xe.isPending,children:"Add"}),e.jsx(Z,{type:"button",size:"sm",variant:"ghost",onClick:()=>{se(!1),q("")},children:e.jsx(Vr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:u.category_id,onValueChange:Qe=>f({...u,category_id:Qe}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(er,{children:ce.map(Qe=>e.jsx(At,{value:Qe.id,children:Qe.name},Qe.id))})]}),e.jsx(Z,{type:"button",variant:"outline",size:"icon",onClick:()=>se(!0),children:e.jsx(Ys,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Template Type"}),te?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:H,onChange:Qe=>U(Qe.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(Z,{type:"button",size:"sm",onClick:()=>H.trim()&&be.mutate(H.trim()),disabled:be.isPending,children:"Add"}),e.jsx(Z,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Y(!1),U("")},children:e.jsx(Vr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:u.type_id,onValueChange:Qe=>f({...u,type_id:Qe}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select type"})}),e.jsx(er,{children:oe.map(Qe=>e.jsx(At,{value:Qe.id,children:Qe.name},Qe.id))})]}),e.jsx(Z,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!0),children:e.jsx(Ys,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:u.publish_date,onChange:Qe=>f({...u,publish_date:Qe.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[A?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:A,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx(Z,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{S(null),I("")},children:e.jsx(Vr,{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(Xo,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Re,{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(_e,{children:"Video (Optional)"}),u.video_url&&!g?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(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>f({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):w?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(wo,{value:_,className:"h-2"})]}):g?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:g.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(g.size/1024/1024).toFixed(1)," MB"]}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>v(null),children:e.jsx(Vr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Re,{type:"file",accept:"video/*",onChange:Rt,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(_e,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Re,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:Ie,className:"hidden"}),e.jsx(Z,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(xi,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Qe,at)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(Un,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Re,{value:Qe.name,onChange:rt=>dt(at,rt.target.value),placeholder:"Guide name",className:"flex-1"}),Qe.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Qe.file_size/1024).toFixed(0)," KB"]}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Ve(at),children:e.jsx(Vr,{className:"h-4 w-4"})})]},Qe.id||at))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No guide files added. Upload PDFs to help agents understand how to use this template."})]}),e.jsx(wIt,{selectedKitIds:L,onChange:F}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>{l(!1),ke()},children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:ye.isPending,children:ye.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:de?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):le.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:le.map(Qe=>{var at,rt,je,mt,He;return e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Qe.preview_image_url?e.jsx("img",{src:Qe.preview_image_url,alt:Qe.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Xo,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(lt,{className:"font-medium",children:Qe.name}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(nt,{variant:"secondary",children:[((at=Qe.links)==null?void 0:at.length)||0," link",(((rt=Qe.links)==null?void 0:rt.length)||0)!==1?"s":""]}),(((je=Qe.guides)==null?void 0:je.length)||0)>0&&e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),(mt=Qe.guides)==null?void 0:mt.length," guide",(((He=Qe.guides)==null?void 0:He.length)||0)!==1?"s":""]})]})}),e.jsx(lt,{children:Qe.category?e.jsx(nt,{variant:"secondary",children:Qe.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(lt,{children:Qe.type?e.jsx(nt,{variant:"outline",children:Qe.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(lt,{className:"text-muted-foreground",children:new Date(Qe.publish_date).toLocaleDateString()}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{size:"icon",variant:"ghost",onClick:()=>Ge(Qe),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&ve.mutate(Qe.id)},children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},Qe.id)})})]})})})]})})};function xWe({selectedTemplateIds:t,onChange:s}){const[r,n]=M.useState(""),[a,o]=M.useState(!1),{data:l=[]}=Tt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:g,error:v}=await K.from("canva_templates").select("id, name, preview_image_url").order("name");if(v)throw v;return g}}),i=l.filter(g=>t.includes(g.id)),d=l.filter(g=>!t.includes(g.id)&&g.name.toLowerCase().includes(r.toLowerCase())),u=g=>{s([...t,g])},f=g=>{s(t.filter(v=>v!==g))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(Yk,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(g=>e.jsxs(nt,{variant:"secondary",className:"gap-1 pr-1",children:[g.name,e.jsx("button",{type:"button",onClick:()=>f(g.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Vr,{className:"h-3 w-3"})})]},g.id))}),e.jsxs(No,{open:a,onOpenChange:o,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(Yk,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(jo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(xn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search templates...",value:r,onChange:g=>n(g.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:d.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No templates found":"All templates selected"}):d.map(g=>e.jsxs("button",{type:"button",onClick:()=>{u(g.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:[g.preview_image_url?e.jsx("img",{src:g.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(Yk,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link templates that agents can use alongside this content."})]})}const kIt=[{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"}],NIt=()=>{const{user:t}=Qs(),[s,r]=Gc(),{toast:n}=La(),a=ds(),[o,l]=M.useState(!1),[i,d]=M.useState(null),[u,f]=M.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[g,v]=M.useState(null),[_,b]=M.useState(""),[w,j]=M.useState([]),[N,S]=M.useState([]),[A,I]=M.useState([]),[L,F]=M.useState([]),[$,q]=M.useState(""),[H,U]=M.useState(!1),[Q,se]=M.useState(null),[te,Y]=M.useState(0),[ce,oe]=M.useState(!1),[le,de]=M.useState(null),{data:xe=[]}=Tt({queryKey:["academy-categories"],queryFn:async()=>{const{data:fe,error:Qe}=await K.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Qe)throw Qe;return fe}}),{data:be=[],isLoading:ye}=Tt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:fe,error:Qe}=await K.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Qe)throw Qe;const{data:at,error:rt}=await K.from("academy_resources").select("*").order("sort_order");if(rt)throw rt;return fe.map(mt=>({...mt,resources:(at==null?void 0:at.filter(He=>He.video_id===mt.id))||[]}))}});M.useEffect(()=>{const fe=s.get("edit");if(fe&&be.length>0){const Qe=be.find(at=>at.id===fe);Qe&&(Pe(Qe),r({},{replace:!0}))}},[be,s]);const ve=Bt({mutationFn:async fe=>{const{data:Qe,error:at}=await K.from("academy_categories").insert({name:fe,sort_order:xe.length}).select().single();if(at)throw at;return Qe},onSuccess:fe=>{a.invalidateQueries({queryKey:["academy-categories"]}),f({...u,category_id:fe.id}),q(""),U(!1),n({title:"Category added"})},onError:fe=>{n({title:"Error adding category",description:fe.message,variant:"destructive"})}}),ke=Bt({mutationFn:async fe=>{let Qe=fe.existingThumbnailUrl;if(fe.thumbnail){const je=fe.thumbnail.name.split(".").pop(),mt=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${je}`,{error:He}=await K.storage.from("academy-resources").upload(mt,fe.thumbnail);if(He)throw He;const{data:ct}=K.storage.from("academy-resources").getPublicUrl(mt);Qe=ct.publicUrl}const at={title:fe.video.title,description:fe.video.description||null,video_url:fe.video.video_url,video_type:fe.video.video_type,duration:fe.video.duration||null,thumbnail_url:Qe,category_id:fe.video.category_id||null,publish_date:fe.video.publish_date?new Date(fe.video.publish_date).toISOString():new Date().toISOString(),is_published:fe.video.is_published,created_by:t==null?void 0:t.id};let rt=fe.videoId;if(rt){const{error:je}=await K.from("academy_videos").update(at).eq("id",rt);if(je)throw je}else{const{data:je,error:mt}=await K.from("academy_videos").insert(at).select().single();if(mt)throw mt;rt=je.id,xIt(fe.video.title,je.id)}if(fe.resourcesToDelete.length>0){const{error:je}=await K.from("academy_resources").delete().in("id",fe.resourcesToDelete);if(je)throw je}for(let je=0;je0){const{error:je}=await K.from("academy_video_templates").insert(L.map(mt=>({video_id:rt,template_id:mt})));if(je)throw je}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Ae(),l(!1),n({title:i?"Video updated":"Video created"})},onError:fe=>{n({title:"Error saving video",description:fe.message,variant:"destructive"})}}),Ge=Bt({mutationFn:async fe=>{const{error:Qe}=await K.from("academy_videos").delete().eq("id",fe);if(Qe)throw Qe},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:fe=>{n({title:"Error deleting video",description:fe.message,variant:"destructive"})}}),Ne=Bt({mutationFn:async({id:fe,is_published:Qe})=>{const{error:at}=await K.from("academy_videos").update({is_published:Qe}).eq("id",fe);if(at)throw at},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:fe=>{n({title:"Error updating video",description:fe.message,variant:"destructive"})}}),Ae=()=>{f({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),v(null),b(""),j([]),S([]),I([]),d(null),F([]),q(""),se(null),Y(0),oe(!1),de(null)},Pe=async fe=>{d(fe),f({title:fe.title,description:fe.description||"",video_url:fe.video_url,video_type:fe.video_type,duration:fe.duration||"",category_id:fe.category_id||"",publish_date:fe.publish_date?new Date(fe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:fe.is_published}),b(fe.thumbnail_url||""),S(fe.resources||[]),j([]),I([]);const{data:Qe}=await K.from("academy_video_templates").select("template_id").eq("video_id",fe.id);F((Qe||[]).map(at=>at.template_id)),l(!0)},Fe=fe=>{var at;const Qe=(at=fe.target.files)==null?void 0:at[0];Qe&&(v(Qe),b(URL.createObjectURL(Qe)))},Ie=fe=>{const Qe=fe.target.files;if(Qe){const at=Array.from(Qe).map(rt=>({file:rt,title:rt.name.replace(/\.[^/.]+$/,"")}));j([...w,...at])}fe.target.value=""},Ve=fe=>{j(w.filter((Qe,at)=>at!==fe))},dt=fe=>{I([...A,fe]),S(N.filter(Qe=>Qe.id!==fe))},Le=async()=>{if(!Q)return null;oe(!0),Y(0);try{const{data:fe,error:Qe}=await K.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||Q.name}});if(Qe)throw new Error(Qe.message);const{videoId:at,libraryId:rt}=fe;de(at);const{data:je,error:mt}=await K.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:at}});if(mt)throw new Error(mt.message);const He=new XMLHttpRequest;return await new Promise((We,Ze)=>{He.upload.addEventListener("progress",ht=>{if(ht.lengthComputable){const Ke=Math.round(ht.loaded/ht.total*100);Y(Ke)}}),He.addEventListener("load",()=>{He.status>=200&&He.status<300?We():Ze(new Error(`Upload failed with status ${He.status}`))}),He.addEventListener("error",()=>Ze(new Error("Upload failed"))),He.open("PUT",je.uploadUrl),He.setRequestHeader("AccessKey",je.apiKey),He.send(Q)}),`https://player.mediadelivery.net/embed/${rt}/${at}`}catch(fe){return console.error("Bunny upload error:",fe),n({title:"Video upload failed",description:fe instanceof Error?fe.message:"Unknown error",variant:"destructive"}),null}finally{oe(!1)}},Rt=async fe=>{if(fe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Qe=u.video_url;if(u.video_type==="bunny_stream"&&Q&&!i){const at=await Le();if(!at)return;Qe=at}else if(!u.video_url.trim()&&u.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(u.video_type==="bunny_stream"&&!Q&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}ke.mutate({video:{...u,video_url:Qe},thumbnail:g,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:w,resourcesToDelete:A})};return e.jsx(Ms,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:be.length})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:be.filter(fe=>fe.is_published).length})})]})]}),e.jsxs(bs,{open:o,onOpenChange:fe=>{l(fe),fe||Ae()},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:Rt,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:u.title,onChange:fe=>f({...u,title:fe.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Wg,{content:u.description,onChange:fe=>f({...u,description:fe}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Video Type"}),e.jsxs(tr,{value:u.video_type,onValueChange:fe=>{f({...u,video_type:fe,video_url:""}),se(null)},disabled:ce,children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:kIt.map(fe=>e.jsx(At,{value:fe.value,children:fe.label},fe.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(_e,{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(Re,{type:"file",accept:"video/*",onChange:fe=>{var at;const Qe=(at=fe.target.files)==null?void 0:at[0];Qe&&se(Qe)},disabled:ce}),Q&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Cn,{className:"h-4 w-4"}),Q.name," (",(Q.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(Rs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(wo,{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(_e,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(Re,{id:"video_url",value:u.video_url,onChange:fe=>f({...u,video_url:fe.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(_e,{htmlFor:"duration",children:"Duration"}),e.jsx(Re,{id:"duration",value:u.duration,onChange:fe=>f({...u,duration:fe.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:u.publish_date,onChange:fe=>f({...u,publish_date:fe.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Category"}),H?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:$,onChange:fe=>q(fe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(Z,{type:"button",size:"sm",onClick:()=>$.trim()&&ve.mutate($.trim()),disabled:ve.isPending,children:"Add"}),e.jsx(Z,{type:"button",size:"sm",variant:"ghost",onClick:()=>{U(!1),q("")},children:e.jsx(Vr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:u.category_id,onValueChange:fe=>f({...u,category_id:fe}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(er,{children:xe.map(fe=>e.jsx(At,{value:fe.id,children:fe.name},fe.id))})]}),e.jsx(Z,{type:"button",variant:"outline",size:"sm",onClick:()=>U(!0),children:e.jsx(Ys,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[_&&e.jsx("img",{src:_,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:Fe,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(_e,{children:"Resource Files"}),e.jsx(Z,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(xi,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:Ie,className:"hidden"})]})})]}),(N.length>0||w.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[N.map(fe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:fe.title}),e.jsx(nt,{variant:"outline",className:"text-xs",children:fe.file_type}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>dt(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Vr,{className:"h-4 w-4"})})]},fe.id)),w.map((fe,Qe)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:fe.title,onChange:at=>{const rt=[...w];rt[Qe].title=at.target.value,j(rt)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(nt,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>Ve(Qe),className:"text-destructive hover:text-destructive",children:e.jsx(Vr,{className:"h-4 w-4"})})]},Qe))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(xWe,{selectedTemplateIds:L,onChange:F}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_published",checked:u.is_published,onCheckedChange:fe=>f({...u,is_published:fe})}),e.jsx(_e,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(qn,{children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ce,children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:ke.isPending||ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):ke.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:ye?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"})}):be.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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:be.map(fe=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[fe.thumbnail_url?e.jsx("img",{src:fe.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:fe.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:fe.video_type.replace("_"," ")})]})]})}),e.jsx(lt,{children:fe.category?e.jsx(nt,{variant:"outline",children:fe.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(lt,{children:fe.duration||"-"}),e.jsx(lt,{children:fe.resources&&fe.resources.length>0?e.jsxs(nt,{variant:"secondary",children:[fe.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(lt,{children:new Date(fe.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(qr,{checked:fe.is_published,onCheckedChange:Qe=>Ne.mutate({id:fe.id,is_published:Qe})})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>Pe(fe),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>Ge.mutate(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},fe.id))})]})})})]})})};function SIt(){var ke,Ge,Ne;const t=ds(),[s,r]=Gc(),[n,a]=M.useState(!1),[o,l]=M.useState(null),[i,d]=M.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,f]=M.useState(null),[g,v]=M.useState(""),[_,b]=M.useState([]),[w,j]=M.useState([]),[N,S]=M.useState([]),[A,I]=M.useState(null),{data:L,isLoading:F}=Tt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Ae,error:Pe}=await K.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Pe)throw Pe;return Ae}}),{data:$}=Tt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Ae,error:Pe}=await K.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Pe)throw Pe;return Ae}}),{data:q}=Tt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Ae,error:Pe}=await K.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Pe)throw Pe;return Ae}});M.useEffect(()=>{const Ae=s.get("edit");if(Ae&&L&&L.length>0&&$&&q){const Pe=L.find(Fe=>Fe.id===Ae);Pe&&(U(Pe),r({},{replace:!0}))}},[L,$,q,s]);const H=()=>{d({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),f(null),v(""),b([]),j([]),S([]),l(null)},U=async Ae=>{l(Ae),d({name:Ae.name,description:Ae.description||"",publish_date:Ae.publish_date.split("T")[0],is_published:Ae.is_published}),v(Ae.featured_image_url||"");const Pe=($==null?void 0:$.filter(Ve=>Ve.kit_id===Ae.id))||[];b(Pe.map(Ve=>({id:Ve.id,name:Ve.name,file_url:Ve.file_url,file_type:Ve.file_type,file_size:Ve.file_size,sort_order:Ve.sort_order})));const Fe=(q==null?void 0:q.filter(Ve=>Ve.kit_id===Ae.id))||[];j(Fe.map(Ve=>({id:Ve.id,title:Ve.title,canva_share_link:Ve.canva_share_link,sort_order:Ve.sort_order})));const{data:Ie}=await K.from("resource_kit_templates").select("template_id").eq("kit_id",Ae.id);S((Ie||[]).map(Ve=>Ve.template_id)),a(!0)},Q=Ae=>{var Fe;const Pe=(Fe=Ae.target.files)==null?void 0:Fe[0];Pe&&(f(Pe),v(URL.createObjectURL(Pe)))},se=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},te=Ae=>{b(_.filter((Pe,Fe)=>Fe!==Ae))},Y=(Ae,Pe,Fe)=>{const Ie=[..._];Ie[Ae]={...Ie[Ae],[Pe]:Fe},b(Ie)},ce=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},oe=Ae=>{j(w.filter((Pe,Fe)=>Fe!==Ae))},le=(Ae,Pe,Fe)=>{const Ie=[...w];Ie[Ae]={...Ie[Ae],[Pe]:Fe},j(Ie)},de=(Ae,Pe)=>{var Ie;const Fe=(Ie=Pe.target.files)==null?void 0:Ie[0];if(Fe){const Ve=[..._],dt=Fe.name.replace(/\.[^/.]+$/,"");Ve[Ae]={...Ve[Ae],file:Fe,file_type:Fe.type,file_size:Fe.size,name:Ve[Ae].name||dt},b(Ve)}},xe=Bt({mutationFn:async()=>{let Ae=(o==null?void 0:o.featured_image_url)||null;if(u){const dt=u.name.split(".").pop(),Le=`${Date.now()}.${dt}`,{error:Rt}=await K.storage.from("resource-kits").upload(`featured/${Le}`,u);if(Rt)throw Rt;const{data:fe}=K.storage.from("resource-kits").getPublicUrl(`featured/${Le}`);Ae=fe.publicUrl}const Pe={name:i.name,description:i.description||null,featured_image_url:Ae,publish_date:i.publish_date,is_published:i.is_published};let Fe;const Ie=!o,Ve=(o==null?void 0:o.is_published)||!1;if(o){const{error:dt}=await K.from("resource_kits").update(Pe).eq("id",o.id);if(dt)throw dt;Fe=o.id;const Le=($==null?void 0:$.filter(je=>je.kit_id===o.id).map(je=>je.id))||[],Rt=_.filter(je=>je.id).map(je=>je.id),fe=Le.filter(je=>!Rt.includes(je));fe.length>0&&await K.from("resource_kit_files").delete().in("id",fe);const Qe=(q==null?void 0:q.filter(je=>je.kit_id===o.id).map(je=>je.id))||[],at=w.filter(je=>je.id).map(je=>je.id),rt=Qe.filter(je=>!at.includes(je));rt.length>0&&await K.from("resource_kit_links").delete().in("id",rt)}else{const{data:dt,error:Le}=await K.from("resource_kits").insert(Pe).select().single();if(Le)throw Le;Fe=dt.id}for(let dt=0;dt<_.length;dt++){const Le=_[dt];let Rt=Le.file_url;if(Le.file){const fe=Le.file.name.split(".").pop(),Qe=`${Date.now()}-${dt}.${fe}`,{error:at}=await K.storage.from("resource-kits").upload(`files/${Qe}`,Le.file);if(at)throw at;const{data:rt}=K.storage.from("resource-kits").getPublicUrl(`files/${Qe}`);Rt=rt.publicUrl}Le.id?await K.from("resource_kit_files").update({name:Le.name,file_url:Rt,file_type:Le.file_type,file_size:Le.file_size,sort_order:dt}).eq("id",Le.id):Rt&&Le.name&&await K.from("resource_kit_files").insert({kit_id:Fe,name:Le.name,file_url:Rt,file_type:Le.file_type,file_size:Le.file_size,sort_order:dt})}for(let dt=0;dt0){const{error:dt}=await K.from("resource_kit_templates").insert(N.map(Le=>({kit_id:Fe,template_id:Le})));if(dt)throw dt}return{kitId:Fe,kitName:i.name,isNewKit:Ie,wasPublished:Ve,isPublished:i.is_published}},onSuccess:Ae=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),ge.success(o?"Resource kit updated":"Resource kit created"),Ae.isPublished&&(Ae.isNewKit||!Ae.wasPublished)&&vIt(Ae.kitName,Ae.kitId),a(!1),H()},onError:Ae=>{ge.error("Failed to save resource kit: "+Ae.message)}}),be=Bt({mutationFn:async Ae=>{const{error:Pe}=await K.from("resource_kits").delete().eq("id",Ae);if(Pe)throw Pe},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),ge.success("Resource kit deleted")},onError:Ae=>{ge.error("Failed to delete: "+Ae.message)}}),ye=Ae=>{if(Ae.preventDefault(),!i.name){ge.error("Please enter a name");return}xe.mutate()},ve=Ae=>($==null?void 0:$.filter(Pe=>Pe.kit_id===Ae).length)||0;return e.jsx(Ms,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.length)||0})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.filter(Ae=>Ae.is_published).length)||0})})]})]}),e.jsxs(Z,{onClick:()=>{H(),a(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:F?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(ks,{children:e.jsx(lt,{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(ks,{children:[e.jsx(lt,{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(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),ve(Ae.id)]})}),e.jsx(lt,{children:js(new Date(Ae.publish_date),"MMM d, yyyy")}),e.jsx(lt,{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(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{const Pe=($==null?void 0:$.filter(Ie=>Ie.kit_id===Ae.id))||[],Fe=(q==null?void 0:q.filter(Ie=>Ie.kit_id===Ae.id))||[];I({...Ae,files:Pe,links:Fe})},children:e.jsx(Na,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>U(Ae),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&be.mutate(Ae.id)},children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},Ae.id))})]})})}),e.jsx(bs,{open:n,onOpenChange:a,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:ye,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Featured Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[g?e.jsx("img",{src:g,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(Re,{type:"file",accept:"image/*",onChange:Q})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name *"}),e.jsx(Re,{id:"name",value:i.name,onChange:Ae=>d({...i,name:Ae.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Wg,{content:i.description,onChange:Ae=>d({...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(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:i.publish_date,onChange:Ae=>d({...i,publish_date:Ae.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(qr,{checked:i.is_published,onCheckedChange:Ae=>d({...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(_e,{children:"Resource Files"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:se,children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),_.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:_.map((Ae,Pe)=>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 ",Pe+1]}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>te(Pe),children:e.jsx(Vr,{className:"h-4 w-4"})})]}),e.jsx(Re,{placeholder:"File name (e.g., Getting Started Guide)",value:Ae.name,onChange:Fe=>Y(Pe,"name",Fe.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"file",onChange:Fe=>de(Pe,Fe),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"})]})]},Pe))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(_e,{children:"Canva Links"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:ce,children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),w.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No Canva links added yet. Click "Add Canva Link" to include templates.'}):e.jsx("div",{className:"space-y-3",children:w.map((Ae,Pe)=>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 ",Pe+1]}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>oe(Pe),children:e.jsx(Vr,{className:"h-4 w-4"})})]}),e.jsx(Re,{placeholder:"Link title (e.g., Social Media Post Template)",value:Ae.title,onChange:Fe=>le(Pe,"title",Fe.target.value)}),e.jsx(Re,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Ae.canva_share_link,onChange:Fe=>le(Pe,"canva_share_link",Fe.target.value)})]},Pe))})]}),e.jsx(xWe,{selectedTemplateIds:N,onChange:S}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:xe.isPending,children:xe.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(bs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:A==null?void 0:A.name})}),e.jsxs("div",{className:"space-y-4",children:[(A==null?void 0:A.featured_image_url)&&e.jsx("img",{src:A.featured_image_url,alt:A.name,className:"w-full h-48 object-cover rounded-lg"}),(A==null?void 0:A.description)&&e.jsx("p",{className:"text-muted-foreground",children:A.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((ke=A==null?void 0:A.files)==null?void 0:ke.length)||0,")"]}),((Ge=A==null?void 0:A.files)==null?void 0:Ge.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=A==null?void 0:A.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(Un,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ae.name})]},Ae.id))})]}),(A==null?void 0:A.links)&&A.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.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(Po,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ae.title})]},Ae.id))})]})]})]})})]})})}const CIt=()=>{const{user:t}=Qs(),{toast:s}=La(),r=ds(),[n,a]=M.useState(!1),[o,l]=M.useState(null),[i,d]=M.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,f]=M.useState(null),[g,v]=M.useState(""),{data:_=[],isLoading:b}=Tt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:q,error:H}=await K.from("social_swag").select("*").order("publish_date",{ascending:!1});if(H)throw H;const{data:U,error:Q}=await K.from("social_swag_links").select("*").order("sort_order");if(Q)throw Q;return q.map(te=>({...te,links:(U==null?void 0:U.filter(Y=>Y.swag_id===te.id))||[]}))}}),w=Bt({mutationFn:async q=>{let H=q.existingImageUrl;if(q.image){const ce=q.image.name.split(".").pop(),oe=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ce}`,{error:le}=await K.storage.from("template-previews").upload(oe,q.image);if(le)throw le;const{data:de}=K.storage.from("template-previews").getPublicUrl(oe);H=de.publicUrl}const U={title:q.item.title,description:q.item.description||null,preview_image_url:H,publish_date:q.item.publish_date?new Date(q.item.publish_date).toISOString():new Date().toISOString(),is_published:q.item.is_published,created_by:t==null?void 0:t.id};let Q=q.itemId;const se=!Q,te=(o==null?void 0:o.is_published)||!1;if(Q){const{error:ce}=await K.from("social_swag").update(U).eq("id",Q);if(ce)throw ce;await K.from("social_swag_links").delete().eq("swag_id",Q)}else{const{data:ce,error:oe}=await K.from("social_swag").insert(U).select().single();if(oe)throw oe;Q=ce.id}const Y=q.item.links.filter(ce=>ce.title.trim()&&ce.canva_share_link.trim());if(Y.length>0){const ce=Y.map((le,de)=>({swag_id:Q,title:le.title.trim(),canva_share_link:le.canva_share_link.trim(),sort_order:de})),{error:oe}=await K.from("social_swag_links").insert(ce);if(oe)throw oe}return{itemId:Q,itemTitle:q.item.title,isNewItem:se,wasPublished:te,isPublished:q.item.is_published}},onSuccess:q=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),q.isPublished&&(q.isNewItem||!q.wasPublished)&&wxe(q.itemTitle,q.itemId),a(!1),N()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),j=Bt({mutationFn:async q=>{const{error:H}=await K.from("social_swag").delete().eq("id",q);if(H)throw H},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:q=>{s({title:"Error deleting item",description:q.message,variant:"destructive"})}}),N=()=>{d({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),f(null),v(""),l(null)},S=q=>{l(q),d({title:q.title,description:q.description||"",publish_date:q.publish_date?new Date(q.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:q.is_published,links:q.links&&q.links.length>0?q.links.map(H=>({id:H.id,title:H.title,canva_share_link:H.canva_share_link,sort_order:H.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),v(q.preview_image_url||""),a(!0)},A=q=>{var U;const H=(U=q.target.files)==null?void 0:U[0];H&&(f(H),v(URL.createObjectURL(H)))},I=()=>{d({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},L=q=>{if(i.links.length<=1)return;const H=i.links.filter((U,Q)=>Q!==q);d({...i,links:H})},F=(q,H,U)=>{const Q=[...i.links];Q[q]={...Q[q],[H]:U},d({...i,links:Q})},$=q=>{if(q.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ms,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(q=>q.is_published).length})})]})]}),e.jsxs(bs,{open:n,onOpenChange:q=>{a(q),q||N()},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:i.title,onChange:q=>d({...i,title:q.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Wg,{content:i.description,onChange:q=>d({...i,description:q}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:i.publish_date,onChange:q=>d({...i,publish_date:q.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:q=>d({...i,is_published:q})}),e.jsx(_e,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),g?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:g,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(Z,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{f(null),v("")},children:e.jsx(Vr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(Xo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Re,{type:"file",accept:"image/*",onChange:A,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Canva Links"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,H)=>e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",H+1]}),i.links.length>1&&e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>L(H),children:e.jsx(Vr,{className:"h-3 w-3"})})]}),e.jsx(Re,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:U=>F(H,"title",U.target.value)}),e.jsx(Re,{placeholder:"Canva share link",value:q.canva_share_link,onChange:U=>F(H,"canva_share_link",U.target.value)})]})},H))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:b?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"})}):_.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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:_.map(q=>{var H;return e.jsxs(ks,{children:[e.jsx(lt,{children:q.preview_image_url?e.jsx("img",{src:q.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(Xo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(lt,{className:"font-medium",children:q.title}),e.jsxs(lt,{children:[((H=q.links)==null?void 0:H.length)||0," links"]}),e.jsx(lt,{children:new Date(q.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(nt,{variant:q.is_published?"default":"secondary",children:q.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${q.id}`,"_blank"),children:e.jsx(Na,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>S(q),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&j.mutate(q.id)},children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function MIt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const ile=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function pM(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function wbe(t){return"nodeType"in t}function Lm(t){var s,r;return t?pM(t)?t:wbe(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function jbe(t){const{Document:s}=Lm(t);return t instanceof s}function CL(t){return pM(t)?!1:t instanceof Lm(t).HTMLElement}function yWe(t){return t instanceof Lm(t).SVGElement}function fM(t){return t?pM(t)?t.document:wbe(t)?jbe(t)?t:CL(t)||yWe(t)?t.ownerDocument:document:document:document}const sy=ile?M.useLayoutEffect:M.useEffect;function kbe(t){const s=M.useRef(t);return sy(()=>{s.current=t}),M.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=M.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function ZI(t,s){s===void 0&&(s=[t]);const r=M.useRef(t);return sy(()=>{r.current!==t&&(r.current=t)},s),r}function ML(t,s){const r=M.useRef();return M.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function lae(t){const s=kbe(t),r=M.useRef(null),n=M.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function jxe(t){const s=M.useRef();return M.useEffect(()=>{s.current=t},[t]),s.current}let gme={};function TL(t,s){return M.useMemo(()=>{if(s)return s;const r=gme[t]==null?0:gme[t]+1;return gme[t]=r,t+"-"+r},[t,s])}function vWe(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[d,u]of i){const f=o[d];f!=null&&(o[d]=f+t*u)}return o},{...s})}}const C5=vWe(1),YI=vWe(-1);function AIt(t){return"clientX"in t&&"clientY"in t}function Nbe(t){if(!t)return!1;const{KeyboardEvent:s}=Lm(t.target);return s&&t instanceof s}function EIt(t){if(!t)return!1;const{TouchEvent:s}=Lm(t.target);return s&&t instanceof s}function kxe(t){if(EIt(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 AIt(t)?{x:t.clientX,y:t.clientY}:null}const x3=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[x3.Translate.toString(t),x3.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),cTe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function PIt(t){return t.matches(cTe)?t:t.querySelector(cTe)}const IIt={display:"none"};function LIt(t){let{id:s,value:r}=t;return ut.createElement("div",{id:s,style:IIt},r)}function DIt(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 ut.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function OIt(){const[t,s]=M.useState("");return{announce:M.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const _We=M.createContext(null);function RIt(t){const s=M.useContext(_We);M.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function FIt(){const[t]=M.useState(()=>new Set),s=M.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[M.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 zIt={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. `},BIt={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 $It(t){let{announcements:s=BIt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=zIt}=t;const{announce:o,announcement:l}=OIt(),i=TL("DndLiveRegion"),[d,u]=M.useState(!1);if(M.useEffect(()=>{u(!0)},[]),RIt(M.useMemo(()=>({onDragStart(g){let{active:v}=g;o(s.onDragStart({active:v}))},onDragMove(g){let{active:v,over:_}=g;s.onDragMove&&o(s.onDragMove({active:v,over:_}))},onDragOver(g){let{active:v,over:_}=g;o(s.onDragOver({active:v,over:_}))},onDragEnd(g){let{active:v,over:_}=g;o(s.onDragEnd({active:v,over:_}))},onDragCancel(g){let{active:v,over:_}=g;o(s.onDragCancel({active:v,over:_}))}}),[o,s])),!d)return null;const f=ut.createElement(ut.Fragment,null,ut.createElement(LIt,{id:n,value:a.draggable}),ut.createElement(DIt,{id:i,announcement:l}));return r?xm.createPortal(f,r):f}var Pd;(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"})(Pd||(Pd={}));function cae(){}function Nxe(t,s){return M.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function bWe(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const $g=Object.freeze({x:0,y:0});function wWe(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function jWe(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function qIt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function dTe(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 kWe(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function uTe(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 NWe=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=uTe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=wWe(uTe(d),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(jWe)},UIt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=dTe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=dTe(d),f=a.reduce((v,_,b)=>v+wWe(u[b],_),0),g=Number((f/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:g}})}}return o.sort(jWe)};function VIt(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 d=VIt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(qIt)};function WIt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function SWe(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:$g}function GIt(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 KIt=GIt(1);function ZIt(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 YIt(t,s,r){const n=ZIt(s);if(!n)return t;const{scaleX:a,scaleY:o,x:l,y:i}=n,d=t.left-l-(1-a)*parseFloat(r),u=t.top-i-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),f=a?t.width/a:t.width,g=o?t.height/o:t.height;return{width:f,height:g,top:u,right:d+f,bottom:u+g,left:d}}const XIt={ignoreTransform:!1};function gM(t,s){s===void 0&&(s=XIt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:f}=Lm(t).getComputedStyle(t);u&&(r=YIt(r,u,f))}const{top:n,left:a,width:o,height:l,bottom:i,right:d}=r;return{top:n,left:a,width:o,height:l,bottom:i,right:d}}function hTe(t){return gM(t,{ignoreTransform:!0})}function QIt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function JIt(t,s){return s===void 0&&(s=Lm(t).getComputedStyle(t)),s.position==="fixed"}function e6t(t,s){s===void 0&&(s=Lm(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 ole(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(jbe(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!CL(a)||yWe(a)||r.includes(a))return r;const o=Lm(t).getComputedStyle(a);return a!==t&&e6t(a,o)&&r.push(a),JIt(a,o)?r:n(a.parentNode)}return t?n(t):r}function CWe(t){const[s]=ole(t,1);return s??null}function xme(t){return!ile||!t?null:pM(t)?t:wbe(t)?jbe(t)||t===fM(t).scrollingElement?window:CL(t)?t:null:null}function MWe(t){return pM(t)?t.scrollX:t.scrollLeft}function TWe(t){return pM(t)?t.scrollY:t.scrollTop}function Sxe(t){return{x:MWe(t),y:TWe(t)}}var tu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(tu||(tu={}));function AWe(t){return!ile||!t?!1:t===document.scrollingElement}function EWe(t){const s={x:0,y:0},r=AWe(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 t6t={x:.2,y:.2};function s6t(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=t6t);const{isTop:u,isBottom:f,isLeft:g,isRight:v}=EWe(t),_={x:0,y:0},b={x:0,y:0},w={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+w.height?(_.y=tu.Backward,b.y=n*Math.abs((s.top+w.height-o)/w.height)):!f&&d>=s.bottom-w.height&&(_.y=tu.Forward,b.y=n*Math.abs((s.bottom-w.height-d)/w.height)),!v&&i>=s.right-w.width?(_.x=tu.Forward,b.x=n*Math.abs((s.right-w.width-i)/w.width)):!g&&l<=s.left+w.width&&(_.x=tu.Backward,b.x=n*Math.abs((s.left+w.width-l)/w.width)),{direction:_,speed:b}}function r6t(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 PWe(t){return t.reduce((s,r)=>C5(s,Sxe(r)),$g)}function n6t(t){return t.reduce((s,r)=>s+MWe(r),0)}function a6t(t){return t.reduce((s,r)=>s+TWe(r),0)}function i6t(t,s){if(s===void 0&&(s=gM),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);CWe(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const o6t=[["x",["left","right"],n6t],["y",["top","bottom"],a6t]];class Sbe{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=ole(r),a=PWe(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of o6t)for(const d of l)Object.defineProperty(this,d,{get:()=>{const u=i(n),f=a[o]-u;return this.rect[d]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class VP{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 l6t(t){const{EventTarget:s}=Lm(t);return t instanceof s?t:fM(t)}function yme(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 Kp;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Kp||(Kp={}));function mTe(t){t.preventDefault()}function c6t(t){t.stopPropagation()}var xo;(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"})(xo||(xo={}));const IWe={start:[xo.Space,xo.Enter],cancel:[xo.Esc],end:[xo.Space,xo.Enter,xo.Tab]},d6t=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case xo.Right:return{...r,x:r.x+25};case xo.Left:return{...r,x:r.x-25};case xo.Down:return{...r,y:r.y+25};case xo.Up:return{...r,y:r.y-25}}};class Cbe{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 VP(fM(r)),this.windowListeners=new VP(Lm(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Kp.Resize,this.handleCancel),this.windowListeners.add(Kp.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Kp.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&i6t(n),r($g)}handleKeyDown(s){if(Nbe(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=IWe,coordinateGetter:l=d6t,scrollBehavior:i="smooth"}=a,{code:d}=s;if(o.end.includes(d)){this.handleEnd(s);return}if(o.cancel.includes(d)){this.handleCancel(s);return}const{collisionRect:u}=n.current,f=u?{x:u.left,y:u.top}:$g;this.referenceCoordinates||(this.referenceCoordinates=f);const g=l(s,{active:r,context:n.current,currentCoordinates:f});if(g){const v=YI(g,f),_={x:0,y:0},{scrollableAncestors:b}=n.current;for(const w of b){const j=s.code,{isTop:N,isRight:S,isLeft:A,isBottom:I,maxScroll:L,minScroll:F}=EWe(w),$=r6t(w),q={x:Math.min(j===xo.Right?$.right-$.width/2:$.right,Math.max(j===xo.Right?$.left:$.left+$.width/2,g.x)),y:Math.min(j===xo.Down?$.bottom-$.height/2:$.bottom,Math.max(j===xo.Down?$.top:$.top+$.height/2,g.y))},H=j===xo.Right&&!S||j===xo.Left&&!A,U=j===xo.Down&&!I||j===xo.Up&&!N;if(H&&q.x!==g.x){const Q=w.scrollLeft+v.x,se=j===xo.Right&&Q<=L.x||j===xo.Left&&Q>=F.x;if(se&&!v.y){w.scrollTo({left:Q,behavior:i});return}se?_.x=w.scrollLeft-Q:_.x=j===xo.Right?w.scrollLeft-L.x:w.scrollLeft-F.x,_.x&&w.scrollBy({left:-_.x,behavior:i});break}else if(U&&q.y!==g.y){const Q=w.scrollTop+v.y,se=j===xo.Down&&Q<=L.y||j===xo.Up&&Q>=F.y;if(se&&!v.x){w.scrollTo({top:Q,behavior:i});return}se?_.y=w.scrollTop-Q:_.y=j===xo.Down?w.scrollTop-L.y:w.scrollTop-F.y,_.y&&w.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,C5(YI(g,this.referenceCoordinates),_))}}}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()}}Cbe.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=IWe,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 pTe(t){return!!(t&&"distance"in t)}function fTe(t){return!!(t&&"delay"in t)}class Mbe{constructor(s,r,n){var a;n===void 0&&(n=l6t(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=fM(l),this.documentListeners=new VP(this.document),this.listeners=new VP(n),this.windowListeners=new VP(Lm(l)),this.initialCoordinates=(a=kxe(o))!=null?a:$g,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(Kp.Resize,this.handleCancel),this.windowListeners.add(Kp.DragStart,mTe),this.windowListeners.add(Kp.VisibilityChange,this.handleCancel),this.windowListeners.add(Kp.ContextMenu,mTe),this.documentListeners.add(Kp.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(fTe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(pTe(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(Kp.Click,c6t,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Kp.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 d=(r=kxe(s))!=null?r:$g,u=YI(a,d);if(!n&&i){if(pTe(i)){if(i.tolerance!=null&&yme(u,i.tolerance))return this.handleCancel();if(yme(u,i.distance))return this.handleStart()}if(fTe(i)&&yme(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}s.cancelable&&s.preventDefault(),l(d)}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===xo.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const u6t={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class lle extends Mbe{constructor(s){const{event:r}=s,n=fM(r.target);super(s,u6t,n)}}lle.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 h6t={move:{name:"mousemove"},end:{name:"mouseup"}};var Cxe;(function(t){t[t.RightClick=2]="RightClick"})(Cxe||(Cxe={}));class m6t extends Mbe{constructor(s){super(s,h6t,fM(s.event.target))}}m6t.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===Cxe.RightClick?!1:(n==null||n({event:r}),!0)}}];const vme={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class p6t extends Mbe{constructor(s){super(s,vme)}static setup(){return window.addEventListener(vme.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(vme.move.name,s)};function s(){}}}p6t.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 HP;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(HP||(HP={}));var dae;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(dae||(dae={}));function f6t(t){let{acceleration:s,activator:r=HP.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=dae.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:f,delta:g,threshold:v}=t;const _=x6t({delta:g,disabled:!o}),[b,w]=TIt(),j=M.useRef({x:0,y:0}),N=M.useRef({x:0,y:0}),S=M.useMemo(()=>{switch(r){case HP.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case HP.DraggableRect:return a}},[r,a,d]),A=M.useRef(null),I=M.useCallback(()=>{const F=A.current;if(!F)return;const $=j.current.x*N.current.x,q=j.current.y*N.current.y;F.scrollBy($,q)},[]),L=M.useMemo(()=>i===dae.TreeOrder?[...u].reverse():u,[i,u]);M.useEffect(()=>{if(!o||!u.length||!S){w();return}for(const F of L){if((n==null?void 0:n(F))===!1)continue;const $=u.indexOf(F),q=f[$];if(!q)continue;const{direction:H,speed:U}=s6t(F,q,S,s,v);for(const Q of["x","y"])_[Q][H[Q]]||(U[Q]=0,H[Q]=0);if(U.x>0||U.y>0){w(),A.current=F,b(I,l),j.current=U,N.current=H;return}}j.current={x:0,y:0},N.current={x:0,y:0},w()},[s,I,n,w,o,l,JSON.stringify(S),JSON.stringify(_),b,u,L,f,JSON.stringify(v)])}const g6t={x:{[tu.Backward]:!1,[tu.Forward]:!1},y:{[tu.Backward]:!1,[tu.Forward]:!1}};function x6t(t){let{delta:s,disabled:r}=t;const n=jxe(s);return ML(a=>{if(r||!n||!a)return g6t;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[tu.Backward]:a.x[tu.Backward]||o.x===-1,[tu.Forward]:a.x[tu.Forward]||o.x===1},y:{[tu.Backward]:a.y[tu.Backward]||o.y===-1,[tu.Forward]:a.y[tu.Forward]||o.y===1}}},[r,s,n])}function y6t(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return ML(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function v6t(t,s){return M.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 XI;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(XI||(XI={}));var Mxe;(function(t){t.Optimized="optimized"})(Mxe||(Mxe={}));const gTe=new Map;function _6t(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=M.useState(null),{frequency:i,measure:d,strategy:u}=a,f=M.useRef(t),g=j(),v=ZI(g),_=M.useCallback(function(N){N===void 0&&(N=[]),!v.current&&l(S=>S===null?N:S.concat(N.filter(A=>!S.includes(A))))},[v]),b=M.useRef(null),w=ML(N=>{if(g&&!r)return gTe;if(!N||N===gTe||f.current!==t||o!=null){const S=new Map;for(let A of t){if(!A)continue;if(o&&o.length>0&&!o.includes(A.id)&&A.rect.current){S.set(A.id,A.rect.current);continue}const I=A.node.current,L=I?new Sbe(d(I),I):null;A.rect.current=L,L&&S.set(A.id,L)}return S}return N},[t,o,r,g,d]);return M.useEffect(()=>{f.current=t},[t]),M.useEffect(()=>{g||_()},[r,g]),M.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),M.useEffect(()=>{g||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{_(),b.current=null},i))},[i,g,_,...n]),{droppableRects:w,measureDroppableContainers:_,measuringScheduled:o!=null};function j(){switch(u){case XI.Always:return!1;case XI.BeforeDragging:return r;default:return!r}}}function LWe(t,s){return ML(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function b6t(t,s){return LWe(t,s)}function w6t(t){let{callback:s,disabled:r}=t;const n=kbe(s),a=M.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return M.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function cle(t){let{callback:s,disabled:r}=t;const n=kbe(s),a=M.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return M.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function j6t(t){return new Sbe(gM(t),t)}function xTe(t,s,r){s===void 0&&(s=j6t);const[n,a]=M.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??r)!=null?u:null}const f=s(t);return JSON.stringify(d)===JSON.stringify(f)?d:f})}const l=w6t({callback(d){if(t)for(const u of d){const{type:f,target:g}=u;if(f==="childList"&&g instanceof HTMLElement&&g.contains(t)){o();break}}}}),i=cle({callback:o});return sy(()=>{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 k6t(t){const s=LWe(t);return SWe(t,s)}const yTe=[];function N6t(t){const s=M.useRef(t),r=ML(n=>t?n&&n!==yTe&&t&&s.current&&t.parentNode===s.current.parentNode?n:ole(t):yTe,[t]);return M.useEffect(()=>{s.current=t},[t]),r}function S6t(t){const[s,r]=M.useState(null),n=M.useRef(t),a=M.useCallback(o=>{const l=xme(o.target);l&&r(i=>i?(i.set(l,Sxe(l)),new Map(i)):null)},[]);return M.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const u=xme(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,Sxe(u)]):null}).filter(d=>d!=null);r(i.length?new Map(i):null),n.current=t}return()=>{l(t),l(o)};function l(i){i.forEach(d=>{const u=xme(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),M.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>C5(o,l),$g):PWe(t):$g,[t,s])}function vTe(t,s){s===void 0&&(s=[]);const r=M.useRef(null);return M.useEffect(()=>{r.current=null},s),M.useEffect(()=>{const n=t!==$g;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?YI(t,r.current):$g}function C6t(t){M.useEffect(()=>{if(!ile)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 M6t(t,s){return M.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function DWe(t){return M.useMemo(()=>t?QIt(t):null,[t])}const _Te=[];function T6t(t,s){s===void 0&&(s=gM);const[r]=t,n=DWe(r?Lm(r):null),[a,o]=M.useState(_Te);function l(){o(()=>t.length?t.map(d=>AWe(d)?n:new Sbe(s(d),d)):_Te)}const i=cle({callback:l});return sy(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function A6t(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return CL(s)?s:t}function E6t(t){let{measure:s}=t;const[r,n]=M.useState(null),a=M.useCallback(u=>{for(const{target:f}of u)if(CL(f)){n(g=>{const v=s(f);return g?{...g,width:v.width,height:v.height}:v});break}},[s]),o=cle({callback:a}),l=M.useCallback(u=>{const f=A6t(u);o==null||o.disconnect(),f&&(o==null||o.observe(f)),n(f?s(f):null)},[s,o]),[i,d]=lae(l);return M.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const P6t=[{sensor:lle,options:{}},{sensor:Cbe,options:{}}],I6t={current:{}},rre={draggable:{measure:hTe},droppable:{measure:hTe,strategy:XI.WhileDragging,frequency:Mxe.Optimized},dragOverlay:{measure:gM}};class WP 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 L6t={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new WP,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:cae},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:rre,measureDroppableContainers:cae,windowRect:null,measuringScheduled:!1},D6t={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:cae,draggableNodes:new Map,over:null,measureDroppableContainers:cae},dle=M.createContext(D6t),OWe=M.createContext(L6t);function O6t(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new WP}}}function R6t(t,s){switch(s.type){case Pd.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case Pd.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 Pd.DragEnd:case Pd.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Pd.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new WP(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case Pd.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 WP(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case Pd.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new WP(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function F6t(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=M.useContext(dle),o=jxe(n),l=jxe(r==null?void 0:r.id);return M.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!Nbe(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:d,node:u}=i;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[d.current,u.current]){if(!f)continue;const g=PIt(f);if(g){g.focus();break}}})}},[n,s,a,l,o]),null}function z6t(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function B6t(t){return M.useMemo(()=>({draggable:{...rre.draggable,...t==null?void 0:t.draggable},droppable:{...rre.droppable,...t==null?void 0:t.droppable},dragOverlay:{...rre.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 $6t(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=M.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;sy(()=>{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 f=r(u),g=SWe(f,n);if(l||(g.x=0),i||(g.y=0),o.current=!0,Math.abs(g.x)>0||Math.abs(g.y)>0){const v=CWe(u);v&&v.scrollBy({top:g.y,left:g.x})}},[s,l,i,n,r])}const RWe=M.createContext({...$g,scaleX:1,scaleY:1});var n1;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(n1||(n1={}));const FWe=M.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:u,sensors:f=P6t,collisionDetection:g=HIt,measuring:v,modifiers:_,...b}=s;const w=M.useReducer(R6t,void 0,O6t),[j,N]=w,[S,A]=FIt(),[I,L]=M.useState(n1.Uninitialized),F=I===n1.Initialized,{draggable:{active:$,nodes:q,translate:H},droppable:{containers:U}}=j,Q=$!=null?q.get($):null,se=M.useRef({initial:null,translated:null}),te=M.useMemo(()=>{var Da;return $!=null?{id:$,data:(Da=Q==null?void 0:Q.data)!=null?Da:I6t,rect:se}:null},[$,Q]),Y=M.useRef(null),[ce,oe]=M.useState(null),[le,de]=M.useState(null),xe=ZI(b,Object.values(b)),be=TL("DndDescribedBy",l),ye=M.useMemo(()=>U.getEnabled(),[U]),ve=B6t(v),{droppableRects:ke,measureDroppableContainers:Ge,measuringScheduled:Ne}=_6t(ye,{dragging:F,dependencies:[H.x,H.y],config:ve.droppable}),Ae=y6t(q,$),Pe=M.useMemo(()=>le?kxe(le):null,[le]),Fe=no(),Ie=b6t(Ae,ve.draggable.measure);$6t({activeNode:$!=null?q.get($):null,config:Fe.layoutShiftCompensation,initialRect:Ie,measure:ve.draggable.measure});const Ve=xTe(Ae,ve.draggable.measure,Ie),dt=xTe(Ae?Ae.parentElement:null),Le=M.useRef({activatorEvent:null,active:null,activeNode:Ae,collisionRect:null,collisions:null,droppableRects:ke,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Rt=U.getNodeFor((r=Le.current.over)==null?void 0:r.id),fe=E6t({measure:ve.dragOverlay.measure}),Qe=(n=fe.nodeRef.current)!=null?n:Ae,at=F?(a=fe.rect)!=null?a:Ve:null,rt=!!(fe.nodeRef.current&&fe.rect),je=k6t(rt?null:Ve),mt=DWe(Qe?Lm(Qe):null),He=N6t(F?Rt??Ae:null),ct=T6t(He),We=z6t(_,{transform:{x:H.x-je.x,y:H.y-je.y,scaleX:1,scaleY:1},activatorEvent:le,active:te,activeNodeRect:Ve,containerNodeRect:dt,draggingNodeRect:at,over:Le.current.over,overlayNodeRect:fe.rect,scrollableAncestors:He,scrollableAncestorRects:ct,windowRect:mt}),Ze=Pe?C5(Pe,H):null,ht=S6t(He),Ke=vTe(ht),qe=vTe(ht,[Ve]),Je=C5(We,Ke),Lt=at?KIt(at,We):null,zt=te&&Lt?g({active:te,collisionRect:Lt,droppableRects:ke,droppableContainers:ye,pointerCoordinates:Ze}):null,is=kWe(zt,"id"),[Kt,Qt]=M.useState(null),fs=rt?We:C5(We,qe),dr=WIt(fs,(o=Kt==null?void 0:Kt.rect)!=null?o:null,Ve),bt=M.useRef(null),ws=M.useCallback((Da,yn)=>{let{sensor:ea,options:Zt}=yn;if(Y.current==null)return;const yr=q.get(Y.current);if(!yr)return;const Gr=Da.nativeEvent,Dn=new ea({active:Y.current,activeNode:yr,event:Gr,options:Zt,context:Le,onAbort(An){if(!q.get(An))return;const{onDragAbort:qa}=xe.current,Jr={id:An};qa==null||qa(Jr),S({type:"onDragAbort",event:Jr})},onPending(An,la,qa,Jr){if(!q.get(An))return;const{onDragPending:Dl}=xe.current,Lo={id:An,constraint:la,initialCoordinates:qa,offset:Jr};Dl==null||Dl(Lo),S({type:"onDragPending",event:Lo})},onStart(An){const la=Y.current;if(la==null)return;const qa=q.get(la);if(!qa)return;const{onDragStart:Jr}=xe.current,Ka={activatorEvent:Gr,active:{id:la,data:qa.data,rect:se}};xm.unstable_batchedUpdates(()=>{Jr==null||Jr(Ka),L(n1.Initializing),N({type:Pd.DragStart,initialCoordinates:An,active:la}),S({type:"onDragStart",event:Ka}),oe(bt.current),de(Gr)})},onMove(An){N({type:Pd.DragMove,coordinates:An})},onEnd:rs(Pd.DragEnd),onCancel:rs(Pd.DragCancel)});bt.current=Dn;function rs(An){return async function(){const{active:qa,collisions:Jr,over:Ka,scrollAdjustedTranslate:Dl}=Le.current;let Lo=null;if(qa&&Dl){const{cancelDrop:Kc}=xe.current;Lo={activatorEvent:Gr,active:qa,collisions:Jr,delta:Dl,over:Ka},An===Pd.DragEnd&&typeof Kc=="function"&&await Promise.resolve(Kc(Lo))&&(An=Pd.DragCancel)}Y.current=null,xm.unstable_batchedUpdates(()=>{N({type:An}),L(n1.Uninitialized),Qt(null),oe(null),de(null),bt.current=null;const Kc=An===Pd.DragEnd?"onDragEnd":"onDragCancel";if(Lo){const it=xe.current[Kc];it==null||it(Lo),S({type:Kc,event:Lo})}})}}},[q]),ir=M.useCallback((Da,yn)=>(ea,Zt)=>{const yr=ea.nativeEvent,Gr=q.get(Zt);if(Y.current!==null||!Gr||yr.dndKit||yr.defaultPrevented)return;const Dn={active:Gr};Da(ea,yn.options,Dn)===!0&&(yr.dndKit={capturedBy:yn.sensor},Y.current=Zt,ws(ea,yn))},[q,ws]),Rr=v6t(f,ir);C6t(f),sy(()=>{Ve&&I===n1.Initializing&&L(n1.Initialized)},[Ve,I]),M.useEffect(()=>{const{onDragMove:Da}=xe.current,{active:yn,activatorEvent:ea,collisions:Zt,over:yr}=Le.current;if(!yn||!ea)return;const Gr={active:yn,activatorEvent:ea,collisions:Zt,delta:{x:Je.x,y:Je.y},over:yr};xm.unstable_batchedUpdates(()=>{Da==null||Da(Gr),S({type:"onDragMove",event:Gr})})},[Je.x,Je.y]),M.useEffect(()=>{const{active:Da,activatorEvent:yn,collisions:ea,droppableContainers:Zt,scrollAdjustedTranslate:yr}=Le.current;if(!Da||Y.current==null||!yn||!yr)return;const{onDragOver:Gr}=xe.current,Dn=Zt.get(is),rs=Dn&&Dn.rect.current?{id:Dn.id,rect:Dn.rect.current,data:Dn.data,disabled:Dn.disabled}:null,An={active:Da,activatorEvent:yn,collisions:ea,delta:{x:yr.x,y:yr.y},over:rs};xm.unstable_batchedUpdates(()=>{Qt(rs),Gr==null||Gr(An),S({type:"onDragOver",event:An})})},[is]),sy(()=>{Le.current={activatorEvent:le,active:te,activeNode:Ae,collisionRect:Lt,collisions:zt,droppableRects:ke,draggableNodes:q,draggingNode:Qe,draggingNodeRect:at,droppableContainers:U,over:Kt,scrollableAncestors:He,scrollAdjustedTranslate:Je},se.current={initial:at,translated:Lt}},[te,Ae,zt,Lt,q,Qe,at,ke,U,Kt,He,Je]),f6t({...Fe,delta:H,draggingRect:Lt,pointerCoordinates:Ze,scrollableAncestors:He,scrollableAncestorRects:ct});const oa=M.useMemo(()=>({active:te,activeNode:Ae,activeNodeRect:Ve,activatorEvent:le,collisions:zt,containerNodeRect:dt,dragOverlay:fe,draggableNodes:q,droppableContainers:U,droppableRects:ke,over:Kt,measureDroppableContainers:Ge,scrollableAncestors:He,scrollableAncestorRects:ct,measuringConfiguration:ve,measuringScheduled:Ne,windowRect:mt}),[te,Ae,Ve,le,zt,dt,fe,q,U,ke,Kt,Ge,He,ct,ve,Ne,mt]),ri=M.useMemo(()=>({activatorEvent:le,activators:Rr,active:te,activeNodeRect:Ve,ariaDescribedById:{draggable:be},dispatch:N,draggableNodes:q,over:Kt,measureDroppableContainers:Ge}),[le,Rr,te,Ve,N,be,q,Kt,Ge]);return ut.createElement(_We.Provider,{value:A},ut.createElement(dle.Provider,{value:ri},ut.createElement(OWe.Provider,{value:oa},ut.createElement(RWe.Provider,{value:dr},u)),ut.createElement(F6t,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ut.createElement($It,{...i,hiddenTextDescribedById:be}));function no(){const Da=(ce==null?void 0:ce.autoScrollEnabled)===!1,yn=typeof d=="object"?d.enabled===!1:d===!1,ea=F&&!Da&&!yn;return typeof d=="object"?{...d,enabled:ea}:{enabled:ea}}}),q6t=M.createContext(null),bTe="button",U6t="Draggable";function V6t(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=TL(U6t),{activators:l,activatorEvent:i,active:d,activeNodeRect:u,ariaDescribedById:f,draggableNodes:g,over:v}=M.useContext(dle),{role:_=bTe,roleDescription:b="draggable",tabIndex:w=0}=a??{},j=(d==null?void 0:d.id)===s,N=M.useContext(j?RWe:q6t),[S,A]=lae(),[I,L]=lae(),F=M6t(l,s),$=ZI(r);sy(()=>(g.set(s,{id:s,key:o,node:S,activatorNode:I,data:$}),()=>{const H=g.get(s);H&&H.key===o&&g.delete(s)}),[g,s]);const q=M.useMemo(()=>({role:_,tabIndex:w,"aria-disabled":n,"aria-pressed":j&&_===bTe?!0:void 0,"aria-roledescription":b,"aria-describedby":f.draggable}),[n,_,w,j,b,f.draggable]);return{active:d,activatorEvent:i,activeNodeRect:u,attributes:q,isDragging:j,listeners:n?void 0:F,node:S,over:v,setNodeRef:A,setActivatorNodeRef:L,transform:N}}function H6t(){return M.useContext(OWe)}const W6t="Droppable",G6t={timeout:25};function K6t(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=TL(W6t),{active:l,dispatch:i,over:d,measureDroppableContainers:u}=M.useContext(dle),f=M.useRef({disabled:r}),g=M.useRef(!1),v=M.useRef(null),_=M.useRef(null),{disabled:b,updateMeasurementsFor:w,timeout:j}={...G6t,...a},N=ZI(w??n),S=M.useCallback(()=>{if(!g.current){g.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(N.current)?N.current:[N.current]),_.current=null},j)},[j]),A=cle({callback:S,disabled:b||!l}),I=M.useCallback((q,H)=>{A&&(H&&(A.unobserve(H),g.current=!1),q&&A.observe(q))},[A]),[L,F]=lae(I),$=ZI(s);return M.useEffect(()=>{!A||!L.current||(A.disconnect(),g.current=!1,A.observe(L.current))},[L,A]),M.useEffect(()=>(i({type:Pd.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:v,data:$}}),()=>i({type:Pd.UnregisterDroppable,key:o,id:n})),[n]),M.useEffect(()=>{r!==f.current.disabled&&(i({type:Pd.SetDroppableDisabled,id:n,key:o,disabled:r}),f.current.disabled=r)},[n,o,r,i]),{active:l,rect:v,isOver:(d==null?void 0:d.id)===n,node:L,over:d,setNodeRef:F}}function Tbe(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function Z6t(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function $8(t){return t!==null&&t>=0}function Y6t(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 d=Q6t(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-d,y:0,...q8}:l=o?{x:i.width+d,y:0,...q8}:{x:0,y:0,...q8}};function Q6t(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=Tbe(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}},zWe="Sortable",BWe=ut.createContext({activeIndex:-1,containerId:zWe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ule,disabled:{draggable:!1,droppable:!1}});function $We(t){let{children:s,id:r,items:n,strategy:a=ule,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:d,over:u,measureDroppableContainers:f}=H6t(),g=TL(zWe,r),v=i.rect!==null,_=M.useMemo(()=>n.map(F=>typeof F=="object"&&"id"in F?F.id:F),[n]),b=l!=null,w=l?_.indexOf(l.id):-1,j=u?_.indexOf(u.id):-1,N=M.useRef(_),S=!Y6t(_,N.current),A=j!==-1&&w===-1||S,I=X6t(o);sy(()=>{S&&b&&f(_)},[S,_,b,f]),M.useEffect(()=>{N.current=_},[_]);const L=M.useMemo(()=>({activeIndex:w,containerId:g,disabled:I,disableTransforms:A,items:_,overIndex:j,useDragOverlay:v,sortedRects:Z6t(_,d),strategy:a}),[w,g,I.draggable,I.droppable,A,_,j,d,v,a]);return ut.createElement(BWe.Provider,{value:L},s)}const J6t=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return Tbe(r,n,a).indexOf(s)},eLt=t=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:d,transition:u}=t;return!u||!n||i!==o&&a===l?!1:r?!0:l!==a&&s===d},tLt={duration:200,easing:"ease"},qWe="transform",sLt=x3.Transition.toString({property:qWe,duration:0,easing:"linear"}),rLt={roleDescription:"sortable"};function nLt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=M.useState(null),i=M.useRef(r);return sy(()=>{if(!s&&r!==i.current&&n.current){const d=a.current;if(d){const u=gM(n.current,{ignoreTransform:!0}),f={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(f.x||f.y)&&l(f)}}r!==i.current&&(i.current=r)},[s,r,n,a]),M.useEffect(()=>{o&&l(null)},[o]),o}function UWe(t){let{animateLayoutChanges:s=eLt,attributes:r,disabled:n,data:a,getNewIndex:o=J6t,id:l,strategy:i,resizeObserverConfig:d,transition:u=tLt}=t;const{items:f,containerId:g,activeIndex:v,disabled:_,disableTransforms:b,sortedRects:w,overIndex:j,useDragOverlay:N,strategy:S}=M.useContext(BWe),A=aLt(n,_),I=f.indexOf(l),L=M.useMemo(()=>({sortable:{containerId:g,index:I,items:f},...a}),[g,a,I,f]),F=M.useMemo(()=>f.slice(f.indexOf(l)),[f,l]),{rect:$,node:q,isOver:H,setNodeRef:U}=K6t({id:l,data:L,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:F,...d}}),{active:Q,activatorEvent:se,activeNodeRect:te,attributes:Y,setNodeRef:ce,listeners:oe,isDragging:le,over:de,setActivatorNodeRef:xe,transform:be}=V6t({id:l,data:L,attributes:{...rLt,...r},disabled:A.draggable}),ye=MIt(U,ce),ve=!!Q,ke=ve&&!b&&$8(v)&&$8(j),Ge=!N&&le,Ne=Ge&&ke?be:null,Pe=ke?Ne??(i??S)({rects:w,activeNodeRect:te,activeIndex:v,overIndex:j,index:I}):null,Fe=$8(v)&&$8(j)?o({id:l,items:f,activeIndex:v,overIndex:j}):I,Ie=Q==null?void 0:Q.id,Ve=M.useRef({activeId:Ie,items:f,newIndex:Fe,containerId:g}),dt=f!==Ve.current.items,Le=s({active:Q,containerId:g,isDragging:le,isSorting:ve,id:l,index:I,items:f,newIndex:Ve.current.newIndex,previousItems:Ve.current.items,previousContainerId:Ve.current.containerId,transition:u,wasDragging:Ve.current.activeId!=null}),Rt=nLt({disabled:!Le,index:I,node:q,rect:$});return M.useEffect(()=>{ve&&Ve.current.newIndex!==Fe&&(Ve.current.newIndex=Fe),g!==Ve.current.containerId&&(Ve.current.containerId=g),f!==Ve.current.items&&(Ve.current.items=f)},[ve,Fe,g,f]),M.useEffect(()=>{if(Ie===Ve.current.activeId)return;if(Ie!=null&&Ve.current.activeId==null){Ve.current.activeId=Ie;return}const Qe=setTimeout(()=>{Ve.current.activeId=Ie},50);return()=>clearTimeout(Qe)},[Ie]),{active:Q,activeIndex:v,attributes:Y,data:L,rect:$,index:I,newIndex:Fe,items:f,isOver:H,isSorting:ve,isDragging:le,listeners:oe,node:q,overIndex:j,over:de,setNodeRef:ye,setActivatorNodeRef:xe,setDroppableNodeRef:U,setDraggableNodeRef:ce,transform:Rt??Pe,transition:fe()};function fe(){if(Rt||dt&&Ve.current.newIndex===I)return sLt;if(!(Ge&&!Nbe(se)||!u)&&(ve||Le))return x3.Transition.toString({...u,property:qWe})}}function aLt(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 uae(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 iLt=[xo.Down,xo.Right,xo.Up,xo.Left],oLt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(iLt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const d=[];o.getEnabled().forEach(g=>{if(!g||g!=null&&g.disabled)return;const v=a.get(g.id);if(v)switch(t.code){case xo.Down:n.topv.top&&d.push(g);break;case xo.Left:n.left>v.left&&d.push(g);break;case xo.Right:n.left1&&(f=u[1].id),f!=null){const g=o.get(r.id),v=o.get(f),_=v?a.get(v.id):null,b=v==null?void 0:v.node.current;if(b&&_&&g&&v){const j=ole(b).some((F,$)=>i[$]!==F),N=VWe(g,v),S=lLt(g,v),A=j||!N?{x:0,y:0}:{x:S?n.width-_.width:0,y:S?n.height-_.height:0},I={x:_.left,y:_.top};return A.x&&A.y?I:YI(I,A)}}}};function VWe(t,s){return!uae(t)||!uae(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function lLt(t,s){return!uae(t)||!uae(s)||!VWe(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(Ga,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(nt,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(nn,{className:"h-2.5 w-2.5"}),js(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:It("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"h-3 w-3"}),t.post_date?js(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(jo,{className:"w-auto p-0",align:"start",children:[e.jsx(xp,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:g=>n(t.id,g?js(g,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"}),t.post_date&&e.jsx("div",{className:"p-2 border-t",children:e.jsx(Z,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const dLt=()=>{const t=ds(),[s,r]=M.useState("all"),[n,a]=M.useState(!1),[o,l]=M.useState(js(new Date,"yyyy-MM")),[i,d]=M.useState([]),[u,f]=M.useState(!1),[g,v]=M.useState(null),[_,b]=M.useState(null),[w,j]=M.useState(""),[N,S]=M.useState(null),[A,I]=M.useState(!1),[L,F]=M.useState(!1),[$,q]=M.useState(js(new Date,"yyyy-MM")),[H,U]=M.useState(null),[Q,se]=M.useState(""),[te,Y]=M.useState(""),[ce,oe]=M.useState(""),[le,de]=M.useState(!1),xe=bWe(Nxe(lle,{activationConstraint:{distance:5}}),Nxe(Cbe,{coordinateGetter:oLt})),{data:be=[],isLoading:ye}=Tt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Ze,error:ht}=await K.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ht)throw ht;return Ze}}),{data:ve=[]}=Tt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Ze,error:ht}=await K.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ht)throw ht;return Ze}}),{data:ke=[]}=Tt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Ze,error:ht}=await K.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ht)throw ht;return Ze}}),Ge=[...new Set(be.map(Ze=>Ze.month))].sort((Ze,ht)=>ht.localeCompare(Ze)),Ne=s==="all"?be:be.filter(Ze=>Ze.month===s),Ae=Ze=>{const ht=U1e(Ze,"yyyy-MM",new Date);return js(ht,"MMMM yyyy")},Pe=Ze=>{b(Ze),j(Ze.caption),S(Ze.post_date)},Fe=async()=>{if(_){I(!0);try{const{error:Ze}=await K.from("social_swag_2").update({caption:w,post_date:N}).eq("id",_.id);if(Ze)throw Ze;ge.success("Image updated"),b(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{ge.error("Failed to update image")}finally{I(!1)}}},Ie=async Ze=>{const{active:ht,over:Ke}=Ze;if(!Ke||ht.id===Ke.id)return;const qe=Ne,Je=qe.findIndex(is=>is.id===ht.id),Lt=qe.findIndex(is=>is.id===Ke.id);if(Je===-1||Lt===-1)return;const zt=Tbe(qe,Je,Lt);t.setQueryData(["admin-social-swag-2"],is=>{if(!is)return is;const Kt={};return zt.forEach((Qt,fs)=>{Kt[Qt.id]=fs}),is.map(Qt=>Kt[Qt.id]!==void 0?{...Qt,sort_order:Kt[Qt.id]}:Qt).sort((Qt,fs)=>Qt.month!==fs.month?fs.month.localeCompare(Qt.month):Qt.sort_order-fs.sort_order)});try{await Promise.all(zt.map((is,Kt)=>K.from("social_swag_2").update({sort_order:Kt}).eq("id",is.id)))}catch{ge.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Ve=Ze=>{const Ke=Array.from(Ze.target.files||[]).sort((qe,Je)=>qe.name.localeCompare(Je.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(qe=>({file:qe,preview:URL.createObjectURL(qe),caption:""}));d(qe=>[...qe,...Ke].slice(0,16))},dt=Ze=>{d(ht=>{const Ke=[...ht];return URL.revokeObjectURL(Ke[Ze].preview),Ke.splice(Ze,1),Ke})},Le=(Ze,ht)=>{d(Ke=>{const qe=[...Ke];return qe[Ze]={...qe[Ze],caption:ht},qe})},Rt=async()=>{var ht;if(i.length===0){ge.error("Please add at least one image");return}if(i.filter(Ke=>!Ke.caption.trim()).length>0){ge.error("Please add captions to all images");return}f(!0);try{const{data:Ke}=await K.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),qe=(((ht=Ke==null?void 0:Ke[0])==null?void 0:ht.sort_order)??-1)+1;for(let Je=0;Je{const ht=Ze.image_url.split("/social-swag-2/");ht[1]&&await K.storage.from("social-swag-2").remove([ht[1]]);const{error:Ke}=await K.from("social_swag_2").delete().eq("id",Ze.id);if(Ke)throw Ke},onSuccess:()=>{ge.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>ge.error("Failed to delete image")}),Qe=Bt({mutationFn:async({id:Ze,postDate:ht})=>{const{error:Ke}=await K.from("social_swag_2").update({post_date:ht}).eq("id",Ze);if(Ke)throw Ke},onSuccess:()=>{ge.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>ge.error("Failed to update post date")}),at=Bt({mutationFn:async({month:Ze,link:ht})=>{const{error:Ke}=await K.from("social_swag_2_months").upsert({month:Ze,canva_link:ht||null},{onConflict:"month"});if(Ke)throw Ke},onSuccess:()=>{ge.success("Canva link updated"),v(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>ge.error("Failed to update Canva link")}),rt=Ze=>{var ht;return((ht=ve.find(Ke=>Ke.month===Ze))==null?void 0:ht.canva_link)||""},je=Ze=>ke.find(ht=>ht.month===Ze)||null,mt=Ze=>{var Ke;const ht=(Ke=Ze.target.files)==null?void 0:Ke[0];ht&&(U(ht),se(URL.createObjectURL(ht)))},He=()=>{Q&&URL.revokeObjectURL(Q),U(null),se(""),Y(""),oe("")},ct=async()=>{if(!H){ge.error("Please select an image");return}de(!0);try{const Ze=H.name.split(".").pop(),ht=`reels/${$}-${Date.now()}.${Ze}`,{error:Ke}=await K.storage.from("social-swag-2").upload(ht,H);if(Ke)throw Ke;const{data:{publicUrl:qe}}=K.storage.from("social-swag-2").getPublicUrl(ht),{error:Je}=await K.from("social_swag_2_reels").upsert({month:$,image_url:qe,canva_link:ce||null,caption:te||null},{onConflict:"month"});if(Je)throw Je;ge.success("Reel uploaded successfully!"),wxe(`${Ae($)} Reel`,"social-swag-2"),He(),F(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ze){console.error("Reel upload error:",Ze),ge.error("Failed to upload reel")}finally{de(!1)}},We=Bt({mutationFn:async Ze=>{const ht=Ze.image_url.split("/social-swag-2/");ht[1]&&await K.storage.from("social-swag-2").remove([ht[1]]);const{error:Ke}=await K.from("social_swag_2_reels").delete().eq("id",Ze.id);if(Ke)throw Ke},onSuccess:()=>{ge.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>ge.error("Failed to delete reel")});return e.jsxs(Ms,{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(bs,{open:n,onOpenChange:a,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(_s,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Month"}),e.jsx(Re,{type:"month",value:o,onChange:Ze=>l(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{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:Ve,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(xi,{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,ht)=>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 ${ht+1}`,className:"w-full h-full object-cover"}),e.jsx(Z,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>dt(ht),children:e.jsx(Vr,{className:"h-3 w-3"})})]}),e.jsx(Lr,{placeholder:"Caption...",value:Ze.caption,onChange:Ke=>Le(ht,Ke.target.value),className:"text-xs h-20"})]},ht))}),e.jsx(Z,{onClick:Rt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(bs,{open:L,onOpenChange:Ze=>{F(Ze),Ze||He()},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:"gap-2",children:[e.jsx(eu,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(_s,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Month"}),e.jsx(Re,{type:"month",value:$,onChange:Ze=>q(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Reel Preview Image"}),Q?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Q,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(Z,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(Q),U(null),se("")},children:e.jsx(Vr,{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:mt,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(eu,{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(_e,{children:"Canva Download Link"}),e.jsx(Re,{value:ce,onChange:Ze=>oe(Ze.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Caption"}),e.jsx(Lr,{value:te,onChange:Ze=>Y(Ze.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(Z,{onClick:ct,disabled:le||!H,className:"w-full gap-2",children:le?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:be.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Ge.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ia,{value:s,onValueChange:r,children:e.jsxs(Aa,{children:[e.jsx(Ts,{value:"all",children:"All"}),Ge.map(Ze=>e.jsx(Ts,{value:Ze,children:Ae(Ze)},Ze))]})}),s!=="all"&&e.jsx(De,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Po,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(_e,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Ae(s)]}),(g==null?void 0:g.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Re,{value:g.link,onChange:Ze=>v({...g,link:Ze.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(Z,{size:"sm",onClick:()=>at.mutate(g),children:"Save"}),e.jsx(Z,{size:"sm",variant:"outline",onClick:()=>v(null),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm",children:rt(s)||"No link set"}),e.jsx(Z,{size:"sm",variant:"outline",onClick:()=>v({month:s,link:rt(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(De,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(eu,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(_e,{className:"text-sm text-muted-foreground",children:["Reel for ",Ae(s)]}),(()=>{const Ze=je(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(Z,{variant:"destructive",size:"sm",onClick:()=>We.mutate(Ze),children:e.jsx(Cr,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),ye?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(Xo,{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(FWe,{sensors:xe,collisionDetection:NWe,onDragEnd:Ie,children:e.jsx($We,{items:Ne.map(Ze=>Ze.id),strategy:ule,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(cLt,{item:Ze,onEdit:Pe,onDelete:ht=>fe.mutate(ht),onDateChange:(ht,Ke)=>Qe.mutate({id:ht,postDate:Ke})},Ze.id))})})})]}),e.jsx(bs,{open:!!_,onOpenChange:Ze=>{Ze||b(null)},children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Edit Image"})}),_&&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:_.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Caption"}),e.jsx(Lr,{value:w,onChange:Ze=>j(Ze.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("flex-1 justify-start gap-2 font-normal",!N&&"text-muted-foreground"),children:[e.jsx(nn,{className:"h-4 w-4"}),N?js(new Date(N+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:N?new Date(N+"T00:00:00"):void 0,onSelect:Ze=>S(Ze?js(Ze,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),N&&e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>S(null),children:e.jsx(Vr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(Z,{onClick:Fe,disabled:A,className:"gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},uLt=()=>{const{toast:t}=La(),s=ds(),[r,n]=M.useState("categories"),[a,o]=M.useState(!1),[l,i]=M.useState(null),[d,u]=M.useState({name:"",description:"",icon:""}),[f,g]=M.useState(!1),[v,_]=M.useState(null),[b,w]=M.useState({name:"",description:"",icon:""}),[j,N]=M.useState(!1),[S,A]=M.useState(null),[I,L]=M.useState(""),{data:F=[],isLoading:$}=Tt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:Ie,error:Ve}=await K.from("community_categories").select("*").order("sort_order");if(Ve)throw Ve;return Ie}}),{data:q=[],isLoading:H}=Tt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:Ie,error:Ve}=await K.from("community_private_groups").select("*").order("sort_order");if(Ve)throw Ve;return Ie}}),{data:U=[]}=Tt({queryKey:["admin-group-members",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:Ie,error:Ve}=await K.from("community_private_group_members").select("*").eq("group_id",S.id);if(Ve)throw Ve;return Ie},enabled:!!S}),{data:Q=[]}=Tt({queryKey:["admin-all-profiles"],queryFn:async()=>{let Ve=[],dt=0,Le=!0;for(;Le;){const{data:Rt,error:fe}=await K.from("profiles").select("id, name, email, brokerage_id").order("name").range(dt,dt+1e3-1);if(fe)throw fe;Rt&&Rt.length>0?(Ve=[...Ve,...Rt],dt+=1e3,Le=Rt.length===1e3):Le=!1}return Ve}}),{data:se=[]}=Tt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:Ie,error:Ve}=await K.from("brokerages").select("*").order("name");if(Ve)throw Ve;return Ie}}),te=Bt({mutationFn:async Ie=>{if(Ie.id){const{error:Ve}=await K.from("community_categories").update({name:Ie.name,description:Ie.description||null,icon:Ie.icon||null}).eq("id",Ie.id);if(Ve)throw Ve}else{const Ve=Math.max(...F.map(Le=>Le.sort_order),0),{error:dt}=await K.from("community_categories").insert({name:Ie.name,description:Ie.description||null,icon:Ie.icon||null,sort_order:Ve+1});if(dt)throw dt}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:Ie=>{t({title:"Error",description:Ie.message,variant:"destructive"})}}),Y=Bt({mutationFn:async Ie=>{const{error:Ve}=await K.from("community_categories").delete().eq("id",Ie);if(Ve)throw Ve},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ce=Bt({mutationFn:async({id:Ie,direction:Ve})=>{const dt=F.findIndex(Le=>Le.id===Ie);if(Ve==="up"&&dt>0){const Le=F[dt-1],Rt=F[dt];await K.from("community_categories").update({sort_order:Rt.sort_order}).eq("id",Le.id),await K.from("community_categories").update({sort_order:Le.sort_order}).eq("id",Rt.id)}else if(Ve==="down"&&dts.invalidateQueries({queryKey:["admin-community-categories"]})}),oe=Bt({mutationFn:async Ie=>{if(Ie.id){const{error:Ve}=await K.from("community_private_groups").update({name:Ie.name,description:Ie.description||null,icon:Ie.icon||null}).eq("id",Ie.id);if(Ve)throw Ve}else{const Ve=Math.max(...q.map(Le=>Le.sort_order),0),{error:dt}=await K.from("community_private_groups").insert({name:Ie.name,description:Ie.description||null,icon:Ie.icon||null,sort_order:Ve+1});if(dt)throw dt}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),g(!1),_(null),w({name:"",description:"",icon:""}),t({title:v?"Private group updated!":"Private group created!"})},onError:Ie=>{t({title:"Error",description:Ie.message,variant:"destructive"})}}),le=Bt({mutationFn:async Ie=>{const{error:Ve}=await K.from("community_private_groups").delete().eq("id",Ie);if(Ve)throw Ve},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),de=Bt({mutationFn:async({id:Ie,direction:Ve})=>{const dt=q.findIndex(Le=>Le.id===Ie);if(Ve==="up"&&dt>0){const Le=q[dt-1],Rt=q[dt];await K.from("community_private_groups").update({sort_order:Rt.sort_order}).eq("id",Le.id),await K.from("community_private_groups").update({sort_order:Le.sort_order}).eq("id",Rt.id)}else if(Ve==="down"&&dts.invalidateQueries({queryKey:["admin-private-groups"]})}),xe=Bt({mutationFn:async({groupId:Ie,userId:Ve,isMember:dt})=>{if(dt){const{error:Le}=await K.from("community_private_group_members").delete().eq("group_id",Ie).eq("user_id",Ve);if(Le)throw Le}else{const{error:Le}=await K.from("community_private_group_members").insert({group_id:Ie,user_id:Ve});if(Le)throw Le}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),be=Bt({mutationFn:async({groupId:Ie,brokerageId:Ve,isMember:dt})=>{if(dt){const{error:Le}=await K.from("community_private_group_members").delete().eq("group_id",Ie).eq("brokerage_id",Ve);if(Le)throw Le}else{const{error:Le}=await K.from("community_private_group_members").insert({group_id:Ie,brokerage_id:Ve});if(Le)throw Le}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ye=Ie=>{i(Ie),u({name:Ie.name,description:Ie.description||"",icon:Ie.icon||""}),o(!0)},ve=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},ke=Ie=>{_(Ie),w({name:Ie.name,description:Ie.description||"",icon:Ie.icon||""}),g(!0)},Ge=()=>{_(null),w({name:"",description:"",icon:""}),g(!0)},Ne=Ie=>{A(Ie),L(""),N(!0)},Ae=Ie=>U.some(Ve=>Ve.user_id===Ie),Pe=Ie=>U.some(Ve=>Ve.brokerage_id===Ie),Fe=Q.filter(Ie=>Ie.name.toLowerCase().includes(I.toLowerCase())||Ie.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Ms,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(Ia,{value:r,onValueChange:n,children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"categories",children:"Public Categories"}),e.jsxs(Ts,{value:"private-groups",children:[e.jsx(Pu,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(Vs,{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(Z,{onClick:ve,children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:$?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):F.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):F.map((Ie,Ve)=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ve===0,onClick:()=>ce.mutate({id:Ie.id,direction:"up"}),children:"↑"}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ve===F.length-1,onClick:()=>ce.mutate({id:Ie.id,direction:"down"}),children:"↓"})]})}),e.jsx(lt,{className:"text-2xl",children:Ie.icon||"📁"}),e.jsx(lt,{className:"font-medium",children:Ie.name}),e.jsx(lt,{className:"text-muted-foreground",children:Ie.description||"—"}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>ye(Ie),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&Y.mutate(Ie.id)},children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},Ie.id))})]})})})]}),e.jsxs(Vs,{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(_a,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(Z,{onClick:Ge,children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:H?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):q.map((Ie,Ve)=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ve===0,onClick:()=>de.mutate({id:Ie.id,direction:"up"}),children:"↑"}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ve===q.length-1,onClick:()=>de.mutate({id:Ie.id,direction:"down"}),children:"↓"})]})}),e.jsx(lt,{className:"text-2xl",children:Ie.icon||"🔒"}),e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ie.name,Ie.brokerage_id?e.jsxs(nt,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(_a,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(nt,{variant:"secondary",className:"text-xs",children:[e.jsx(Pu,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(lt,{className:"text-muted-foreground",children:Ie.description||"—"}),e.jsx(lt,{children:e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>Ne(Ie),children:[e.jsx(xr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[!Ie.brokerage_id&&e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>ke(Ie),children:e.jsx(Ga,{className:"h-4 w-4"})}),!Ie.brokerage_id&&e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&le.mutate(Ie.id)},children:e.jsx(Cr,{className:"h-4 w-4"})}),Ie.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},Ie.id))})]})})})]})]}),e.jsx(bs,{open:a,onOpenChange:o,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Re,{value:d.icon,onChange:Ie=>u(Ve=>({...Ve,icon:Ie.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Re,{value:d.name,onChange:Ie=>u(Ve=>({...Ve,name:Ie.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Lr,{value:d.description,onChange:Ie=>u(Ve=>({...Ve,description:Ie.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(Z,{onClick:()=>te.mutate({...d,id:l==null?void 0:l.id}),disabled:!d.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(bs,{open:f,onOpenChange:g,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:v?"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(Re,{value:b.icon,onChange:Ie=>w(Ve=>({...Ve,icon:Ie.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Re,{value:b.name,onChange:Ie=>w(Ve=>({...Ve,name:Ie.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(Lr,{value:b.description,onChange:Ie=>w(Ve=>({...Ve,description:Ie.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),e.jsx(Z,{onClick:()=>oe.mutate({...b,id:v==null?void 0:v.id}),disabled:!b.name.trim(),children:v?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(bs,{open:j,onOpenChange:N,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Manage Members: ",S==null?void 0:S.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ia,{defaultValue:"brokerages",children:[e.jsxs(Aa,{className:"w-full",children:[e.jsx(Ts,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(Ts,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(Vs,{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(Fi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[se.map(Ie=>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($o,{checked:Pe(Ie.id),onCheckedChange:()=>{S&&be.mutate({groupId:S.id,brokerageId:Ie.id,isMember:Pe(Ie.id)})}}),e.jsx("span",{className:"font-medium",children:Ie.name})]}),e.jsxs(nt,{variant:"secondary",children:[Q.filter(Ve=>Ve.brokerage_id===Ie.id).length," agents"]})]},Ie.id)),se.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(Vs,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search users...",value:I,onChange:Ie=>L(Ie.target.value),className:"pl-9"})]}),e.jsx(Fi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Fe.map(Ie=>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($o,{checked:Ae(Ie.id),onCheckedChange:()=>{S&&xe.mutate({groupId:S.id,userId:Ie.id,isMember:Ae(Ie.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ie.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Ie.email})]})]})},Ie.id)),Fe.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(Z,{onClick:()=>N(!1),children:"Done"})})]})]})})]})})},wTe=t=>{switch(t){case"academy_video":return e.jsx(dl,{className:"h-3 w-3"});case"template":return e.jsx(Un,{className:"h-3 w-3"});case"toolbox":return e.jsx(cl,{className:"h-3 w-3"});case"newsletter":return e.jsx(j0,{className:"h-3 w-3"});case"social_swag":return e.jsx(gn,{className:"h-3 w-3"});default:return e.jsx(un,{className:"h-3 w-3"})}},hLt=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}},mLt=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}},pLt=()=>{const{toast:t}=La(),[s,r]=M.useState([]),[n,a]=M.useState([]),[o,l]=M.useState([]),[i,d]=M.useState(!0),[u,f]=M.useState(""),[g,v]=M.useState(null),[_,b]=M.useState([]),[w,j]=M.useState([]);M.useEffect(()=>{N()},[]);const N=async()=>{try{d(!0);const{data:U,error:Q}=await K.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(Q)throw Q;const{data:se,error:te}=await K.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 Y=[...new Set((se==null?void 0:se.map(ye=>ye.user_id))||[])],{data:ce}=await K.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Y),oe=new Map((ce==null?void 0:ce.map(ye=>[ye.id,ye]))||[]),le=(U==null?void 0:U.map(ye=>{var ve,ke,Ge,Ne;return{id:ye.id,user_id:ye.user_id,app_name:ye.app_name,launched_at:ye.launched_at,user_name:((ve=ye.profiles)==null?void 0:ve.name)||"Unknown",user_email:((ke=ye.profiles)==null?void 0:ke.email)||"Unknown",brokerage_name:((Ne=(Ge=ye.profiles)==null?void 0:Ge.brokerages)==null?void 0:Ne.name)||null}}))||[],de=(se==null?void 0:se.map(ye=>{var ke;const ve=oe.get(ye.user_id);return{id:ye.id,user_id:ye.user_id,resource_type:ye.resource_type,resource_id:ye.resource_id,resource_title:ye.resource_title,action_type:ye.action_type,created_at:ye.created_at,user_name:(ve==null?void 0:ve.name)||"Unknown",user_email:(ve==null?void 0:ve.email)||"Unknown",brokerage_name:((ke=ve==null?void 0:ve.brokerages)==null?void 0:ke.name)||null}}))||[];r(le),a(de);const xe=new Map;le.forEach(ye=>{if(!xe.has(ye.user_id))xe.set(ye.user_id,{user_id:ye.user_id,user_name:ye.user_name,user_email:ye.user_email,brokerage_name:ye.brokerage_name,last_activity_type:"app",last_activity_name:ye.app_name,last_activity_at:ye.launched_at,total_app_launches:1,total_content_views:0});else{const ve=xe.get(ye.user_id);ve.total_app_launches++,new Date(ye.launched_at)>new Date(ve.last_activity_at)&&(ve.last_activity_type="app",ve.last_activity_name=ye.app_name,ve.last_activity_at=ye.launched_at)}}),de.forEach(ye=>{if(!xe.has(ye.user_id))xe.set(ye.user_id,{user_id:ye.user_id,user_name:ye.user_name,user_email:ye.user_email,brokerage_name:ye.brokerage_name,last_activity_type:ye.resource_type,last_activity_name:ye.resource_title,last_activity_at:ye.created_at,total_app_launches:0,total_content_views:1});else{const ve=xe.get(ye.user_id);ve.total_content_views++,new Date(ye.created_at)>new Date(ve.last_activity_at)&&(ve.last_activity_type=ye.resource_type,ve.last_activity_name=ye.resource_title,ve.last_activity_at=ye.created_at)}});const be=Array.from(xe.values()).sort((ye,ve)=>new Date(ve.last_activity_at).getTime()-new Date(ye.last_activity_at).getTime());l(be)}catch(U){console.error("Error loading activity:",U),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},S=U=>{v({id:U.user_id,name:U.user_name,email:U.user_email});const Q=s.filter(te=>te.user_id===U.user_id),se=n.filter(te=>te.user_id===U.user_id);b(Q),j(se)},A=()=>{v(null),b([]),j([])},{sortKey:I,sortDirection:L,handleSort:F,sortData:$}=NL("last_activity_at","desc"),q=o.filter(U=>{var se;if(!u)return!0;const Q=u.toLowerCase();return U.user_name.toLowerCase().includes(Q)||U.user_email.toLowerCase().includes(Q)||((se=U.brokerage_name)==null?void 0:se.toLowerCase().includes(Q))}),H=$(q,{user:U=>{var Q;return((Q=U.user_name)==null?void 0:Q.toLowerCase())||""},brokerage:U=>{var Q;return((Q=U.brokerage_name)==null?void 0:Q.toLowerCase())||""},last_activity_at:U=>new Date(U.last_activity_at).getTime(),apps:U=>U.total_app_launches,content:U=>U.total_content_views});return i?e.jsx(De,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"User Activity"}),e.jsx(_r,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:U=>f(U.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(Qo,{sortKey:"user",currentSortKey:I,currentDirection:L,onSort:F,children:"User"}),e.jsx(Qo,{sortKey:"brokerage",currentSortKey:I,currentDirection:L,onSort:F,children:"Brokerage"}),e.jsx(kt,{children:"Last Activity"}),e.jsx(Qo,{sortKey:"last_activity_at",currentSortKey:I,currentDirection:L,onSort:F,children:"Last Active"}),e.jsx(Qo,{sortKey:"apps",currentSortKey:I,currentDirection:L,onSort:F,className:"text-right",children:"Apps"}),e.jsx(Qo,{sortKey:"content",currentSortKey:I,currentDirection:L,onSort:F,className:"text-right",children:"Content"})]})}),e.jsx(Ln,{children:H.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):H.map(U=>e.jsxs(ks,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>S(U),children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:U.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.user_email})]})}),e.jsx(lt,{children:U.brokerage_name?e.jsx(nt,{variant:"outline",children:U.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(lt,{children:e.jsx("div",{className:"flex items-center gap-2",children:U.last_activity_type==="app"?e.jsxs(nt,{variant:"secondary",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),U.last_activity_name]}):e.jsxs(nt,{variant:"outline",className:"flex items-center gap-1",children:[wTe(U.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:U.last_activity_name})]})})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:$d(new Date(U.last_activity_at),{addSuffix:!0})}),e.jsx(lt,{className:"text-right",children:e.jsx(nt,{variant:"outline",children:U.total_app_launches})}),e.jsx(lt,{className:"text-right",children:e.jsx(nt,{variant:"outline",children:U.total_content_views})})]},U.user_id))})]})})]})]}),e.jsx(bs,{open:!!g,onOpenChange:U=>!U&&A(),children:e.jsxs(_s,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[g==null?void 0:g.name,"'s Activity"]}),e.jsx(Kr,{children:g==null?void 0:g.email})]}),e.jsxs(Ia,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ts,{value:"content",children:["Content (",w.length,")"]}),e.jsxs(Ts,{value:"apps",children:["App Launches (",_.length,")"]})]}),e.jsx(Vs,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Resource"}),e.jsx(kt,{children:"Action"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(Ln,{children:w.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):w.map(U=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs(nt,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[wTe(U.resource_type),hLt(U.resource_type)]})}),e.jsx(lt,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:U.resource_title})}),e.jsx(lt,{children:e.jsx(nt,{variant:"secondary",children:mLt(U.action_type)})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:$d(new Date(U.created_at),{addSuffix:!0})})]},U.id))})]})})}),e.jsx(Vs,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"App"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(Ln,{children:_.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(U=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsx(nt,{variant:"secondary",children:U.app_name})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:$d(new Date(U.launched_at),{addSuffix:!0})})]},U.id))})]})})})]})]})})]})},fLt=()=>{const{toast:t}=La(),[s,r]=M.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=M.useState(!0);M.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await K.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await K.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),d=(l||0)-(i||0),{count:u}=await K.from("brokerages").select("*",{count:"exact",head:!0}),{count:f}=await K.from("activity_logs").select("*",{count:"exact",head:!0}),g=new Date;g.setDate(g.getDate()-7);const{count:v}=await K.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",g.toISOString()),_=new Date;_.setMonth(_.getMonth()-1);const{count:b}=await K.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",_.toISOString()),{data:w}=await K.from("activity_logs").select("user_id").gte("launched_at",g.toISOString()),j=new Set(w==null?void 0:w.map(N=>N.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:d,totalBrokerages:u||0,totalLaunches:f||0,launchesThisWeek:v||0,launchesThisMonth:b||0,uniqueActiveThisWeek:j})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(De,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeUsers," active, ",s.pendingUsers," pending"]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(hi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.activeUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalUsers>0?`${Math.round(s.activeUsers/s.totalUsers*100)}% of total`:"0% of total"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.pendingUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(_a,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalBrokerages}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Fx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(Fx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(Fx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Vc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},jTe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},kTe={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 HWe({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=M.useState([]),[a,o]=M.useState(!0),[l,i]=M.useState(""),[d,u]=M.useState("all");M.useEffect(()=>{f()},[s]);const f=async()=>{o(!0);try{let F=[];if(t&&s){const{data:Y}=await K.from("profiles").select("id").eq("brokerage_id",s);if(F=(Y==null?void 0:Y.map(ce=>ce.id))||[],F.length===0){n([]),o(!1);return}}let $=K.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&F.length>0&&($=$.or(`sender_id.in.(${F.join(",")}),recipient_id.in.(${F.join(",")})`));const{data:q,error:H}=await $;if(H)throw H;const U=new Set;q==null||q.forEach(Y=>{U.add(Y.sender_id),U.add(Y.recipient_id)});const{data:Q}=await K.from("profiles").select("id, name, email").in("id",Array.from(U)),se=new Map((Q==null?void 0:Q.map(Y=>[Y.id,Y]))||[]),te=(q==null?void 0:q.map(Y=>({...Y,sender:se.get(Y.sender_id),recipient:se.get(Y.recipient_id)})))||[];n(te)}catch(F){console.error("Error loading shares:",F)}finally{o(!1)}},{sortKey:g,sortDirection:v,handleSort:_,sortData:b}=NL("created_at","desc"),w=r.filter(F=>{var H,U;const $=l===""||F.resource_title.toLowerCase().includes(l.toLowerCase())||((H=F.sender)==null?void 0:H.name.toLowerCase().includes(l.toLowerCase()))||((U=F.recipient)==null?void 0:U.name.toLowerCase().includes(l.toLowerCase())),q=d==="all"||F.resource_type===d;return $&&q}),j=b(w,{resource:F=>{var $;return(($=F.resource_title)==null?void 0:$.toLowerCase())||""},type:F=>F.resource_type,sender:F=>{var $,q;return((q=($=F.sender)==null?void 0:$.name)==null?void 0:q.toLowerCase())||""},recipient:F=>{var $,q;return((q=($=F.recipient)==null?void 0:$.name)==null?void 0:q.toLowerCase())||""},status:F=>F.is_read?1:0,created_at:F=>new Date(F.created_at).getTime()}),N=r.length,S=new Set(r.map(F=>F.sender_id)).size,A=new Set(r.map(F=>F.recipient_id)).size,I=r.length>0?Math.round(r.filter(F=>F.is_read).length/r.length*100):0,L=r.reduce((F,$)=>(F[$.resource_type]=(F[$.resource_type]||0)+1,F),{});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((F,$)=>e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(gs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(gs,{className:"h-8 w-16"})})]},$))}),e.jsx(De,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(gs,{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(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(nd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:N})})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Vc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:A})})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(L).map(([F,$])=>e.jsxs(nt,{variant:"secondary",className:kTe[F],children:[jTe[F],": ",$]},F)),Object.keys(L).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Share History"}),e.jsxs(_r,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:F=>i(F.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:d,onValueChange:u,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Resource type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),e.jsx(At,{value:"event",children:"Events"}),e.jsx(At,{value:"template",children:"Templates"}),e.jsx(At,{value:"academy_video",children:"Academy Videos"}),e.jsx(At,{value:"resource_kit",children:"Resource Kits"}),e.jsx(At,{value:"newsletter",children:"Newsletters"}),e.jsx(At,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(Fi,{className:"h-[400px]",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(Qo,{sortKey:"resource",currentSortKey:g,currentDirection:v,onSort:_,children:"Resource"}),e.jsx(Qo,{sortKey:"type",currentSortKey:g,currentDirection:v,onSort:_,children:"Type"}),e.jsx(Qo,{sortKey:"sender",currentSortKey:g,currentDirection:v,onSort:_,children:"Sender"}),e.jsx(Qo,{sortKey:"recipient",currentSortKey:g,currentDirection:v,onSort:_,children:"Recipient"}),e.jsx(Qo,{sortKey:"status",currentSortKey:g,currentDirection:v,onSort:_,children:"Status"}),e.jsx(Qo,{sortKey:"created_at",currentSortKey:g,currentDirection:v,onSort:_,children:"Date"})]})}),e.jsx(Ln,{children:j.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):j.map(F=>{var $,q;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium max-w-[200px] truncate",children:F.resource_title}),e.jsx(lt,{children:e.jsx(nt,{variant:"secondary",className:kTe[F.resource_type],children:jTe[F.resource_type]})}),e.jsx(lt,{children:(($=F.sender)==null?void 0:$.name)||"Unknown"}),e.jsx(lt,{children:((q=F.recipient)==null?void 0:q.name)||"Unknown"}),e.jsx(lt,{children:e.jsx(nt,{variant:F.is_read?"default":"outline",children:F.is_read?"Read":"Unread"})}),e.jsx(lt,{className:"text-muted-foreground",children:js(new Date(F.created_at),"MMM d, yyyy")})]},F.id)})})]})})]})]})]})}const _me={academy_video:{label:"Academy Videos",icon:Cn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:Na},template:{label:"Templates",icon:Jy,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:ym},toolbox:{label:"Toolkit",icon:Vx,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:Ei},newsletter:{label:"Newsletters",icon:Ar,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:ym},social_swag:{label:"Social Swag",icon:El,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:ym},event:{label:"Events",icon:nn,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:ym}};function NTe(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function gLt(t,s){return t==="toolbox"?s.downloads:s.clicks}function xLt(){var F;const[t,s]=M.useState([]),[r,n]=M.useState(!0),[a,o]=M.useState(null),l=M.useRef(null),{sortKey:i,sortDirection:d,handleSort:u,sortData:f}=NL("total_views","desc");M.useEffect(()=>{g()},[]);const g=async()=>{try{const{data:$,error:q}=await K.rpc("get_admin_content_engagement");if(q)throw q;s($||[])}catch($){console.error("Error loading content engagement:",$)}finally{n(!1)}},v=$=>{o(q=>{const H=q===$?null:$;return requestAnimationFrame(()=>{var U;(U=l.current)==null||U.scrollIntoView({behavior:"smooth",block:"start"})}),H})};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)=>e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(gs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(gs,{className:"h-8 w-16"})})]},q))}),e.jsx(De,{children:e.jsx(Oe,{className:"py-8",children:e.jsx(gs,{className:"h-64 w-full"})})})]});const _=t.reduce(($,q)=>$+q.total_views,0),b=t.reduce(($,q)=>$+q.total_clicks,0),w=t.reduce(($,q)=>$+q.total_downloads,0),j=t.length,N=t.reduce(($,q)=>($[q.resource_type]||($[q.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),$[q.resource_type].views+=q.total_views,$[q.resource_type].clicks+=q.total_clicks,$[q.resource_type].downloads+=q.total_downloads,$[q.resource_type].assets+=1,$[q.resource_type].uniqueUsers+=q.unique_users,$),{}),S=a?t.filter($=>$.resource_type===a):t,A=f(S,{asset:$=>{var q;return((q=$.resource_title)==null?void 0:q.toLowerCase())||""},type:$=>$.resource_type,views:$=>$.total_views,actions:$=>NTe($),unique_users:$=>$.unique_users,last_activity:$=>$.last_engaged_at?new Date($.last_engaged_at).getTime():0}),I=a?_me[a]||{label:a,icon:Na,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(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(Na,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(ym,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link & Canva clicks"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(Ei,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Vc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(ym,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[_>0?Math.round((b+w)/_*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(_r,{children:"Click a category to see individual asset performance"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(N).map(([$,q])=>{const H=_me[$]||{label:$,icon:Na,color:"bg-muted text-muted-foreground",actionIcon:ym},U=H.icon,Q=a===$;return e.jsxs("button",{type:"button",onClick:()=>v($),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${Q?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${H.color}`,children:e.jsx(U,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:H.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(Na,{className:"h-3 w-3"})," ",q.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(H.actionIcon,{className:"h-3 w-3"})," ",gLt($,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xr,{className:"h-3 w-3"})," ",q.uniqueUsers]})]})]}),e.jsxs(nt,{variant:"secondary",className:"text-[10px]",children:[q.assets," items"]})]},$)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{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(_r,{children:a?`${S.length} ${((F=I==null?void 0:I.label)==null?void 0:F.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Ba,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Oe,{children:S.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(Fi,{className:"h-[400px]",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{className:"w-[40px]",children:"#"}),e.jsx(Qo,{sortKey:"asset",currentSortKey:i,currentDirection:d,onSort:u,children:"Asset"}),!a&&e.jsx(Qo,{sortKey:"type",currentSortKey:i,currentDirection:d,onSort:u,children:"Type"}),e.jsx(Qo,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Views"}),e.jsx(Qo,{sortKey:"actions",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:I?I.actionLabel:"Actions"}),e.jsx(Qo,{sortKey:"unique_users",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(Qo,{sortKey:"last_activity",currentSortKey:i,currentDirection:d,onSort:u,children:"Last Activity"})]})}),e.jsx(Ln,{children:A.map(($,q)=>{const H=_me[$.resource_type]||{label:$.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(ks,{children:[e.jsx(lt,{className:"text-muted-foreground text-xs",children:q+1}),e.jsx(lt,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:$.resource_title})}),!a&&e.jsx(lt,{children:e.jsx(nt,{className:`text-[10px] ${H.color}`,children:H.label})}),e.jsx(lt,{className:"text-right font-medium",children:$.total_views}),e.jsx(lt,{className:"text-right font-medium",children:NTe($)}),e.jsx(lt,{className:"text-right",children:$.unique_users}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:$.last_engaged_at?$d(new Date($.last_engaged_at),{addSuffix:!0}):"—"})]},`${$.resource_type}-${$.resource_id}`)})})]})})})]})})]})}const yLt=()=>e.jsx(Ms,{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(Ia,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"analytics",children:"Analytics"}),e.jsx(Ts,{value:"content",children:"Content"}),e.jsx(Ts,{value:"activity",children:"Activity"}),e.jsx(Ts,{value:"shares",children:"Shares"})]}),e.jsx(Vs,{value:"analytics",className:"space-y-4",children:e.jsx(fLt,{})}),e.jsx(Vs,{value:"content",className:"space-y-4",children:e.jsx(xLt,{})}),e.jsx(Vs,{value:"activity",className:"space-y-4",children:e.jsx(pLt,{})}),e.jsx(Vs,{value:"shares",className:"space-y-4",children:e.jsx(HWe,{})})]})]})});function vLt(){const t=ds(),[s,r]=M.useState(!1),[n,a]=M.useState(null),[o,l]=M.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=M.useState(null),[u,f]=M.useState(""),[g,v]=M.useState([]),[_,b]=M.useState([]),[w,j]=M.useState([]),[N,S]=M.useState(!1),[A,I]=M.useState(null),[L,F]=M.useState(""),{data:$,isLoading:q}=Tt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:Le,error:Rt}=await K.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(Rt)throw Rt;return Le}}),{data:H}=Tt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:Le,error:Rt}=await K.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return Le}}),{data:U}=Tt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:Le,error:Rt}=await K.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return Le}}),{data:Q}=Tt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:Le,error:Rt}=await K.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return Le}}),{data:se,isLoading:te}=Tt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:Le,error:Rt}=await K.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return Le}}),Y=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),d(null),f(""),v([]),b([]),j([]),a(null),F("")},ce=Le=>{a(Le),l({title:Le.title,description:Le.description||"",publish_date:Le.publish_date.split("T")[0],is_published:Le.is_published,category_id:Le.category_id||""}),f(Le.preview_image_url||""),F("");const Rt=(H==null?void 0:H.filter(at=>at.resource_id===Le.id))||[];v(Rt.map(at=>({id:at.id,name:at.name,file_url:at.file_url,file_size:at.file_size,sort_order:at.sort_order})));const fe=(U==null?void 0:U.filter(at=>at.resource_id===Le.id))||[];b(fe.map(at=>({id:at.id,title:at.title,video_url:at.video_url,sort_order:at.sort_order})));const Qe=(Q==null?void 0:Q.filter(at=>at.resource_id===Le.id))||[];j(Qe.map(at=>({id:at.id,title:at.title,canva_share_link:at.canva_share_link,sort_order:at.sort_order}))),r(!0)},oe=Le=>{var fe;const Rt=(fe=Le.target.files)==null?void 0:fe[0];Rt&&(d(Rt),f(URL.createObjectURL(Rt)))},le=()=>{v([...g,{name:"",file_url:"",sort_order:g.length}])},de=Le=>{v(g.filter((Rt,fe)=>fe!==Le))},xe=(Le,Rt,fe)=>{const Qe=[...g];if(Rt==="file"&&fe instanceof File){const at=fe.name.replace(/\.[^/.]+$/,"");Qe[Le]={...Qe[Le],file:fe,file_size:fe.size,name:Qe[Le].name||at}}else Qe[Le]={...Qe[Le],[Rt]:fe};v(Qe)},be=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},ye=Le=>{b(_.filter((Rt,fe)=>fe!==Le))},ve=(Le,Rt,fe)=>{const Qe=[..._];Rt==="file"&&fe instanceof File?Qe[Le]={...Qe[Le],file:fe}:Qe[Le]={...Qe[Le],[Rt]:fe},b(Qe)},ke=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},Ge=Le=>{j(w.filter((Rt,fe)=>fe!==Le))},Ne=(Le,Rt,fe)=>{const Qe=[...w];Qe[Le]={...Qe[Le],[Rt]:fe},j(Qe)},Ae=async(Le,Rt)=>{try{const fe=await K.functions.invoke("bunny-upload",{body:{action:"create",title:Le.name}});if(fe.error)throw fe.error;const{videoId:Qe,uploadUrl:at,libraryId:rt}=fe.data,je=await K.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Qe,libraryId:rt}});if(je.error)throw je.error;const{uploadUrl:mt,apiKey:He}=je.data,ct=new XMLHttpRequest;return ct.open("PUT",mt,!0),ct.setRequestHeader("AccessKey",He),ct.upload.onprogress=We=>{if(We.lengthComputable){const Ze=Math.round(We.loaded/We.total*100),ht=[..._];ht[Rt]={...ht[Rt],uploadProgress:Ze},b(ht)}},await new Promise((We,Ze)=>{ct.onload=()=>ct.status>=200&&ct.status<300?We():Ze(new Error("Upload failed")),ct.onerror=()=>Ze(new Error("Upload failed")),ct.send(Le)}),`https://iframe.mediadelivery.net/embed/${rt}/${Qe}`}catch(fe){throw console.error("Bunny upload error:",fe),fe}},Pe=Bt({mutationFn:async Le=>{const{data:Rt,error:fe}=await K.from("brokerage_resource_categories").insert({name:Le,sort_order:(se==null?void 0:se.length)||0}).select().single();if(fe)throw fe;return Rt},onSuccess:Le=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:Le.id}),F(""),ge.success("Category created")},onError:Le=>{ge.error("Failed to create category: "+Le.message)}}),Fe=Bt({mutationFn:async()=>{S(!0);let Le=(n==null?void 0:n.preview_image_url)||null;if(i){const Qe=i.name.split(".").pop(),at=`${Date.now()}.${Qe}`,{error:rt}=await K.storage.from("brokerage-resources").upload(`previews/${at}`,i);if(rt)throw rt;const{data:je}=K.storage.from("brokerage-resources").getPublicUrl(`previews/${at}`);Le=je.publicUrl}const Rt={title:o.title,description:o.description||null,preview_image_url:Le,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let fe;if(n){const{error:Qe}=await K.from("brokerage_resources").update(Rt).eq("id",n.id);if(Qe)throw Qe;fe=n.id;const at=(H==null?void 0:H.filter(Ke=>Ke.resource_id===n.id).map(Ke=>Ke.id))||[],rt=g.filter(Ke=>Ke.id).map(Ke=>Ke.id),je=at.filter(Ke=>!rt.includes(Ke));je.length>0&&await K.from("brokerage_resource_pdfs").delete().in("id",je);const mt=(U==null?void 0:U.filter(Ke=>Ke.resource_id===n.id).map(Ke=>Ke.id))||[],He=_.filter(Ke=>Ke.id).map(Ke=>Ke.id),ct=mt.filter(Ke=>!He.includes(Ke));ct.length>0&&await K.from("brokerage_resource_videos").delete().in("id",ct);const We=(Q==null?void 0:Q.filter(Ke=>Ke.resource_id===n.id).map(Ke=>Ke.id))||[],Ze=w.filter(Ke=>Ke.id).map(Ke=>Ke.id),ht=We.filter(Ke=>!Ze.includes(Ke));ht.length>0&&await K.from("brokerage_resource_links").delete().in("id",ht)}else{const{data:Qe,error:at}=await K.from("brokerage_resources").insert(Rt).select().single();if(at)throw at;fe=Qe.id}for(let Qe=0;Qe{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),ge.success(n?"Resource updated":"Resource created"),r(!1),Y(),S(!1)},onError:Le=>{ge.error("Failed to save resource: "+Le.message),S(!1)}}),Ie=Bt({mutationFn:async Le=>{const{error:Rt}=await K.from("brokerage_resources").delete().eq("id",Le);if(Rt)throw Rt},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),ge.success("Resource deleted")},onError:Le=>{ge.error("Failed to delete: "+Le.message)}}),Ve=Le=>{if(Le.preventDefault(),!o.title){ge.error("Please enter a title");return}Fe.mutate()},dt=Le=>{const Rt=(H==null?void 0:H.filter(at=>at.resource_id===Le).length)||0,fe=(U==null?void 0:U.filter(at=>at.resource_id===Le).length)||0,Qe=(Q==null?void 0:Q.filter(at=>at.resource_id===Le).length)||0;return{pdfCount:Rt,videoCount:fe,linkCount:Qe}};return e.jsx(Ms,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.length)||0})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.filter(Le=>Le.is_published).length)||0})})]})]}),e.jsxs(Z,{onClick:()=>{Y(),r(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:q?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):($==null?void 0:$.length)===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):$==null?void 0:$.map(Le=>{const{pdfCount:Rt,videoCount:fe,linkCount:Qe}=dt(Le.id),at=se==null?void 0:se.find(rt=>rt.id===Le.category_id);return e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Le.preview_image_url?e.jsx("img",{src:Le.preview_image_url,alt:Le.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(Zu,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Le.title}),Le.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Le.description})]})]})}),e.jsx(lt,{children:at?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:at.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{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(Un,{className:"h-3.5 w-3.5"}),Rt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),fe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Po,{className:"h-3.5 w-3.5"}),Qe]})]})}),e.jsx(lt,{children:js(new Date(Le.publish_date),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Le.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Le.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{const rt=(H==null?void 0:H.filter(He=>He.resource_id===Le.id))||[],je=(U==null?void 0:U.filter(He=>He.resource_id===Le.id))||[],mt=(Q==null?void 0:Q.filter(He=>He.resource_id===Le.id))||[];I({...Le,pdfs:rt,videos:je,links:mt})},children:e.jsx(Na,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>ce(Le),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&Ie.mutate(Le.id)},children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},Le.id)})})]})})}),e.jsx(bs,{open:s,onOpenChange:r,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Ve,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{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(Zu,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Re,{type:"file",accept:"image/*",onChange:oe})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:o.title,onChange:Le=>l({...o,title:Le.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(pp,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:o.category_id,onValueChange:Le=>l({...o,category_id:Le}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select a category"})}),e.jsx(er,{children:se==null?void 0:se.map(Le=>e.jsx(At,{value:Le.id,children:Le.name},Le.id))})]}),o.category_id&&e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Vr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Or create new category...",value:L,onChange:Le=>F(Le.target.value),className:"flex-1"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||Pe.isPending,onClick:()=>Pe.mutate(L.trim()),children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Wg,{content:o.description,onChange:Le=>l({...o,description:Le}),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(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:o.publish_date,onChange:Le=>l({...o,publish_date:Le.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(qr,{checked:o.is_published,onCheckedChange:Le=>l({...o,is_published:Le})}),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(_e,{className:"flex items-center gap-2",children:[e.jsx(Un,{className:"h-4 w-4"}),"PDF Documents (",g.length,")"]}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:le,children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),g.map((Le,Rt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Re,{placeholder:"PDF Name",value:Le.name,onChange:fe=>xe(Rt,"name",fe.target.value),className:"flex-1"}),e.jsx(Re,{type:"file",accept:".pdf",onChange:fe=>{var at;const Qe=(at=fe.target.files)==null?void 0:at[0];Qe&&xe(Rt,"file",Qe)},className:"flex-1"}),Le.file_url&&!Le.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>de(Rt),children:e.jsx(Vr,{className:"h-4 w-4"})})]},Rt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:be,children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((Le,Rt)=>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(Re,{placeholder:"Video Title",value:Le.title,onChange:fe=>ve(Rt,"title",fe.target.value),className:"flex-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>ye(Rt),children:e.jsx(Vr,{className:"h-4 w-4"})})]}),e.jsx(Re,{type:"file",accept:"video/*",onChange:fe=>{var at;const Qe=(at=fe.target.files)==null?void 0:at[0];Qe&&ve(Rt,"file",Qe)}}),Le.uploadProgress!==void 0&&Le.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:`${Le.uploadProgress}%`}})}),Le.video_url&&!Le.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},Rt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(Po,{className:"h-4 w-4"}),"Canva Links (",w.length,")"]}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:ke,children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),w.map((Le,Rt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Re,{placeholder:"Link Title",value:Le.title,onChange:fe=>Ne(Rt,"title",fe.target.value),className:"flex-1"}),e.jsx(Re,{placeholder:"Canva Share Link",value:Le.canva_share_link,onChange:fe=>Ne(Rt,"canva_share_link",fe.target.value),className:"flex-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ge(Rt),children:e.jsx(Vr,{className:"h-4 w-4"})})]},Rt))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:Fe.isPending||N,children:Fe.isPending||N?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(bs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:A==null?void 0:A.title})}),A&&e.jsxs("div",{className:"space-y-4",children:[A.preview_image_url&&e.jsx("img",{src:A.preview_image_url,alt:A.title,className:"w-full h-48 object-cover rounded-lg"}),A.description&&e.jsx("p",{className:"text-muted-foreground",children:A.description}),A.pdfs&&A.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Un,{className:"h-4 w-4"}),"PDF Documents (",A.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.pdfs.map(Le=>e.jsx("a",{href:Le.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Le.name},Le.id))})]}),A.videos&&A.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 (",A.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.videos.map(Le=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:Le.title})},Le.id))})]}),A.links&&A.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Po,{className:"h-4 w-4"}),"Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.links.map(Le=>e.jsx("a",{href:Le.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Le.title},Le.id))})]})]})]})})]})})}const WWe=[{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 _Lt(){const[t,s]=M.useState([]),[r,n]=M.useState(!0),[a,o]=M.useState(!1),[l,i]=M.useState(!1),[d,u]=M.useState(null),[f,g]=M.useState(!1),[v,_]=M.useState(!1),[b,w]=M.useState(""),[j,N]=M.useState(""),[S,A]=M.useState(""),[I,L]=M.useState(""),[F,$]=M.useState("Learn More"),[q,H]=M.useState("top"),[U,Q]=M.useState(""),[se,te]=M.useState(!0),[Y,ce]=M.useState(""),[oe,le]=M.useState("");M.useEffect(()=>{de()},[]);const de=async()=>{try{const{data:Pe,error:Fe}=await K.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Fe)throw Fe;s(Pe||[])}catch(Pe){ge.error("Failed to load banners: "+Pe.message)}finally{n(!1)}},xe=()=>{w(""),N(""),A(""),L(""),$("Learn More"),H("top"),Q(""),te(!0),ce(""),le(""),u(null)},be=Pe=>{u(Pe),w(Pe.title),N(Pe.description||""),A(Pe.image_url),L(Pe.link_url||""),$(Pe.link_text||"Learn More"),H(Pe.placement),Q(Pe.section_after||""),te(Pe.is_active),ce(Pe.start_date?js(new Date(Pe.start_date),"yyyy-MM-dd'T'HH:mm"):""),le(Pe.end_date?js(new Date(Pe.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ye=async Pe=>{var Ie;const Fe=(Ie=Pe.target.files)==null?void 0:Ie[0];if(Fe){g(!0);try{const Ve=Fe.name.split(".").pop(),dt=`${Date.now()}.${Ve}`,{error:Le}=await K.storage.from("banner-images").upload(dt,Fe);if(Le)throw Le;const{data:{publicUrl:Rt}}=K.storage.from("banner-images").getPublicUrl(dt);A(Rt),ge.success("Image uploaded successfully")}catch(Ve){ge.error("Failed to upload image: "+Ve.message)}finally{g(!1)}}},ve=async()=>{if(!b.trim()||!S){ge.error("Please fill in required fields (title and image)");return}_(!0);try{const Pe={title:b.trim(),description:j.trim()||null,image_url:S,link_url:I.trim()||null,link_text:F.trim()||"Learn More",placement:q,section_after:q==="between"?U:null,is_active:se,start_date:Y?new Date(Y).toISOString():null,end_date:oe?new Date(oe).toISOString():null};if(d){const{error:Fe}=await K.from("dashboard_banners").update(Pe).eq("id",d.id);if(Fe)throw Fe;ge.success("Banner updated successfully")}else{const Fe=t.filter(Ve=>Ve.placement===q).length,{error:Ie}=await K.from("dashboard_banners").insert({...Pe,sort_order:Fe});if(Ie)throw Ie;ge.success("Banner created successfully")}o(!1),xe(),de()}catch(Pe){ge.error("Failed to save banner: "+Pe.message)}finally{_(!1)}},ke=async()=>{if(d)try{const{error:Pe}=await K.from("dashboard_banners").delete().eq("id",d.id);if(Pe)throw Pe;ge.success("Banner deleted successfully"),i(!1),u(null),de()}catch(Pe){ge.error("Failed to delete banner: "+Pe.message)}},Ge=async Pe=>{try{const{error:Fe}=await K.from("dashboard_banners").update({is_active:!Pe.is_active}).eq("id",Pe.id);if(Fe)throw Fe;ge.success(Pe.is_active?"Banner deactivated":"Banner activated"),de()}catch(Fe){ge.error("Failed to update banner: "+Fe.message)}},Ne=t.filter(Pe=>Pe.placement==="top"),Ae=t.filter(Pe=>Pe.placement==="between");return r?e.jsx(Ms,{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(Ms,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(_r,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(bs,{open:a&&q==="top",onOpenChange:Pe=>{Pe||xe(),o(Pe),Pe&&H("top")},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{onClick:()=>{xe(),H("top")},children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[d?"Edit":"Create"," Banner"]}),e.jsx(Kr,{children:"Configure the banner's content and display settings"})]}),e.jsx(STe,{title:b,setTitle:w,description:j,setDescription:N,imageUrl:S,linkUrl:I,setLinkUrl:L,linkText:F,setLinkText:$,placement:q,setPlacement:H,sectionAfter:U,setSectionAfter:Q,isActive:se,setIsActive:te,startDate:Y,setStartDate:ce,endDate:oe,setEndDate:le,handleImageUpload:ye,uploading:f,showPlacementOptions:!1}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>{o(!1),xe()},children:"Cancel"}),e.jsx(Z,{onClick:ve,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{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(Pe=>e.jsx(CTe,{banner:Pe,onEdit:()=>be(Pe),onDelete:()=>{u(Pe),i(!0)},onToggleActive:()=>Ge(Pe)},Pe.id))})})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(_r,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(bs,{open:a&&q==="between",onOpenChange:Pe=>{Pe||xe(),o(Pe),Pe&&H("between")},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{onClick:()=>{xe(),H("between")},children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[d?"Edit":"Create"," Section Banner"]}),e.jsx(Kr,{children:"Configure where this banner appears between sections"})]}),e.jsx(STe,{title:b,setTitle:w,description:j,setDescription:N,imageUrl:S,linkUrl:I,setLinkUrl:L,linkText:F,setLinkText:$,placement:q,setPlacement:H,sectionAfter:U,setSectionAfter:Q,isActive:se,setIsActive:te,startDate:Y,setStartDate:ce,endDate:oe,setEndDate:le,handleImageUpload:ye,uploading:f,showPlacementOptions:!0}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>{o(!1),xe()},children:"Cancel"}),e.jsx(Z,{onClick:ve,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{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(Pe=>e.jsx(CTe,{banner:Pe,onEdit:()=>be(Pe),onDelete:()=>{u(Pe),i(!0)},onToggleActive:()=>Ge(Pe),showSection:!0},Pe.id))})})]})]}),e.jsx(bs,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Delete Banner"}),e.jsxs(Kr,{children:['Are you sure you want to delete "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(Z,{variant:"destructive",onClick:ke,children:"Delete"})]})]})})]})}function STe({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:u,setPlacement:f,sectionAfter:g,setSectionAfter:v,isActive:_,setIsActive:b,startDate:w,setStartDate:j,endDate:N,setEndDate:S,handleImageUpload:A,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(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",placeholder:"Banner headline...",value:t,onChange:F=>s(F.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",placeholder:"Optional banner description...",value:r,onChange:F=>n(F.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:A,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(_e,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(Re,{id:"linkUrl",placeholder:"https://...",value:o,onChange:F=>l(F.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"linkText",children:"Button Text"}),e.jsx(Re,{id:"linkText",placeholder:"Learn More",value:i,onChange:F=>d(F.target.value)})]})]}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Placement"}),e.jsxs(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select section placement..."})}),e.jsx(er,{children:WWe.map(F=>e.jsx(At,{value:F.value,children:F.label},F.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(Re,{id:"startDate",type:"datetime-local",value:w,onChange:F=>j(F.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(Re,{id:"endDate",type:"datetime-local",value:N,onChange:F=>S(F.target.value)})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"isActive",checked:_,onCheckedChange:b}),e.jsx(_e,{htmlFor:"isActive",children:"Active"})]})})]})}function CTe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=WWe.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(Rh,{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(nt,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(nt,{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(Z,{variant:"ghost",size:"icon",children:e.jsx(un,{className:"h-4 w-4"})})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(Na,{className:"h-4 w-4"}):e.jsx(Nm,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})]})}const U8={open:{label:"Open",icon:Tn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:mc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:hi,color:"bg-green-500"},closed:{label:"Closed",icon:bc,color:"bg-muted-foreground"}},MTe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function bLt(){var F,$;const{user:t}=Qs(),s=ds(),[r,n]=M.useState(null),[a,o]=M.useState(""),[l,i]=M.useState("all"),[d,u]=M.useState("all"),[f,g]=M.useState(!1),{data:v=[],isLoading:_}=Tt({queryKey:["admin-support-tickets",l,d],queryFn:async()=>{let q=K.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(q=q.eq("status",l)),d!=="all"&&(q=q.eq("category",d));const{data:H,error:U}=await q;if(U)throw U;return H}}),{data:b=[]}=Tt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:q,error:H}=await K.from("user_roles").select("user_id").eq("role","admin");if(H)throw H;const U=q.map(oe=>oe.user_id),{data:Q,error:se}=await K.from("profiles").select("id, name, email").in("id",U);if(se)throw se;const{data:te,error:Y}=await K.from("support_notification_settings").select("user_id, receive_notifications");if(Y)throw Y;const ce=new Map((te==null?void 0:te.map(oe=>[oe.user_id,oe.receive_notifications]))||[]);return Q.map(oe=>({...oe,receives_notifications:ce.get(oe.id)||!1}))}}),{data:w=[]}=Tt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:q,error:H}=await K.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(H)throw H;return q},enabled:!!r}),j=Bt({mutationFn:async({userId:q,enabled:H})=>{const{data:U}=await K.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(U){const{error:Q}=await K.from("support_notification_settings").update({receive_notifications:H}).eq("user_id",q);if(Q)throw Q}else{const{error:Q}=await K.from("support_notification_settings").insert({user_id:q,receive_notifications:H});if(Q)throw Q}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),ge.success("Notification settings updated")},onError:()=>{ge.error("Failed to update settings")}}),N=Bt({mutationFn:async({ticketId:q,status:H})=>{const{error:U}=await K.from("support_tickets").update({status:H}).eq("id",q);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),ge.success("Status updated")},onError:()=>{ge.error("Failed to update status")}}),S=Bt({mutationFn:async({ticketId:q,assignedTo:H})=>{const{error:U}=await K.from("support_tickets").update({assigned_to:H}).eq("id",q);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),ge.success("Ticket assigned")},onError:()=>{ge.error("Failed to assign ticket")}}),A=Bt({mutationFn:async q=>{var U,Q;if(!r||!t)throw new Error("Missing data");const{error:H}=await K.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:q,is_admin_reply:!0});if(H)throw H;try{await K.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:q,userEmail:(U=r.profiles)==null?void 0:U.email,userName:(Q=r.profiles)==null?void 0:Q.name}})}catch(se){console.error("Failed to send reply notification:",se)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),ge.success("Reply sent!")},onError:()=>{ge.error("Failed to send reply")}}),I=()=>{a.trim()&&A.mutate(a)};M.useEffect(()=>{const q=K.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{K.removeChannel(q)}},[s]);const L=v.filter(q=>q.status==="open").length;return r?(U8[r.status].icon,e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Ba,{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(nt,{variant:"secondary",children:MTe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((F=r.profiles)==null?void 0:F.name)||"Unknown"," (",($=r.profiles)==null?void 0:$.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm",children:"Status"})}),e.jsx(Oe,{children:e.jsxs(tr,{value:r.status,onValueChange:q=>{N.mutate({ticketId:r.id,status:q}),n({...r,status:q})},children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"open",children:"Open"}),e.jsx(At,{value:"in_progress",children:"In Progress"}),e.jsx(At,{value:"resolved",children:"Resolved"}),e.jsx(At,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm",children:"Assigned To"})}),e.jsx(Oe,{children:e.jsxs(tr,{value:r.assigned_to||"unassigned",onValueChange:q=>{const H=q==="unassigned"?null:q;S.mutate({ticketId:r.id,assignedTo:H}),n({...r,assigned_to:H})},children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Unassigned"})}),e.jsxs(er,{children:[e.jsx(At,{value:"unassigned",children:"Unassigned"}),b.map(q=>e.jsx(At,{value:q.id,children:q.name},q.id))]})]})})]})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(_r,{children:["Created on ",js(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Fi,{className:"h-[300px] pr-4",children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:w.map(q=>{var H,U;return e.jsxs("div",{className:`p-4 rounded-lg ${q.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:q.is_admin_reply?`${((H=q.profiles)==null?void 0:H.name)||"Admin"} (Support)`:((U=q.profiles)==null?void 0:U.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:js(new Date(q.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:q.content})]},q.id)})})}),e.jsx(Jl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Lr,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(Z,{onClick:I,disabled:!a.trim()||A.isPending,className:"self-end",children:e.jsx(Pa,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Ms,{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(nt,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(bs,{open:f,onOpenChange:g,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",children:[e.jsx(Pl,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Email Notification Settings"}),e.jsx(Kr,{children:"Choose which admins receive email notifications for new support tickets."})]}),e.jsx("div",{className:"space-y-4 mt-4",children:b.map(q=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(mo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:q.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q.receives_notifications?e.jsx(af,{className:"h-4 w-4 text-primary"}):e.jsx(U1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(qr,{checked:q.receives_notifications,onCheckedChange:H=>j.mutate({userId:q.id,enabled:H})})]})]},q.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(Ia,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(Aa,{children:[e.jsx(Ts,{value:"all",children:"All"}),e.jsx(Ts,{value:"open",children:"Open"}),e.jsx(Ts,{value:"in_progress",children:"In Progress"}),e.jsx(Ts,{value:"resolved",children:"Resolved"}),e.jsx(Ts,{value:"closed",children:"Closed"})]})}),e.jsxs(tr,{value:d,onValueChange:u,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"All Categories"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Categories"}),e.jsx(At,{value:"general",children:"General Support"}),e.jsx(At,{value:"technology",children:"Technology Support"}),e.jsx(At,{value:"crm",children:"CRM Support"}),e.jsx(At,{value:"marketing",children:"Marketing Support"})]})]})]}),e.jsx("div",{className:"mt-4",children:_?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):v.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(mc,{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:v.map(q=>{var U,Q;const H=U8[q.status].icon;return e.jsx(De,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(q),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:q.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(nt,{variant:"outline",className:"text-xs",children:MTe[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(U=q.profiles)==null?void 0:U.name," • ",js(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(mo,{className:"h-3 w-3"}),((Q=b.find(se=>se.id===q.assigned_to))==null?void 0:Q.name)||"Assigned"]})]})]}),e.jsxs(nt,{className:U8[q.status].color,children:[e.jsx(H,{className:"h-3 w-3 mr-1"}),U8[q.status].label]})]})})},q.id)})})})]})]})})}const wLt=Lu.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 jLt({content:t,onChange:s,variables:r}){const n=SVe({extensions:[PVe,qVe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),UVe.configure({types:["heading","paragraph"]}),VVe,wLt],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});M.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(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(Z4,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(s5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(Fh,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(b0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(W4,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(H4,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(Po,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(Vk,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(m5,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(u5,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsxs(Z,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(wP,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(mu,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Wa,{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(kVe,{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(nt,{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 kLt(){const t=ds(),[s,r]=M.useState(null),[n,a]=M.useState(null),[o,l]=M.useState(""),[i,d]=M.useState(""),[u,f]=M.useState(""),[g,v]=M.useState(!0),[_,b]=M.useState("visual"),{data:w,isLoading:j}=Tt({queryKey:["email-templates"],queryFn:async()=>{const{data:L,error:F}=await K.from("email_templates").select("*").order("name");if(F)throw F;return L.map($=>({...$,available_variables:$.available_variables||[]}))}}),N=Bt({mutationFn:async L=>{const{error:F}=await K.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(F)throw F},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),ge.success("Email template updated successfully"),r(null)},onError:L=>{ge.error("Failed to update template: "+L.message)}}),S=L=>{r(L),l(L.subject),d(L.body_html),f(L.description||""),v(L.is_active),b("visual")},A=()=>{s&&N.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:g})},I=(L,F)=>{let $=L;return F.forEach(q=>{const H=`{{${q.key}}}`,U=`[${q.label}]`;$=$.replace(new RegExp(H.replace(/[{}]/g,"\\$&"),"g"),U)}),$};return s?e.jsxs(Ms,{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(Z,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(Z,{variant:"outline",onClick:()=>a(s),children:[e.jsx(Na,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(Z,{onClick:A,disabled:N.isPending,children:[e.jsx(zh,{className:"h-4 w-4 mr-2"}),N.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Ar,{className:"h-5 w-5"}),s.name]}),e.jsxs(_r,{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(_e,{htmlFor:"active-toggle",children:"Active"}),e.jsx(qr,{id:"active-toggle",checked:g,onCheckedChange:v})]})]})}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",value:u,onChange:L=>f(L.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"subject",children:"Email Subject"}),e.jsx(Re,{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(_e,{children:"Email Body"}),e.jsx(Ia,{value:_,onValueChange:L=>b(L),children:e.jsxs(Aa,{className:"h-8",children:[e.jsxs(Ts,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(Xk,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(Ts,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(Vk,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(jLt,{content:i,onChange:d,variables:s.available_variables}):e.jsx(Lr,{value:i,onChange:L=>d(L.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(bs,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Email Preview"}),e.jsxs(Kr,{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(Ms,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),j?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,F)=>e.jsx(De,{children:e.jsxs($t,{children:[e.jsx(gs,{className:"h-5 w-48"}),e.jsx(gs,{className:"h-4 w-96"})]})},F))}):e.jsx("div",{className:"grid gap-4",children:w==null?void 0:w.map(L=>e.jsxs(De,{className:"hover:shadow-md transition-shadow",children:[e.jsx($t,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Vt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Ar,{className:"h-5 w-5 text-muted-foreground"}),L.name,!L.is_active&&e.jsx(nt,{variant:"secondary",children:"Inactive"})]}),e.jsx(_r,{children:L.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>a(L),children:[e.jsx(Na,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(Z,{size:"sm",onClick:()=>S(L),children:[e.jsx(Pc,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subject:"}),e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-sm",children: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(F=>e.jsx(nt,{variant:"outline",className:"font-mono text-xs",children:`{{${F.key}}}`},F.key))})]})]})})]},L.id))}),e.jsx(bs,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(Kr,{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 NLt(){const t=ds(),[s,r]=M.useState("templates"),[n,a]=M.useState(null),[o,l]=M.useState(null),[i,d]=M.useState(!1),[u,f]=M.useState(!1),[g,v]=M.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=M.useState({name:"",description:"",icon:"📧"}),{data:w=[]}=Tt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:U,error:Q}=await K.from("email_template_categories").select("*").order("sort_order");if(Q)throw Q;return U}}),{data:j=[],isLoading:N}=Tt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:U,error:Q}=await K.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(Q)throw Q;return U}}),S=Bt({mutationFn:async U=>{const Q={title:U.title,subject:U.subject,body:U.body,description:U.description||null,tone:U.tone||null,category_id:U.category_id||null,is_active:U.is_active};if(U.id){const{error:se}=await K.from("agent_email_templates").update(Q).eq("id",U.id);if(se)throw se}else{const{error:se}=await K.from("agent_email_templates").insert(Q);if(se)throw se}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),d(!1),ge.success(n?"Template updated":"Template created")},onError:()=>ge.error("Failed to save template")}),A=Bt({mutationFn:async U=>{const{error:Q}=await K.from("agent_email_templates").delete().eq("id",U);if(Q)throw Q},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),ge.success("Template deleted")}}),I=Bt({mutationFn:async U=>{const Q={name:U.name,description:U.description||null,icon:U.icon};if(U.id){const{error:se}=await K.from("email_template_categories").update(Q).eq("id",U.id);if(se)throw se}else{const se=w.length>0?Math.max(...w.map(Y=>Y.sort_order))+1:0,{error:te}=await K.from("email_template_categories").insert({...Q,sort_order:se});if(te)throw te}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),f(!1),ge.success(o?"Category updated":"Category created")},onError:()=>ge.error("Failed to save category")}),L=Bt({mutationFn:async U=>{const{error:Q}=await K.from("email_template_categories").delete().eq("id",U);if(Q)throw Q},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),ge.success("Category deleted")}}),F=()=>{a(null),v({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),d(!0)},$=U=>{a(U),v({title:U.title,subject:U.subject,body:U.body,description:U.description||"",tone:U.tone||"",category_id:U.category_id||"",is_active:U.is_active}),d(!0)},q=()=>{l(null),b({name:"",description:"",icon:"📧"}),f(!0)},H=U=>{l(U),b({name:U.name,description:U.description||"",icon:U.icon}),f(!0)};return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(pu,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(Ia,{value:s,onValueChange:r,children:[e.jsxs(Aa,{children:[e.jsxs(Ts,{value:"templates",className:"gap-2",children:[e.jsx(Ar,{className:"h-4 w-4"})," Templates"]}),e.jsxs(Ts,{value:"categories",className:"gap-2",children:[e.jsx(Oh,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(Vs,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(Z,{onClick:F,className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:N?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin mx-auto"})})}):j.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):j.map(U=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:U.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:U.subject})]})}),e.jsx(lt,{className:"hidden md:table-cell",children:U.category?e.jsxs(nt,{variant:"outline",className:"gap-1",children:[U.category.icon," ",U.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{className:"hidden md:table-cell",children:U.tone?e.jsx(nt,{variant:"secondary",children:U.tone}):"—"}),e.jsx(lt,{children:e.jsx(nt,{variant:U.is_active?"default":"secondary",children:U.is_active?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>$(U),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&A.mutate(U.id)},children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},U.id))})]})})})]}),e.jsxs(Vs,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(Z,{onClick:q,className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w.map(U=>e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:U.icon})," ",U.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>H(U),children:e.jsx(Ga,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&L.mutate(U.id)},children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:U.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[j.filter(Q=>Q.category_id===U.id).length," templates"]})]})]},U.id))})]})]}),e.jsx(bs,{open:i,onOpenChange:d,children:e.jsxs(_s,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{children:"Title"}),e.jsx(Re,{value:g.title,onChange:U=>v(Q=>({...Q,title:U.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Category"}),e.jsxs(tr,{value:g.category_id,onValueChange:U=>v(Q=>({...Q,category_id:U})),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(er,{children:w.map(U=>e.jsxs(At,{value:U.id,children:[U.icon," ",U.name]},U.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Subject Line"}),e.jsx(Re,{value:g.subject,onChange:U=>v(Q=>({...Q,subject:U.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(_e,{children:"Email Body"}),e.jsx(Lr,{value:g.body,onChange:U=>v(Q=>({...Q,body:U.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(_e,{children:"Description (internal)"}),e.jsx(Re,{value:g.description,onChange:U=>v(Q=>({...Q,description:U.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Tone"}),e.jsx(Re,{value:g.tone,onChange:U=>v(Q=>({...Q,tone:U.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:g.is_active,onCheckedChange:U=>v(Q=>({...Q,is_active:U}))}),e.jsx(_e,{children:"Active"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(Z,{onClick:()=>S.mutate({...g,id:n==null?void 0:n.id}),disabled:S.isPending||!g.title||!g.subject||!g.body,children:[S.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(bs,{open:u,onOpenChange:f,children:e.jsxs(_s,{className:"sm:max-w-[450px]",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{children:"Icon"}),e.jsx(Re,{value:_.icon,onChange:U=>b(Q=>({...Q,icon:U.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Name"}),e.jsx(Re,{value:_.name,onChange:U=>b(Q=>({...Q,name:U.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Description"}),e.jsx(Re,{value:_.description,onChange:U=>b(Q=>({...Q,description:U.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsxs(Z,{onClick:()=>I.mutate({..._,id:o==null?void 0:o.id}),disabled:I.isPending||!_.name,children:[I.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const SLt=({brokerageId:t})=>{var Lo,Kc;const{toast:s}=La(),[r,n]=M.useState([]),[a,o]=M.useState(!0),[l,i]=M.useState(""),[d,u]=M.useState("all"),[f,g]=M.useState(new Set),[v,_]=M.useState(!1),[b,w]=M.useState({}),[j,N]=M.useState(!1),[S,A]=M.useState(!1),[I,L]=M.useState({email:"",name:"",password:"",phone:""}),[F,$]=M.useState(!1),[q,H]=M.useState(null),[U,Q]=M.useState(!1),[se,te]=M.useState(!1),[Y,ce]=M.useState(!1),[oe,le]=M.useState(""),[de,xe]=M.useState(!1),[be,ye]=M.useState([]),[ve,ke]=M.useState(!1),[Ge,Ne]=M.useState(!1),[Ae,Pe]=M.useState(null),[Fe,Ie]=M.useState({name:"",phone:"",email:""}),[Ve,dt]=M.useState(!1),[Le,Rt]=M.useState(!1),[fe,Qe]=M.useState(null),[at,rt]=M.useState("asc"),[je,mt]=M.useState(!1),[He,ct]=M.useState(null),[We,Ze]=M.useState(!1),[ht,Ke]=M.useState(null),[qe,Je]=M.useState(""),[Lt,zt]=M.useState(!1),[is,Kt]=M.useState(null);M.useEffect(()=>{fs(),Qt()},[t]);const Qt=async()=>{try{const{data:it,error:Se}=await K.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Se)throw Se;ye((it==null?void 0:it.map(ze=>ze.user_id))||[])}catch(it){console.error("Error loading brokerage managers:",it)}},fs=async()=>{try{o(!0);const{data:it,error:Se}=await K.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Se)throw Se;const ze=it.agents||[];if(n(ze),ze.length>0){const tt=ze.map(Nt=>Nt.id),{data:Mt}=await K.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",tt);if(Mt&&Mt.length>0){const Nt=Mt.map(qt=>qt.assistant_id),{data:Ot}=await K.from("profiles").select("id, name, email").in("id",Nt),Yt={};for(const qt of Mt){const Jt=Ot==null?void 0:Ot.find(Ps=>Ps.id===qt.assistant_id);Jt&&(Yt[qt.agent_id]={name:Jt.name||"",email:Jt.email||""})}w(Yt)}else w({})}}catch(it){console.error("Error loading agents:",it),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{o(!1)}},dr=async()=>{if(!I.email||!I.name||!I.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}A(!0);try{const{data:{session:it}}=await K.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it==null?void 0:it.access_token}`},body:JSON.stringify({...I,brokerageId:t})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to create agent");s({title:"Success",description:`Agent ${I.email} created successfully`}),L({email:"",name:"",password:"",phone:""}),N(!1),fs()}catch(it){console.error("Error creating agent:",it),s({title:"Error",description:it.message||"Failed to create agent",variant:"destructive"})}finally{A(!1)}},bt=async it=>{try{const{data:{session:Se}}=await K.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:it})}),tt=await ze.json();if(!ze.ok)throw new Error(tt.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(Se){console.error("Error resending welcome email:",Se),s({title:"Error",description:Se.message||"Failed to resend welcome email",variant:"destructive"})}},ws=async(it,Se)=>{try{const{error:ze}=await K.functions.invoke("send-password-reset",{body:{email:it,redirectTo:window.location.origin}});if(ze)throw ze;s({title:"Password Reset Sent",description:`Password reset email sent to ${Se}`})}catch(ze){console.error("Error sending password reset:",ze),s({title:"Error",description:ze.message||"Failed to send password reset email",variant:"destructive"})}},ir=it=>{H(it),$(!0)},Rr=it=>{Pe(it),Ie({name:it.name,phone:it.phone||"",email:it.email}),Ne(!0)},oa=async()=>{if(!Ae)return;if(!Fe.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const it=Fe.email.trim().toLowerCase()!==Ae.email.toLowerCase();dt(!0);try{if(it){if(!Fe.email.trim())throw new Error("Email is required");Rt(!0);const{data:{session:ze}}=await K.auth.getSession(),tt=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze==null?void 0:ze.access_token}`},body:JSON.stringify({agentId:Ae.id,newEmail:Fe.email.trim(),brokerageId:t})}),Mt=await tt.json();if(Rt(!1),!tt.ok)throw new Error(Mt.error||"Failed to update email")}const{error:Se}=await K.from("profiles").update({name:Fe.name.trim(),phone:Fe.phone.trim()||null}).eq("id",Ae.id);if(Se)throw Se;s({title:"Success",description:"Agent profile updated successfully"}),Ne(!1),Pe(null),fs()}catch(Se){console.error("Error updating agent:",Se),s({title:"Error",description:Se.message||"Failed to update agent",variant:"destructive"})}finally{dt(!1),Rt(!1)}},ri=async()=>{if(!oe){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}xe(!0);try{const{data:{session:it}}=await K.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it==null?void 0:it.access_token}`},body:JSON.stringify({userId:oe,role:"brokerage_manager",action:"add",brokerageId:t})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),ce(!1),le(""),Qt()}catch(it){console.error("Error adding brokerage manager:",it),s({title:"Error",description:it.message||"Failed to add brokerage manager",variant:"destructive"})}finally{xe(!1)}},no=async it=>{try{const{data:{session:Se}}=await K.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:it,role:"brokerage_manager",action:"remove",brokerageId:t})}),tt=await ze.json();if(!ze.ok)throw new Error(tt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),Qt()}catch(Se){console.error("Error removing brokerage manager:",Se),s({title:"Error",description:Se.message||"Failed to remove brokerage manager",variant:"destructive"})}},Da=it=>be.includes(it),yn=it=>{Ke(it),Je(""),Ze(!0)},ea=async()=>{if(!(!ht||!qe)){if(qe.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}zt(!0);try{const{data:{session:it}}=await K.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it==null?void 0:it.access_token}`},body:JSON.stringify({agentId:ht.id,brokerageId:t,action:"set_password",newPassword:qe})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to set password");s({title:"Success",description:`Password set for ${ht.name}`}),Ze(!1),Ke(null),Je("")}catch(it){console.error("Error setting password:",it),s({title:"Error",description:it.message||"Failed to set password",variant:"destructive"})}finally{zt(!1)}}},Zt=async it=>{Kt(it.id);try{const{data:{session:Se}}=await K.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({agentId:it.id,brokerageId:t,action:"claim_account"})}),tt=await ze.json();if(!ze.ok)throw new Error(tt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${it.name}`}),fs()}catch(Se){console.error("Error claiming account:",Se),s({title:"Error",description:Se.message||"Failed to claim account",variant:"destructive"})}finally{Kt(null)}},yr=async()=>{if(q){Q(!0);try{const{data:{session:it}}=await K.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it==null?void 0:it.access_token}`},body:JSON.stringify({userId:q.id,brokerageId:t})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to remove agent");s({title:"Success",description:`${q.name} has been removed from your brokerage`}),$(!1),H(null),fs()}catch(it){console.error("Error removing agent:",it),s({title:"Error",description:it.message||"Failed to remove agent",variant:"destructive"})}finally{Q(!1)}}},Gr=it=>{const Se=it.trim().split(" ");return Se.length>1?Se[Se.length-1].toLowerCase():it.toLowerCase()},Dn=it=>{fe===it?rt(at==="asc"?"desc":"asc"):(Qe(it),rt("asc"))},rs=it=>fe!==it?e.jsx($c,{className:"ml-1 h-4 w-4"}):at==="asc"?e.jsx(Rd,{className:"ml-1 h-4 w-4"}):e.jsx(Ku,{className:"ml-1 h-4 w-4"}),An=r.filter(it=>{if(d==="active"&&!it.claimed||d==="pending"&&it.claimed)return!1;if(!l)return!0;const Se=l.toLowerCase();return it.name.toLowerCase().includes(Se)||it.email.toLowerCase().includes(Se)}),la=[...An].sort((it,Se)=>{if(!fe)return 0;let ze=0;return fe==="name"?ze=Gr(it.name).localeCompare(Gr(Se.name)):fe==="status"&&(ze=it.claimed===Se.claimed?0:it.claimed?-1:1),at==="asc"?ze:-ze});An.filter(it=>it.claimed&&!Da(it.id));const qa=it=>{g(Se=>{const ze=new Set(Se);return ze.has(it)?ze.delete(it):ze.add(it),ze})},Jr=()=>{f.size===la.length?g(new Set):g(new Set(la.map(it=>it.id)))},Ka=()=>{g(new Set)},Dl=async()=>{const it=Array.from(f);if(it.length===0)return;_(!0);let Se=0,ze=0;try{const{data:{session:tt}}=await K.auth.getSession();for(const Mt of it)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${tt==null?void 0:tt.access_token}`},body:JSON.stringify({userId:Mt})})).ok?Se++:ze++}catch{ze++}Se>0?s({title:"Success",description:`Welcome emails sent to ${Se} agent${Se>1?"s":""}${ze>0?` (${ze} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),Ka()}catch(tt){console.error("Error bulk sending welcome emails:",tt),s({title:"Error",description:tt.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return a?e.jsx(De,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Agents"}),e.jsx(_r,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Z,{variant:"outline",onClick:()=>ce(!0),children:[e.jsx(Xu,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(Z,{variant:"outline",onClick:()=>te(!0),children:[e.jsx(x0,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(Z,{onClick:()=>N(!0),children:[e.jsx(pc,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:l,onChange:it=>i(it.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:d,onValueChange:it=>u(it),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Agents"}),e.jsx(At,{value:"active",children:"Active"}),e.jsx(At,{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(Z,{size:"sm",variant:"outline",onClick:Dl,disabled:v,children:[e.jsx(Ar,{className:"mr-2 h-4 w-4"}),v?"Sending...":"Resend Welcome Email"]}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:Ka,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx($o,{checked:la.length>0&&f.size===la.length,onCheckedChange:Jr,"aria-label":"Select all"})}),e.jsx(kt,{children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>Dn("name"),children:["Name (Last)",rs("name")]})}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>Dn("status"),children:["Status",rs("status")]})}),e.jsx(kt,{children:"Actions"})]})}),e.jsx(Ln,{children:la.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):la.map(it=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsx($o,{checked:f.has(it.id),onCheckedChange:()=>qa(it.id),"aria-label":`Select ${it.name}`})}),e.jsx(lt,{className:"font-medium",children:it.name}),e.jsx(lt,{children:it.email}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[it.claimed?e.jsx(nt,{variant:"default",children:"Active"}):e.jsx(nt,{variant:"secondary",children:"Pending"}),Da(it.id)&&e.jsxs(nt,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(pP,{className:"mr-1 h-3 w-3"}),"Manager"]}),b[it.id]&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:[e.jsx(xr,{className:"mr-1 h-3 w-3"}),"Asst: ",b[it.id].name||b[it.id].email]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>{ct(it),mt(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(bd,{className:"h-4 w-4"})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>Rr(it),title:"Edit agent",children:e.jsx(Ga,{className:"h-4 w-4"})}),!it.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>bt(it.id),title:"Resend welcome email",children:e.jsx(Ar,{className:"h-4 w-4"})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>Zt(it),title:"Claim account for agent",disabled:is===it.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(J1,{className:"h-4 w-4"})})]}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>yn(it),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(Pu,{className:"h-4 w-4"})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>ws(it.email,it.name),title:"Send password reset email",children:e.jsx(Kk,{className:"h-4 w-4"})}),Da(it.id)&&e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>no(it.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(Xu,{className:"h-4 w-4"})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>ir(it),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},it.id))})]})})]})]}),e.jsx(bs,{open:j,onOpenChange:N,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Add New Agent"}),e.jsx(Kr,{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(_e,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:I.name,onChange:it=>L({...I,name:it.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:I.email,onChange:it=>L({...I,email:it.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Re,{id:"phone",type:"tel",value:I.phone,onChange:it=>L({...I,phone:it.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"password",children:"Temporary Password"}),e.jsx(Re,{id:"password",type:"password",value:I.password,onChange:it=>L({...I,password:it.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(Z,{onClick:dr,disabled:S,children:S?"Creating...":"Create Agent"})]})]})}),e.jsx(bs,{open:F,onOpenChange:$,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Remove Agent"}),e.jsxs(Kr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:q==null?void 0:q.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(Z,{variant:"destructive",onClick:yr,disabled:U,children:U?"Removing...":"Remove Agent"})]})]})}),e.jsx(dWe,{open:se,onOpenChange:te,fixedBrokerageId:t,onSuccess:fs}),e.jsx(bs,{open:Y,onOpenChange:ce,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Add Brokerage Manager"}),e.jsx(Kr,{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(_e,{children:"Select Agent"}),e.jsxs(No,{open:ve,onOpenChange:ke,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",role:"combobox","aria-expanded":ve,className:"w-full justify-between",children:[oe?((Lo=r.find(it=>it.id===oe))==null?void 0:Lo.name)+" ("+((Kc=r.find(it=>it.id===oe))==null?void 0:Kc.email)+")":"Select an agent to promote...",e.jsx(of,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-full p-0",align:"start",children:e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search by name or email..."}),e.jsxs(yf,{className:"max-h-[200px]",children:[e.jsx(vf,{children:"No eligible agents found."}),e.jsx(_f,{children:r.filter(it=>!Da(it.id)).map(it=>e.jsxs(_m,{value:`${it.name} ${it.email}`,onSelect:()=>{le(it.id),ke(!1)},children:[e.jsx(ma,{className:`mr-2 h-4 w-4 ${oe===it.id?"opacity-100":"opacity-0"}`}),it.name," (",it.email,")"]},it.id))})]})]})})]}),r.filter(it=>!Da(it.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>ce(!1),children:"Cancel"}),e.jsx(Z,{onClick:ri,disabled:de||!oe,children:de?"Adding...":"Add as Manager"})]})]})}),e.jsx(bs,{open:Ge,onOpenChange:Ne,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Agent"}),e.jsxs(Kr,{children:["Update profile information for ",Ae==null?void 0:Ae.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"edit-name",children:"Name"}),e.jsx(Re,{id:"edit-name",value:Fe.name,onChange:it=>Ie({...Fe,name:it.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"edit-email",children:"Email"}),e.jsx(Re,{id:"edit-email",type:"email",value:Fe.email,onChange:it=>Ie({...Fe,email:it.target.value}),placeholder:"agent@example.com"}),Fe.email.trim().toLowerCase()!==(Ae==null?void 0:Ae.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(_e,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Re,{id:"edit-phone",type:"tel",value:Fe.phone,onChange:it=>Ie({...Fe,phone:it.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>Ne(!1),children:"Cancel"}),e.jsx(Z,{onClick:oa,disabled:Ve||Le,children:Le?"Updating email...":Ve?"Saving...":"Save Changes"})]})]})}),He&&e.jsx(uWe,{open:je,onOpenChange:it=>{mt(it),it||ct(null)},userId:He.id,userName:He.name}),e.jsx(bs,{open:We,onOpenChange:Ze,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Set Password"}),e.jsxs(Kr,{children:["Set a new password for ",ht==null?void 0:ht.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(_e,{htmlFor:"new-password",children:"New Password"}),e.jsx(Re,{id:"new-password",type:"password",value:qe,onChange:it=>Je(it.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(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>Ze(!1),children:"Cancel"}),e.jsx(Z,{onClick:ea,disabled:Lt||!qe||qe.length<6,children:Lt?"Setting...":"Set Password"})]})]})})]})},CLt={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},MLt={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},TLt=t=>{switch(t){case"academy_video":return e.jsx(Cn,{className:"h-4 w-4"});case"template":return e.jsx(Un,{className:"h-4 w-4"});case"toolbox":return e.jsx(Un,{className:"h-4 w-4"});case"newsletter":return e.jsx(j0,{className:"h-4 w-4"});case"social_swag":return e.jsx(gn,{className:"h-4 w-4"});case"event":return e.jsx(nn,{className:"h-4 w-4"});default:return e.jsx(un,{className:"h-4 w-4"})}},ALt=({brokerageId:t})=>{const{toast:s}=La(),[r,n]=M.useState([]),[a,o]=M.useState([]),[l,i]=M.useState([]),[d,u]=M.useState(!0),[f,g]=M.useState(null);M.useEffect(()=>{v()},[t]);const v=async()=>{try{u(!0);const{data:w,error:j}=await K.from("profiles").select("id, name, email").eq("brokerage_id",t);if(j)throw j;const N=w.map(Q=>Q.id),S=new Map(w.map(Q=>[Q.id,Q]));if(N.length===0){n([]),o([]),i([]);return}const{data:A,error:I}=await K.from("activity_logs").select("*").in("user_id",N).order("launched_at",{ascending:!1});if(I)throw I;const L=A.map(Q=>{var se,te;return{id:Q.id,user_id:Q.user_id,app_name:Q.app_name,launched_at:Q.launched_at,user_name:((se=S.get(Q.user_id))==null?void 0:se.name)||"Unknown",user_email:((te=S.get(Q.user_id))==null?void 0:te.email)||"Unknown"}});n(L);const{data:F,error:$}=await K.from("content_engagement_logs").select("*").in("user_id",N).order("created_at",{ascending:!1});if($)throw $;const q=(F||[]).map(Q=>{var se,te;return{id:Q.id,user_id:Q.user_id,resource_type:Q.resource_type,resource_id:Q.resource_id,resource_title:Q.resource_title,action_type:Q.action_type,created_at:Q.created_at,user_name:((se=S.get(Q.user_id))==null?void 0:se.name)||"Unknown",user_email:((te=S.get(Q.user_id))==null?void 0:te.email)||"Unknown"}});o(q);const H=new Map;w.forEach(Q=>{H.set(Q.id,{user_id:Q.id,user_name:Q.name,user_email:Q.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(Q=>{const se=H.get(Q.user_id);se&&(se.app_launches++,(!se.last_activity||new Date(Q.launched_at)>new Date(se.last_activity))&&(se.last_activity=Q.launched_at))}),q.forEach(Q=>{const se=H.get(Q.user_id);se&&(se.content_views++,(!se.last_activity||new Date(Q.created_at)>new Date(se.last_activity))&&(se.last_activity=Q.created_at))});const U=Array.from(H.values()).filter(Q=>Q.app_launches>0||Q.content_views>0).sort((Q,se)=>new Date(se.last_activity).getTime()-new Date(Q.last_activity).getTime());i(U)}catch(w){console.error("Error loading activity:",w),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},_=w=>r.filter(j=>j.user_id===w),b=w=>a.filter(j=>j.user_id===w);return d?e.jsx(De,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Agent Activity"}),e.jsx(_r,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:l.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(w=>e.jsxs(ks,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>g({id:w.user_id,name:w.user_name,email:w.user_email}),children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:w.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:w.user_email})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(dl,{className:"h-3 w-3"}),w.app_launches]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),w.content_views]})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:w.last_activity&&$d(new Date(w.last_activity),{addSuffix:!0})})]},w.user_id))})]})})})]}),e.jsx(bs,{open:!!f,onOpenChange:w=>!w&&g(null),children:e.jsxs(_s,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Kr,{children:f==null?void 0:f.email})]}),e.jsxs(Ia,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-2",children:[e.jsx(Ts,{value:"content",children:"Content Engagement"}),e.jsx(Ts,{value:"apps",children:"App Launches"})]}),e.jsx(Vs,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"Resource"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Action"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(Ln,{children:f&&b(f.id).length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):f&&b(f.id).map(w=>e.jsxs(ks,{children:[e.jsx(lt,{className:"max-w-[200px] truncate font-medium",children:w.resource_title}),e.jsx(lt,{children:e.jsxs(nt,{variant:"outline",className:"gap-1",children:[TLt(w.resource_type),CLt[w.resource_type]||w.resource_type]})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:MLt[w.action_type]||w.action_type})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:$d(new Date(w.created_at),{addSuffix:!0})})]},w.id))})]})})}),e.jsx(Vs,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"App"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(Ln,{children:f&&_(f.id).length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):f&&_(f.id).map(w=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsx(nt,{variant:"outline",children:w.app_name})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:$d(new Date(w.launched_at),{addSuffix:!0})})]},w.id))})]})})})]})]})})]})},ELt=({brokerageId:t})=>{const{toast:s}=La(),[r,n]=M.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=M.useState(!0);M.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:d}=await K.from("profiles").select("id").eq("brokerage_id",t);if(d)throw d;const u=i.map(L=>L.id),f=u.length;if(u.length===0){o(!1);return}const{data:g,error:v}=await K.from("profiles").select("id, email").in("id",u);if(v)throw v;const{count:_}=await K.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),b=_||0,w=f-b,{count:j}=await K.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),N=new Date;N.setDate(N.getDate()-7);const{count:S}=await K.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",N.toISOString()),A=new Date;A.setMonth(A.getMonth()-1);const{count:I}=await K.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",A.toISOString());n({totalAgents:f,activeAgents:b,pendingAgents:w,totalLaunches:j||0,launchesThisWeek:S||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(De,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalAgents}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.activeAgents," active, ",r.pendingAgents," pending"]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(hi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.activeAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.totalAgents>0?`${Math.round(r.activeAgents/r.totalAgents*100)}% of total`:"0% of total"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.pendingAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Fx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(Fx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(Fx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]})]})},PLt=({brokerageId:t})=>{const[s,r]=M.useState([]),[n,a]=M.useState(!0),[o,l]=M.useState(!1),[i,d]=M.useState(!1),[u,f]=M.useState({description:"",maxUses:""});M.useEffect(()=>{g()},[t]);const g=async()=>{try{const{data:N,error:S}=await K.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;r(N||[])}catch(N){console.error("Error loading invite codes:",N),ge.error("Failed to load invite links")}finally{a(!1)}},v=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const N=v(),{error:S}=await K.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(S)throw S;ge.success("Invite link created!"),d(!1),f({description:"",maxUses:""}),g()}catch(N){console.error("Error creating invite code:",N),ge.error("Failed to create invite link")}finally{l(!1)}},b=async N=>{try{const{error:S}=await K.from("invite_codes").delete().eq("id",N);if(S)throw S;ge.success("Invite link deleted"),r(s.filter(A=>A.id!==N))}catch(S){console.error("Error deleting invite code:",S),ge.error("Failed to delete invite link")}},w=async(N,S)=>{try{const{error:A}=await K.from("invite_codes").update({is_active:!S}).eq("id",N);if(A)throw A;r(s.map(I=>I.id===N?{...I,is_active:!S}:I)),ge.success(`Invite link ${S?"deactivated":"activated"}`)}catch(A){console.error("Error toggling invite code:",A),ge.error("Failed to update invite link")}},j=N=>{const S=`${window.location.origin}/join?code=${N}`;navigator.clipboard.writeText(S),ge.success("Link copied to clipboard!")};return n?e.jsx(De,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Po,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(_r,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(bs,{open:i,onOpenChange:d,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{size:"sm",children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create Invite Link"}),e.jsx(Kr,{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(_e,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Re,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:N=>f({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(Re,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:N=>f({...u,maxUses:N.target.value})})]}),e.jsx(Z,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Oe,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Po,{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(nt,{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(Z,{variant:"ghost",size:"sm",onClick:()=>j(N.code),title:"Copy link",children:e.jsx(Ni,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>w(N.id,N.is_active),title:N.is_active?"Deactivate":"Activate",children:N.is_active?"Disable":"Enable"}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>b(N.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(Cr,{className:"h-4 w-4"})})]})]},N.id))})})]})},ILt=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=M.useState(""),[u,f]=M.useState([]),[g,v]=M.useState(""),[_,b]=M.useState(!1),w=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),j=()=>{const I=i.trim().toLowerCase();if(I&&w(I)&&!u.includes(I)){if(u.length>=10){ge.error("Maximum 10 emails per invite");return}f([...u,I]),d("")}else I&&!w(I)?ge.error("Please enter a valid email address"):u.includes(I)&&ge.error("Email already added")},N=I=>{f(u.filter(L=>L!==I))},S=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),j())},A=async()=>{if(u.length===0){ge.error("Please add at least one email address");return}b(!0);try{const{data:I,error:L}=await K.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:g.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(L)throw L;I.successCount===I.totalCount?ge.success(`${I.successCount} invite${I.successCount>1?"s":""} sent successfully!`):ge.warning(`${I.successCount} of ${I.totalCount} invites sent. Some failed.`),f([]),v(""),s(!1),l==null||l()}catch(I){console.error("Error sending invites:",I),ge.error("Failed to send invites. Please try again.")}finally{b(!1)}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[550px]",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Ar,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Kr,{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(uo,{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(_e,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:I=>d(I.target.value),onKeyDown:S,onBlur:j}),e.jsx(Z,{type:"button",variant:"secondary",onClick:j,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(nt,{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(Vr,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Lr,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:g,onChange:I=>v(I.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[g.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(gn,{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(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Z,{onClick:A,disabled:u.length===0||_,children:_?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(Pa,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},LLt=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=M.useState([]),[a,o]=M.useState(!0);M.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:d,error:u}=await K.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(d||[])}catch(d){console.error("Error fetching invites:",d)}finally{o(!1)}},i=d=>{switch(d){case"signed_up":return e.jsxs(nt,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(hi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(nt,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(bc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{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(Ar,{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(d=>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:d.recipient_email}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",js(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},DLt=()=>{const{brokerageId:t,user:s}=Qs(),[r,n]=M.useState(null),[a,o]=M.useState(""),[l,i]=M.useState(""),[d,u]=M.useState([]),[f,g]=M.useState(!0),[v,_]=M.useState(!1),[b,w]=M.useState(0);M.useEffect(()=>{t&&j()},[t]);const j=async()=>{try{const[F,$]=await Promise.all([K.from("brokerages").select("name").eq("id",t).single(),s?K.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);F.data&&o(F.data.name),$.data&&i($.data.name||"A LevelUp Member");const{data:q}=await K.from("referral_codes").select("code").eq("brokerage_id",t).single();if(q)n(q.code);else{const U=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await K.from("referral_codes").insert({brokerage_id:t,code:U}),n(U)}const{data:H}=await K.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(H||[])}catch(F){console.error("Error fetching referral data:",F)}finally{g(!1)}},N=()=>{const F=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(F),ge.success("Referral link copied to clipboard!")},S=d.filter(F=>F.status==="qualified").length,A=d.filter(F=>F.status==="pending").length,I=S*25,L=Math.max(0,Math.ceil((299-I)/25));return f?null:e.jsxs(e.Fragment,{children:[e.jsxs(De,{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(uo,{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(hi,{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(gn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Oe,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(Z,{onClick:()=>_(!0),className:"w-full",size:"lg",children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(Z,{onClick:N,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(Ni,{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(Uc,{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(xr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(Tn,{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:A}),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(LLt,{brokerageId:t,refreshTrigger:b}),d.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),d.slice(0,5).map(F=>{var $,q;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:(($=F.referred_brokerage)==null?void 0:$.name)||((q=F.referred_user)==null?void 0:q.email)||"Pending setup"}),e.jsxs(nt,{variant:F.status==="qualified"?"default":F.status==="pending"?"secondary":"destructive",className:F.status==="qualified"?"bg-green-600":"",children:[F.status==="qualified"&&e.jsx(hi,{className:"h-3 w-3 mr-1"}),F.status]})]},F.id)})]})]})]}),e.jsx(ILt,{open:v,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>w(F=>F+1)})]})},OLt=({brokerageId:t})=>{const s=Or(),{teams:r,isLoading:n}=YN(t),{data:a,isLoading:o}=Tt({queryKey:["team-aggregate-stats",t,r.map(f=>f.id)],queryFn:async()=>{if(r.length===0)return[];const f=r.map(F=>F.id),{data:g}=await K.from("team_members").select("team_id, user_id, role").in("team_id",f);if(!g||g.length===0)return r.map(F=>({team_id:F.id,team_name:F.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const v=g.map(F=>F.user_id),_=g.filter(F=>F.role==="team_leader").map(F=>F.user_id),{data:b}=await K.from("profiles").select("id, name, avatar_url").in("id",_),w=new Map((b||[]).map(F=>[F.id,F])),{data:j}=await K.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",v),{data:N}=await K.from("deal_pipeline").select("owner_user_id").in("owner_user_id",v),{data:S}=await K.from("agent_videos").select("owner_user_id").in("owner_user_id",v).eq("is_deleted",!1),A=new Map;(j||[]).forEach(F=>{A.set(F.owner_user_id,(A.get(F.owner_user_id)||0)+1)});const I=new Map;(N||[]).forEach(F=>{I.set(F.owner_user_id,(I.get(F.owner_user_id)||0)+1)});const L=new Map;return(S||[]).forEach(F=>{L.set(F.owner_user_id,(L.get(F.owner_user_id)||0)+1)}),r.map(F=>{const $=g.filter(Y=>Y.team_id===F.id),q=$.find(Y=>Y.role==="team_leader"),H=q?w.get(q.user_id):null,U=$.map(Y=>Y.user_id),Q=U.reduce((Y,ce)=>Y+(A.get(ce)||0),0),se=U.reduce((Y,ce)=>Y+(I.get(ce)||0),0),te=U.reduce((Y,ce)=>Y+(L.get(ce)||0),0);return{team_id:F.id,team_name:F.name,member_count:$.length,leader_name:(H==null?void 0:H.name)||null,leader_avatar:(H==null?void 0:H.avatar_url)||null,total_contacts:Q,total_deals:se,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(f=>e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(gs,{className:"h-5 w-32"})}),e.jsx(Oe,{children:e.jsx(gs,{className:"h-24 w-full"})})]},f))});if(r.length===0)return e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(xr,{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(Z,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((f,g)=>f+g.member_count,0),d=(a||[]).reduce((f,g)=>f+g.total_contacts,0),u=(a||[]).reduce((f,g)=>f+g.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(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(xr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(xr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Wk,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:d.toLocaleString()})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Zu,{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(f=>e.jsxs(De,{className:"hover:shadow-md transition-shadow",children:[e.jsxs($t,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Vt,{className:"text-lg",children:f.team_name}),e.jsxs(nt,{variant:"secondary",children:[f.member_count," members"]})]}),f.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(mn,{className:"h-6 w-6",children:[e.jsx(ba,{src:f.leader_avatar||""}),e.jsx(pn,{className:"text-xs",children:f.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Dh,{className:"h-3 w-3 text-amber-500"}),f.leader_name]})]})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:f.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:f.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:f.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},f.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Z,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},RLt=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Qs(),i=Or(),{toast:d}=La(),[u,f]=M.useState(""),[g,v]=M.useState(!0),_=o||(a.length>0?a[0].id:r);M.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?b():a.length===0&&!r&&v(!1)},[t,s,n,_,i,a,o]);const b=async()=>{if(!_){v(!1);return}try{const{data:w,error:j}=await K.from("brokerages").select("name").eq("id",_).single();if(j)throw j;f(w.name)}catch(w){console.error("Error loading brokerage info:",w),d({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{v(!1)}};return g?e.jsx(Ms,{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"})})}):_?e.jsx(Ms,{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(tr,{value:o||"",onValueChange:l,children:[e.jsxs(Js,{className:"w-[280px]",children:[e.jsx(_a,{className:"mr-2 h-4 w-4"}),e.jsx(rr,{placeholder:"Select brokerage"})]}),e.jsx(er,{children:a.map(w=>e.jsx(At,{value:w.id,children:w.name},w.id))})]})]}),e.jsxs(Ia,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(Ts,{value:"agents",children:"Agents"}),e.jsx(Ts,{value:"teams",children:"Teams"}),e.jsx(Ts,{value:"invite",children:"Invite Links"}),e.jsx(Ts,{value:"referrals",children:"Referrals"}),e.jsx(Ts,{value:"leaderboard",children:"Leaderboard"}),e.jsx(Ts,{value:"activity",children:"Activity"}),e.jsx(Ts,{value:"analytics",children:"Analytics"}),e.jsx(Ts,{value:"shares",children:"Shares"})]}),e.jsx(Vs,{value:"agents",className:"space-y-4",children:e.jsx(SLt,{brokerageId:_})}),e.jsx(Vs,{value:"teams",className:"space-y-4",children:e.jsx(OLt,{brokerageId:_})}),e.jsx(Vs,{value:"invite",className:"space-y-4",children:e.jsx(PLt,{brokerageId:_})}),e.jsx(Vs,{value:"referrals",className:"space-y-4",children:e.jsx(DLt,{})}),e.jsx(Vs,{value:"leaderboard",className:"space-y-4",children:e.jsx(THe,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(Vs,{value:"activity",className:"space-y-4",children:e.jsx(ALt,{brokerageId:_})}),e.jsx(Vs,{value:"analytics",className:"space-y-4",children:e.jsx(ELt,{brokerageId:_})}),e.jsx(Vs,{value:"shares",className:"space-y-4",children:e.jsx(HWe,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Ms,{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(_a,{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 FLt({brokerageId:t,canManage:s}){const{user:r}=Qs(),[n,a]=M.useState([]),[o,l]=M.useState(!0),[i,d]=M.useState(!1),[u,f]=M.useState(null),[g,v]=M.useState(null),[_,b]=M.useState(!1),[w,j]=M.useState(""),[N,S]=M.useState(""),[A,I]=M.useState(!1),L=async()=>{try{const{data:U,error:Q}=await K.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(Q)throw Q;const se=U;if(se&&se.length>0){const te=[...new Set(se.map(le=>le.created_by))],{data:Y}=await K.from("profiles").select("id, name, avatar_url").in("id",te),ce=new Map((Y==null?void 0:Y.map(le=>[le.id,le]))||[]),oe=se.map(le=>({...le,author:ce.get(le.created_by)||{name:"Unknown",avatar_url:null}}));a(oe)}else a([])}catch(U){console.error("Error fetching announcements:",U)}finally{l(!1)}};M.useEffect(()=>{L()},[t]);const F=()=>{j(""),S(""),I(!1),f(null)},$=U=>{U?(f(U),j(U.title),S(U.content),I(U.is_pinned)):F(),d(!0)},q=async()=>{if(!w.trim()||!N.trim()){ge.error("Please fill in all fields");return}b(!0);try{if(u){const{error:U}=await K.from("brokerage_announcements").update({title:w.trim(),content:N.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null}).eq("id",u.id);if(U)throw U;ge.success("Announcement updated")}else{const{error:U}=await K.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:w.trim(),content:N.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null});if(U)throw U;ge.success("Announcement created")}d(!1),F(),L()}catch(U){console.error("Error saving announcement:",U),ge.error("Failed to save announcement")}finally{b(!1)}},H=async()=>{if(g)try{const{error:U}=await K.from("brokerage_announcements").delete().eq("id",g);if(U)throw U;ge.success("Announcement deleted"),L()}catch(U){console.error("Error deleting announcement:",U),ge.error("Failed to delete announcement")}finally{v(null)}};return o?e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Ag,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:e.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Ag,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(Z,{size:"sm",onClick:()=>$(),className:"gap-1",children:[e.jsx(Ys,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Oe,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(U=>{var Q,se,te,Y;return e.jsx("div",{className:`p-4 rounded-lg border ${U.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:[U.is_pinned&&e.jsx(Y1,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:U.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:U.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs(mn,{className:"h-5 w-5",children:[e.jsx(ba,{src:((Q=U.author)==null?void 0:Q.avatar_url)||void 0}),e.jsx(pn,{className:"text-[10px]",children:((te=(se=U.author)==null?void 0:se.name)==null?void 0:te.charAt(0))||"?"})]}),e.jsx("span",{children:(Y=U.author)==null?void 0:Y.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:js(new Date(U.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(U),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>v(U.id),children:e.jsx(Cr,{className:"h-4 w-4"})})]})]})},U.id)})})})]}),e.jsx(bs,{open:i,onOpenChange:d,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",value:w,onChange:U=>j(U.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"content",children:"Content"}),e.jsx(Lr,{id:"content",value:N,onChange:U=>S(U.target.value),placeholder:"Write your announcement...",rows:4})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"pinned",checked:A,onCheckedChange:I}),e.jsxs(_e,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(Y1,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(Z,{onClick:q,disabled:_,children:_?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(uc,{open:!!g,onOpenChange:()=>v(null),children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete Announcement"}),e.jsx(Xl,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:H,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function zLt({brokerageId:t}){const[s,r]=M.useState([]),[n,a]=M.useState(!0),[o,l]=M.useState(""),[i,d]=M.useState(new Set);M.useEffect(()=>{(async()=>{try{const{data:g,error:v}=await K.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(v)throw v;if(r(g||[]),g&&g.length>0){const _=g.map(w=>w.id),{data:b}=await K.from("agent_assistant_assignments").select("agent_id").in("agent_id",_);b&&d(new Set(b.map(w=>w.agent_id)))}}catch(g){console.error("Error fetching agents:",g)}finally{a(!1)}})()},[t]);const u=s.filter(f=>{var g,v;return f.name.toLowerCase().includes(o.toLowerCase())||f.email.toLowerCase().includes(o.toLowerCase())||((g=f.title)==null?void 0:g.toLowerCase().includes(o.toLowerCase()))||((v=f.areas_served)==null?void 0:v.toLowerCase().includes(o.toLowerCase()))});return n?e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(f=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},f))})})]}):e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(xr,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:o,onChange:f=>l(f.target.value),className:"pl-9"})]})]}),e.jsx(Oe,{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(f=>e.jsx(BLt,{agent:f,hasAssistant:i.has(f.id)},f.id))})})]})}function BLt({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(mn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(ba,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(pn,{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(nt,{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(Pi,{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(Z,{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(ga,{className:"h-4 w-4"})})}),e.jsx(Z,{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(Ar,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(Z,{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(Cm,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(Z,{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(zd,{className:"h-4 w-4"})})})]})]})}function $Lt({brokerageId:t}){const[s,r]=M.useState([]),[n,a]=M.useState(!0);if(M.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await K.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){r([]),a(!1);return}const f=d.map(w=>w.id),{data:g,error:v}=await K.from("agent_attendance_stats").select("user_id, total_points").in("user_id",f).order("total_points",{ascending:!1});if(v)throw v;const _=new Map(d.map(w=>[w.id,w])),b=(g||[]).filter(w=>w.total_points>0).map(w=>{const j=_.get(w.user_id);return{user_id:w.user_id,total_points:w.total_points,name:(j==null?void 0:j.name)||"Unknown",avatar_url:(j==null?void 0:j.avatar_url)||null}});r(b)}catch(d){console.error("Error fetching leaderboard:",d)}finally{a(!1)}})()},[t]),n)return e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:[1,2,3].map(i=>e.jsx("div",{className:"h-12 bg-muted rounded"},i))})})]});const o=i=>i===1?"text-yellow-500":i===2?"text-gray-400":i===3?"text-amber-600":"text-muted-foreground",l=i=>i<=3?e.jsx(w0,{className:It("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):e.jsx("div",{className:"space-y-2",children:s.slice(0,10).map((i,d)=>{const u=i.name.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2),f=d+1;return e.jsxs("div",{className:It("flex items-center gap-3 p-2 rounded-lg",f<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(f)}),e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:i.avatar_url||void 0}),e.jsx(pn,{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 qLt({brokerageId:t}){const s=Or(),[r,n]=M.useState([]),[a,o]=M.useState(!0);M.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await K.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){n([]),o(!1);return}const f=d.map(w=>w.id),g=new Map(d.map(w=>[w.id,w])),{data:v,error:_}=await K.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",f).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(_)throw _;const b=(v||[]).map(w=>({id:w.id,slug:w.slug,property_address:w.property_address,city:w.city,price:w.price,property_type:w.property_type,agent_id:w.agent_id,agent:g.get(w.agent_id)||null,photos:w.listing_photos||[]}));n(b)}catch(d){console.error("Error fetching listings:",d)}finally{o(!1)}})()},[t]);const l=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i);return a?e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(Oe,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Hn,{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(Z,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx(Ys,{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(Hn,{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(Z,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(un,{className:"h-3 w-3 ml-1"})]})]})]})}function ULt(){const{user:t,isAdmin:s,isBrokerageManager:r}=Qs(),n=Or(),[a,o]=M.useState(!0),[l,i]=M.useState(null),[d,u]=M.useState(""),[f,g]=M.useState(0),[v,_]=M.useState(!1),[b,w]=M.useState(!1);return M.useEffect(()=>{(async()=>{if(t)try{const{data:N}=await K.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:S}=await K.from("brokerages").select("name").eq("id",N.brokerage_id).maybeSingle();S&&u(S.name);const{count:A}=await K.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",N.brokerage_id);if(g(A||0),s)_(!0),w(!0);else if(r){const{data:I}=await K.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",N.brokerage_id).maybeSingle();_(!!I),w(!!I)}}catch(N){console.error("Error fetching brokerage info:",N)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Ms,{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(Ms,{title:d||"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(xr,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[f," ",f===1?"Agent":"Agents"]})]}),b&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Z,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(nu,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(Z,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Hn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(FLt,{brokerageId:l,canManage:v}),e.jsx(zLt,{brokerageId:l}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx($Lt,{brokerageId:l}),e.jsx(qLt,{brokerageId:l})]})]})}):e.jsx(Ms,{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(_a,{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 VLt(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 HLt(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 TTe={video:{icon:dl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:Un,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Al,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:nn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:El,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function WLt({item:t,canManage:s}){const[r,n]=M.useState(!1),[a,o]=M.useState(null),l=Djt(),i=Or(),d=TTe[t.content_type]||TTe.link,u=d.icon,f=M.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?VLt(t.url):null,[t]);M.useEffect(()=>{f||!t.url||t.content_type!=="video"||!HLt(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(b=>b.ok?b.json():null).then(b=>{b!=null&&b.thumbnail_url&&o(b.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,f]);const g=f||a,v=()=>{i(`/brokerage-content/${t.id}`)},_=async()=>{try{await l.mutateAsync(t.id),ge.success("Content deleted")}catch{ge.error("Failed to delete")}n(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(De,{className:"group overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",onClick:v,children:[g?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:g,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(u,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(nt,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${d.color}`,children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),d.label]}),t.category&&e.jsxs(nt,{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:["📅 ",js(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",js(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,onClick:b=>b.stopPropagation(),children:e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(xg,{className:"h-4 w-4"})})}),e.jsx(mu,{align:"end",children:e.jsxs(Wa,{onClick:b=>{b.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(Cr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(uc,{open:r,onOpenChange:n,children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete Content"}),e.jsxs(Xl,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:_,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function GLt(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 ATe=[{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 KLt({brokerageId:t,categories:s}){var ve;const{user:r}=Qs(),[n,a]=M.useState(!1),[o,l]=M.useState(!1),[i,d]=M.useState(""),[u,f]=M.useState("📁"),[g,v]=M.useState(!1);M.useRef(null);const[_,b]=M.useState("video"),[w,j]=M.useState(""),[N,S]=M.useState(""),[A,I]=M.useState(""),[L,F]=M.useState(""),[$,q]=M.useState(""),[H,U]=M.useState(""),[Q,se]=M.useState(""),te=Ljt(),Y=Ojt(t),ce=Rjt(),oe=Fjt(t),le=()=>{b("video"),j(""),S(""),I(""),F(""),q(""),U(""),se("")},de=async(ke,Ge)=>{var Ae;const Ne=(Ae=ke.target.files)==null?void 0:Ae[0];if(Ne){v(!0);try{const Pe=Ne.name.split(".").pop(),Fe=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Pe}`,{error:Ie}=await K.storage.from("brokerage-content").upload(Fe,Ne);if(Ie)throw Ie;const{data:{publicUrl:Ve}}=K.storage.from("brokerage-content").getPublicUrl(Fe);Ge==="file"?(F(Ve),_==="graphic"&&!$&&q(Ve)):q(Ve),ge.success("File uploaded")}catch(Pe){ge.error(Pe.message||"Upload failed")}finally{v(!1)}}},xe=async()=>{if(!w.trim()){ge.error("Title is required");return}if(r)try{await te.mutateAsync({brokerage_id:t,category_id:Q||null,content_type:_,title:w.trim(),description:N.trim()||null,url:A.trim()||null,file_url:L.trim()||null,thumbnail_url:$.trim()||null,event_date:H?new Date(H).toISOString():null,created_by:r.id}),ge.success("Content added!"),le(),a(!1)}catch(ke){ge.error(ke.message||"Failed to add content")}},be=async()=>{if(i.trim())try{await Y.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),d(""),f("📁"),ge.success("Category created")}catch(ke){ge.error(ke.message||"Failed to create category")}},ye=async()=>{try{await oe.mutateAsync(),ge.success("Default categories created")}catch{ge.error("Failed to create defaults")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(bs,{open:n,onOpenChange:a,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{children:"Content Type"}),e.jsxs(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:ATe.map(ke=>e.jsx(At,{value:ke.value,children:ke.label},ke.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(ve=ATe.find(ke=>ke.value===_))==null?void 0:ve.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Category"}),e.jsxs(tr,{value:Q,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select category (optional)"})}),e.jsx(er,{children:s.map(ke=>e.jsxs(At,{value:ke.id,children:[ke.icon," ",ke.name]},ke.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Title *"}),e.jsx(Re,{value:w,onChange:ke=>j(ke.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{value:N,onChange:ke=>S(ke.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:_==="video"?"Video URL":_==="graphic"?"Canva / Image URL":_==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(Re,{value:A,onChange:ke=>{const Ge=ke.target.value;if(I(Ge),_==="video"&&!$){const Ne=GLt(Ge);Ne&&q(Ne)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:_==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"file",accept:_==="pdf"?".pdf,.doc,.docx":"image/*",onChange:ke=>de(ke,"file"),disabled:g}),g&&e.jsx(Rs,{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(_e,{children:"Thumbnail Image (optional)"}),e.jsx(Re,{type:"file",accept:"image/*",onChange:ke=>de(ke,"thumbnail"),disabled:g}),$&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:$,className:"w-full h-full object-cover",alt:"thumb"}),e.jsx("button",{onClick:()=>q(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(Vr,{className:"h-3 w-3"})})]})]}),_==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Event Date & Time"}),e.jsx(Re,{type:"datetime-local",value:H,onChange:ke=>U(ke.target.value)})]}),e.jsxs(Z,{onClick:xe,disabled:te.isPending||!w.trim(),className:"w-full",children:[te.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(bs,{open:o,onOpenChange:l,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",children:[e.jsx(Pl,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Z,{variant:"outline",size:"sm",onClick:ye,disabled:oe.isPending,children:[oe.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(ke=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[ke.icon," ",ke.name]}),!ke.is_default&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ce.mutateAsync(ke.id),ge.success("Category deleted")},children:e.jsx(Vr,{className:"h-4 w-4"})})]},ke.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(Re,{value:u,onChange:ke=>f(ke.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(Re,{value:i,onChange:ke=>d(ke.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:ke=>ke.key==="Enter"&&be()}),e.jsx(Z,{size:"sm",onClick:be,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function ZLt(){const{user:t,isAdmin:s,isBrokerageManager:r}=Qs(),[n,a]=M.useState(!0),[o,l]=M.useState(null),[i,d]=M.useState(""),[u,f]=M.useState(!1),[g,v]=M.useState(null),[_,b]=M.useState("");M.useEffect(()=>{(async()=>{if(t)try{const{data:I}=await K.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 K.from("brokerages").select("name").eq("id",I.brokerage_id).maybeSingle();if(L&&d(L.name),s)f(!0);else if(r){const{data:F}=await K.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",I.brokerage_id).maybeSingle();f(!!F)}}catch(I){console.error("Error fetching brokerage info:",I)}finally{a(!1)}})()},[t,s,r]);const{data:w=[]}=Ejt(o),{data:j=[],isLoading:N}=Pjt(o,g),S=M.useMemo(()=>{if(!_.trim())return j;const A=_.toLowerCase();return j.filter(I=>{var L;return I.title.toLowerCase().includes(A)||((L=I.description)==null?void 0:L.toLowerCase().includes(A))||I.content_type.toLowerCase().includes(A)})},[j,_]);return n?e.jsx(Ms,{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(Ms,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(KLt,{brokerageId:o,categories:w}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search content...",value:_,onChange:A=>b(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Z,{variant:g===null?"default":"outline",size:"sm",onClick:()=>v(null),children:"All"}),w.map(A=>e.jsxs(Z,{variant:g===A.id?"default":"outline",size:"sm",onClick:()=>v(A.id),children:[e.jsx("span",{className:"mr-1",children:A.icon}),A.name]},A.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"})}):S.length===0?e.jsx(De,{className:"bg-muted/30 border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Oh,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:_.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:_.trim()?"Try a different search term or category.":u?"Add your first piece of content above.":"Your brokerage hasn't added content yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:S.map(A=>e.jsx(WLt,{item:A,canManage:u},A.id))})]})}):e.jsx(Ms,{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(_a,{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 ETe={video:{icon:dl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:Un,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Al,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:nn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:El,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function YLt(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 XLt(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function QLt(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function JLt(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function eDt(){const{contentId:t}=Uo(),{data:s,isLoading:r}=Tt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:f}=await K.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(f)throw f;return u},enabled:!!t});if(r)return e.jsx(Ms,{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(Ms,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(_a,{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(Z,{asChild:!0,className:"mt-4",children:e.jsx(yo,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=ETe[s.content_type]||ETe.link,a=n.icon,o=s.url||s.file_url,l=o&&XLt(o)?YLt(o):null,i=o&&QLt(o)?JLt(o):null,d=l||i;return e.jsx(Ms,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsx(Z,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(yo,{to:"/brokerage-content",children:[e.jsx(Ba,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(nt,{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(nt,{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 ",js(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),d&&e.jsx(De,{className:"overflow-hidden",children:e.jsx("div",{className:"relative w-full bg-black",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:d,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&&!d&&e.jsx(De,{className:"overflow-hidden",children:e.jsx("img",{src:s.file_url,alt:s.title,className:"w-full max-h-[600px] object-contain bg-muted"})}),!d&&s.content_type!=="graphic"&&s.thumbnail_url&&e.jsx(De,{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(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})}),s.content_type==="event"&&s.event_date&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(nn,{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:js(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(Z,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),s.content_type==="pdf"?"Download Document":"Download File"]})}),s.url&&e.jsx(Z,{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(un,{className:"h-4 w-4 mr-2"}),d?"Open on YouTube":s.content_type==="event"?"Join Event":s.content_type==="graphic"?"Open in Canva":"Open Link"]})})]})]})})}function tDt(){const t=Or(),[s,r]=M.useState(""),[n,a]=M.useState("grid"),{data:o,isLoading:l}=Tt({queryKey:["newsletters"],queryFn:async()=>{const{data:A,error:I}=await K.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;return A}}),{data:i}=Tt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:A}=await K.from("newsletter_likes").select("newsletter_id");return A||[]}}),{data:d}=Tt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:A}=await K.from("newsletter_comments").select("newsletter_id");return A||[]}}),{data:u}=Tt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[A,I,L,F]=await Promise.all([K.from("newsletter_canva_links").select("newsletter_id"),K.from("newsletter_pdfs").select("newsletter_id"),K.from("newsletter_videos").select("newsletter_id"),K.from("newsletter_drive_links").select("newsletter_id")]);return{canva:A.data||[],pdfs:I.data||[],videos:L.data||[],drives:F.data||[]}}}),f=A=>(i==null?void 0:i.filter(I=>I.newsletter_id===A).length)||0,g=A=>(d==null?void 0:d.filter(I=>I.newsletter_id===A).length)||0,v=A=>{var I;return((I=u==null?void 0:u.canva)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},_=A=>{var I;return((I=u==null?void 0:u.pdfs)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},b=A=>{var I;return((I=u==null?void 0:u.videos)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},w=A=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},j=A=>v(A)+_(A)+b(A)+w(A),N=o==null?void 0:o.filter(A=>{var I;return A.title.toLowerCase().includes(s.toLowerCase())||((I=A.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase()))}),S=A=>{t(`/newsletters/${A}`)};return e.jsx(Ms,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search newsletters...",value:s,onChange:A=>r(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(hp,{className:"h-4 w-4"})}),e.jsx(Z,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Fh,{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((A,I)=>e.jsx(De,{children:e.jsxs(Oe,{className:"p-0",children:[e.jsx(gs,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{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(Un,{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(Z,{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(A=>{const I=j(A.id),L=v(A.id),F=_(A.id),$=b(A.id);return n==="grid"?e.jsxs(De,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(A.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:A.preview_image_url?e.jsx("img",{src:A.preview_image_url,alt:A.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(Un,{className:"h-16 w-16"})})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:A.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(nn,{className:"h-3 w-3"}),js(new Date(A.publish_date),"MMM d, yyyy")]})]}),A.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:A.description.replace(/<[^>]*>/g,"")}),I>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L>0&&e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(El,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),F>0&&e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Ei,{className:"h-3 w-3"})," ",F," PDF",F>1?"s":""]}),$>0&&e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(dl,{className:"h-3 w-3"})," ",$," Video",$>1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground pt-1 border-t border-border/50",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lu,{className:"h-3 w-3"})," ",f(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mc,{className:"h-3 w-3"})," ",g(A.id)]})]})]})]},A.id):e.jsx(De,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(A.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:A.preview_image_url?e.jsx("img",{src:A.preview_image_url,alt:A.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(Un,{className:"h-10 w-10"})})}),e.jsxs(Oe,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:A.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(nn,{className:"h-3 w-3"}),js(new Date(A.publish_date),"MMM d, yyyy")]})]}),A.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:A.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(lu,{className:"h-3 w-3"})," ",f(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mc,{className:"h-3 w-3"})," ",g(A.id)]})]})]})]})},A.id)})})]})})}function sDt({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(De,{className:"overflow-hidden border-border/50",children:[o.image_url&&e.jsx("img",{src:o.image_url,alt:o.title||"",className:"w-full h-40 object-cover"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[o.title&&e.jsx("h4",{className:"font-semibold text-foreground",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})]},l))},n)})})}function rDt(){const{id:t}=Uo(),s=Or(),{user:r}=Qs(),{toast:n}=La(),a=ds(),{trackEngagement:o}=_L(),[l,i]=M.useState(""),{data:d,isLoading:u}=Tt({queryKey:["newsletter",t],queryFn:async()=>{const{data:L,error:F}=await K.from("newsletter_content").select("*").eq("id",t).single();if(F)throw F;return L},enabled:!!t});M.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:f}=Tt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:L}=await K.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:g}=Tt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:L}=await K.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:v}=Tt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:L}=await K.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:_}=Tt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:L}=await K.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:b}=Tt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await K.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:w}=Tt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:L}=await K.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return L||[]},enabled:!!t}),j=b==null?void 0:b.some(L=>L.user_id===(r==null?void 0:r.id)),N=Bt({mutationFn:async()=>{j?await K.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await K.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),S=Bt({mutationFn:async L=>{const{error:F}=await K.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:L});if(F)throw F},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),A=Bt({mutationFn:async L=>{const{error:F}=await K.from("newsletter_comments").delete().eq("id",L);if(F)throw F},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 F=L.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(F)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${F[1]}/${F[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 F=L.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(F)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${F[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(dl,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Ms,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-32"}),e.jsx(gs,{className:"h-64 w-full"}),e.jsx(gs,{className:"h-32 w-full"})]})}):d?e.jsx(Ms,{title:"",description:"",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(Z,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(Ba,{className:"mr-2 h-4 w-4"})," Back to Newsletters"]}),d.preview_image_url&&e.jsx("img",{src:d.preview_image_url,alt:d.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:d.title}),e.jsx("p",{className:"text-muted-foreground mt-1",children:js(new Date(d.publish_date),"MMMM d, yyyy")})]}),d.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:d.description}}),e.jsx(sDt,{rows:d.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(hM,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),e.jsxs(Z,{variant:j?"default":"outline",size:"sm",onClick:()=>N.mutate(),children:[e.jsx(Oi,{className:`h-4 w-4 mr-1 ${j?"fill-current":""}`}),(b==null?void 0:b.length)||0," ",(b==null?void 0:b.length)===1?"Like":"Likes"]})]}),_&&_.length>0&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Oe,{className:"space-y-2",children:_.map(L=>e.jsxs("a",{href:L.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_canva"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(El,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),f&&f.length>0&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Oe,{className:"space-y-2",children:f.map(L=>e.jsxs("a",{href:L.drive_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_link"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(un,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),g&&g.length>0&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Oe,{className:"space-y-2",children:g.map(L=>e.jsxs("a",{href:L.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_pdf"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Un,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(Ei,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),v&&v.length>0&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Videos"})}),e.jsx(Oe,{className:"space-y-6",children:v.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(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"text-lg",children:["Comments (",(w==null?void 0:w.length)||0,")"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Lr,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(Z,{onClick:()=>l.trim()&&S.mutate(l),disabled:!l.trim()||S.isPending,children:e.jsx(Pa,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:w==null?void 0:w.map(L=>{var F,$,q;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(mn,{className:"h-8 w-8",children:e.jsx(pn,{children:(($=(F=L.profiles)==null?void 0:F.name)==null?void 0:$[0])||"U"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-sm",children:((q=L.profiles)==null?void 0:q.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:js(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A.mutate(L.id),children:e.jsx(Cr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:L.content})]})]},L.id)})})]})]})]})}):e.jsx(Ms,{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(Z,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function nDt({rows:t,onChange:s}){const[r,n]=M.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((f,g)=>g!==u))},l=(u,f,g,v)=>{const _=[...t];_[u]={..._[u],columns:_[u].columns.map((b,w)=>w===f?{...b,[g]:v}:b)},s(_)},i=async(u,f,g)=>{var b;const v=(b=g.target.files)==null?void 0:b[0];if(!v)return;const _=`${u}-${f}`;n(_);try{const w=`content-blocks/${Date.now()}-${v.name}`,{error:j}=await K.storage.from("newsletter-content").upload(w,v);if(!j){const{data:N}=K.storage.from("newsletter-content").getPublicUrl(w);l(u,f,"image_url",N.publicUrl)}}finally{n(null)}},d=(u,f)=>{l(u,f,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx(Ys,{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,f)=>e.jsxs(De,{className:"relative",children:[e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(f),children:e.jsx(Vr,{className:"h-4 w-4"})}),e.jsxs(Oe,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Rh,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",f+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.columns.map((g,v)=>{const _=`${f}-${v}`;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 ",v+1]}),g.image_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:g.image_url,alt:"",className:"w-full h-20 object-cover rounded"}),e.jsx(Z,{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:()=>d(f,v),children:e.jsx(Vr,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${_}`,onChange:b=>i(f,v,b)}),e.jsx(Z,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===_,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${_}`,className:"cursor-pointer",children:r===_?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(Xo,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(Re,{placeholder:"Title",value:g.title,onChange:b=>l(f,v,"title",b.target.value),className:"h-8 text-sm"}),e.jsx(Lr,{placeholder:"Description",value:g.description,onChange:b=>l(f,v,"description",b.target.value),className:"text-sm min-h-[60px] resize-none"})]},v)})})]})]},f))]})}function aDt(){const{toast:t}=La(),s=ds(),[r,n]=M.useState(!1),[a,o]=M.useState(null),[l,i]=M.useState({title:"",description:"",publish_date:js(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,u]=M.useState(null),[f,g]=M.useState(null),[v,_]=M.useState([]),[b,w]=M.useState([]),[j,N]=M.useState([]),[S,A]=M.useState([]),[I,L]=M.useState([]),[F,$]=M.useState([]),[q,H]=M.useState(!1),{data:U,isLoading:Q}=Tt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Ne,error:Ae}=await K.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Ae)throw Ae;return Ne}}),se=Bt({mutationFn:async Ne=>{const{data:Ae,error:Pe}=await K.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(Pe)throw Pe;return Ae},onSuccess:async Ne=>{await ce(Ne.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Ne.is_published&&_It(Ne.title,Ne.id),de()},onError:Ne=>{t({title:"Error creating newsletter",description:Ne.message,variant:"destructive"})}}),te=Bt({mutationFn:async Ne=>{const{error:Ae}=await K.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"}),de()},onError:Ne=>{t({title:"Error updating newsletter",description:Ne.message,variant:"destructive"})}}),Y=Bt({mutationFn:async Ne=>{const{error:Ae}=await K.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 K.from("newsletter_drive_links").delete().eq("newsletter_id",Ne),await K.from("newsletter_pdfs").delete().eq("newsletter_id",Ne),await K.from("newsletter_videos").delete().eq("newsletter_id",Ne),await K.from("newsletter_canva_links").delete().eq("newsletter_id",Ne);for(const Ae of F){const Pe=`${Ne}/${Date.now()}-${Ae.file.name}`,{error:Fe}=await K.storage.from("newsletter-content").upload(Pe,Ae.file);if(!Fe){const{data:Ie}=K.storage.from("newsletter-content").getPublicUrl(Pe);b.push({name:Ae.name,file_url:Ie.publicUrl,file_size:Ae.file.size,sort_order:b.length})}}v.length>0&&await K.from("newsletter_drive_links").insert(v.map((Ae,Pe)=>({newsletter_id:Ne,title:Ae.title,drive_url:Ae.drive_url,sort_order:Pe}))),b.length>0&&await K.from("newsletter_pdfs").insert(b.map((Ae,Pe)=>({newsletter_id:Ne,name:Ae.name,file_url:Ae.file_url,file_size:Ae.file_size||null,sort_order:Pe}))),j.length>0&&await K.from("newsletter_videos").insert(j.map((Ae,Pe)=>({newsletter_id:Ne,title:Ae.title,video_url:Ae.video_url,sort_order:Pe}))),S.length>0&&await K.from("newsletter_canva_links").insert(S.map((Ae,Pe)=>({newsletter_id:Ne,title:Ae.title,canva_share_link:Ae.canva_share_link,sort_order:Pe})))},oe=async Ne=>{o(Ne),i({title:Ne.title,description:Ne.description||"",publish_date:js(new Date(Ne.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Ne.is_published}),g(Ne.preview_image_url),L(Ne.content_blocks||[]);const[Ae,Pe,Fe,Ie]=await Promise.all([K.from("newsletter_drive_links").select("*").eq("newsletter_id",Ne.id).order("sort_order"),K.from("newsletter_pdfs").select("*").eq("newsletter_id",Ne.id).order("sort_order"),K.from("newsletter_videos").select("*").eq("newsletter_id",Ne.id).order("sort_order"),K.from("newsletter_canva_links").select("*").eq("newsletter_id",Ne.id).order("sort_order")]);_(Ae.data||[]),w(Pe.data||[]),N(Fe.data||[]),A(Ie.data||[]),$([]),n(!0)},le=async Ne=>{const[Ae,Pe,Fe,Ie]=await Promise.all([K.from("newsletter_drive_links").select("*").eq("newsletter_id",Ne.id).order("sort_order"),K.from("newsletter_pdfs").select("*").eq("newsletter_id",Ne.id).order("sort_order"),K.from("newsletter_videos").select("*").eq("newsletter_id",Ne.id).order("sort_order"),K.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:js(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),g(Ne.preview_image_url),L(Ne.content_blocks||[]),_((Ae.data||[]).map(({id:Ve,...dt})=>dt)),w((Pe.data||[]).map(({id:Ve,...dt})=>dt)),N((Fe.data||[]).map(({id:Ve,...dt})=>dt)),A((Ie.data||[]).map(({id:Ve,...dt})=>dt)),$([]),n(!0)},de=()=>{n(!1),o(null),i({title:"",description:"",publish_date:js(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),g(null),_([]),w([]),N([]),A([]),L([]),$([])},xe=async Ne=>{var Pe;const Ae=(Pe=Ne.target.files)==null?void 0:Pe[0];Ae&&(u(Ae),g(URL.createObjectURL(Ae)))},be=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}H(!0);let Ne=f;if(d){const Ae=`previews/${Date.now()}-${d.name}`,{error:Pe}=await K.storage.from("newsletter-content").upload(Ae,d);if(!Pe){const{data:Fe}=K.storage.from("newsletter-content").getPublicUrl(Ae);Ne=Fe.publicUrl}}a?te.mutate({id:a.id,...l,preview_image_url:Ne,content_blocks:I}):se.mutate({...l,preview_image_url:Ne,content_blocks:I}),H(!1)},ye=()=>_([...v,{title:"",drive_url:"",sort_order:v.length}]),ve=()=>N([...j,{title:"",video_url:"",sort_order:j.length}]),ke=()=>A([...S,{title:"",canva_share_link:"",sort_order:S.length}]),Ge=Ne=>{const Ae=Ne.target.files;if(!Ae)return;const Pe=Array.from(Ae).map(Fe=>({file:Fe,name:Fe.name.replace(/\.[^/.]+$/,"")}));$([...F,...Pe])};return e.jsx(Ms,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.length)||0})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.filter(Ne=>Ne.is_published).length)||0})})]})]}),e.jsxs(bs,{open:r,onOpenChange:Ne=>!Ne&&de(),children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{onClick:()=>n(!0),children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(_s,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{children:"Title *"}),e.jsx(Re,{value:l.title,onChange:Ne=>i({...l,title:Ne.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Publish Date"}),e.jsx(Re,{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(_e,{children:"Description"}),e.jsx(Wg,{content:l.description,onChange:Ne=>i({...l,description:Ne}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:f,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(Z,{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),g(null)},children:e.jsx(Vr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:xe,className:"hidden",id:"preview-upload"}),e.jsx(Z,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(xi,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:l.is_published,onCheckedChange:Ne=>i({...l,is_published:Ne})}),e.jsx(_e,{children:"Published"})]}),e.jsx(nDt,{rows:I,onChange:L}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:ke,children:[e.jsx(Ys,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),S.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Link title",value:Ne.title,onChange:Pe=>{const Fe=[...S];Fe[Ae].title=Pe.target.value,A(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Canva share link",value:Ne.canva_share_link,onChange:Pe=>{const Fe=[...S];Fe[Ae].canva_share_link=Pe.target.value,A(Fe)},className:"flex-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>A(S.filter((Pe,Fe)=>Fe!==Ae)),children:e.jsx(Vr,{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(_e,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:ye,children:[e.jsx(Ys,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),v.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Link title",value:Ne.title,onChange:Pe=>{const Fe=[...v];Fe[Ae].title=Pe.target.value,_(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Google Drive URL",value:Ne.drive_url,onChange:Pe=>{const Fe=[...v];Fe[Ae].drive_url=Pe.target.value,_(Fe)},className:"flex-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(v.filter((Pe,Fe)=>Fe!==Ae)),children:e.jsx(Vr,{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(_e,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:".pdf",multiple:!0,onChange:Ge,className:"hidden",id:"pdf-upload"}),e.jsx(Z,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(xi,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Ne.name}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(b.filter((Pe,Fe)=>Fe!==Ae)),children:e.jsx(Vr,{className:"h-4 w-4"})})]},`existing-${Ae}`)),F.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:Ne.name,onChange:Pe=>{const Fe=[...F];Fe[Ae].name=Pe.target.value,$(Fe)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>$(F.filter((Pe,Fe)=>Fe!==Ae)),children:e.jsx(Vr,{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(_e,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:ve,children:[e.jsx(Ys,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),j.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Video title",value:Ne.title,onChange:Pe=>{const Fe=[...j];Fe[Ae].title=Pe.target.value,N(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Video URL",value:Ne.video_url,onChange:Pe=>{const Fe=[...j];Fe[Ae].video_url=Pe.target.value,N(Fe)},className:"flex-1"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(j.filter((Pe,Fe)=>Fe!==Ae)),children:e.jsx(Vr,{className:"h-4 w-4"})})]},Ae))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Z,{variant:"outline",onClick:de,children:"Cancel"}),e.jsx(Z,{onClick:be,disabled:q||se.isPending||te.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:Q?e.jsx(ks,{children:e.jsx(lt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(U==null?void 0:U.length)===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):U==null?void 0:U.map(Ne=>e.jsxs(ks,{children:[e.jsx(lt,{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(Un,{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(lt,{children:js(new Date(Ne.publish_date),"MMM d, yyyy")}),e.jsx(lt,{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(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>oe(Ne),title:"Edit",children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>le(Ne),title:"Duplicate",children:e.jsx(Ni,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&Y.mutate(Ne.id)},children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},Ne.id))})]})})})]})})}const PTe={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 iDt(){const{user:t}=Qs(),{toast:s}=La(),r=Or(),n=ds(),[a,o]=M.useState(""),[l,i]=M.useState("popular"),[d,u]=M.useState(!1),[f,g]=M.useState(""),[v,_]=M.useState(""),[b,w]=M.useState(!1),{data:j=[],isLoading:N}=Tt({queryKey:["wishlist-items",l,b],queryFn:async()=>{let F=K.from("wishlist_items").select("*");b&&t&&(F=F.eq("user_id",t.id)),l==="latest"?F=F.order("created_at",{ascending:!1}):l==="popular"?F=F.order("vote_count",{ascending:!1}):l==="trending"&&(F=F.order("vote_count",{ascending:!1}));const{data:$,error:q}=await F;if(q)throw q;const H=[...new Set(($==null?void 0:$.map(oe=>oe.user_id))||[])],{data:U}=await K.from("profiles").select("id, name").in("id",H),Q=new Map((U==null?void 0:U.map(oe=>[oe.id,oe]))||[]);let se=[];if(t){const{data:oe}=await K.from("wishlist_votes").select("item_id").eq("user_id",t.id);se=(oe==null?void 0:oe.map(le=>le.item_id))||[]}const te=($==null?void 0:$.map(oe=>oe.id))||[],{data:Y}=await K.from("wishlist_comments").select("item_id").in("item_id",te),ce=new Map;return Y==null||Y.forEach(oe=>{ce.set(oe.item_id,(ce.get(oe.item_id)||0)+1)}),$==null?void 0:$.map(oe=>{const le=Q.get(oe.user_id),de=(le==null?void 0:le.name)||"Unknown";return{...oe,user_name:de,user_initials:de.split(" ").map(xe=>xe[0]).join("").toUpperCase().slice(0,2),has_voted:se.includes(oe.id),comment_count:ce.get(oe.id)||0}})}}),S=Bt({mutationFn:async({title:F,description:$})=>{const{error:q}=await K.from("wishlist_items").insert({user_id:t.id,title:F,description:$});if(q)throw q},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),g(""),_(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:F=>{s({title:"Error",description:F.message,variant:"destructive"})}}),A=Bt({mutationFn:async({itemId:F,hasVoted:$})=>{if($){const{error:q}=await K.from("wishlist_votes").delete().eq("item_id",F).eq("user_id",t.id);if(q)throw q;return{itemId:F,wasAdded:!1}}else{const{error:q}=await K.from("wishlist_votes").insert({item_id:F,user_id:t.id});if(q)throw q;return{itemId:F,wasAdded:!0}}},onSuccess:async F=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),F!=null&&F.wasAdded){const $=j.find(H=>H.id===F.itemId),q=(($==null?void 0:$.vote_count)||0)+1;K.functions.invoke("wishlist-notify",{body:{itemId:F.itemId,voteCount:q}}).catch(console.error)}},onError:F=>{s({title:"Error",description:F.message,variant:"destructive"})}}),I=j.filter(F=>F.title.toLowerCase().includes(a.toLowerCase())||F.description.toLowerCase().includes(a.toLowerCase())),L=()=>{if(!f.trim()||!v.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}S.mutate({title:f.trim(),description:v.trim()})};return e.jsx(Ms,{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(G1,{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(bs,{open:d,onOpenChange:u,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",placeholder:"Give your idea a clear title...",value:f,onChange:F=>g(F.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:v,onChange:F=>_(F.target.value),rows:4})]}),e.jsx(Z,{onClick:L,className:"w-full",disabled:S.isPending,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search ideas...",value:a,onChange:F=>o(F.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ia,{value:l,onValueChange:F=>i(F),children:e.jsxs(Aa,{children:[e.jsx(Ts,{value:"popular",children:"Most Popular"}),e.jsx(Ts,{value:"latest",children:"Latest"}),e.jsx(Ts,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(Z,{variant:b?"default":"outline",size:"sm",onClick:()=>w(!b),children:b?"Show All Ideas":"My Ideas"})}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Rs,{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(G1,{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(Z,{onClick:()=>u(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:I.map(F=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${F.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:$=>{$.stopPropagation(),A.mutate({itemId:F.id,hasVoted:F.has_voted||!1})},className:It("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",F.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Rd,{className:It("h-4 w-4",F.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:F.vote_count})]}),e.jsx(mn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(pn,{className:"bg-primary/20 text-primary text-sm font-medium",children:F.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:F.title}),e.jsx(nt,{className:It("text-xs",PTe[F.status].color),children:PTe[F.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:F.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:F.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(F.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ho,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:F.comment_count})]})]})},F.id))})]})})}const ITe={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 oDt(){const{itemId:t}=Uo(),s=Or(),{user:r}=Qs(),{toast:n}=La(),a=ds(),[o,l]=M.useState(""),{data:i=!1}=Tt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:j,error:N}=await K.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!N&&!!j},enabled:!!r}),{data:d,isLoading:u}=Tt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:j,error:N}=await K.from("wishlist_items").select("*").eq("id",t).single();if(N)throw N;const{data:S}=await K.from("profiles").select("name").eq("id",j.user_id).single();let A=!1;if(r){const{data:I}=await K.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();A=!!I}return{...j,user_name:(S==null?void 0:S.name)||"Unknown",user_initials:((S==null?void 0:S.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:A}}}),{data:f=[],isLoading:g}=Tt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:j,error:N}=await K.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(N)throw N;const S=[...new Set((j==null?void 0:j.map(L=>L.user_id))||[])],{data:A}=await K.from("profiles").select("id, name").in("id",S),I=new Map((A==null?void 0:A.map(L=>[L.id,L]))||[]);return j==null?void 0:j.map(L=>{const F=I.get(L.user_id),$=(F==null?void 0:F.name)||"Unknown";return{...L,user_name:$,user_initials:$.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2)}})}}),v=Bt({mutationFn:async j=>{if(j){const{error:N}=await K.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 K.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(N)throw N;return{wasAdded:!0}}},onSuccess:async j=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),j!=null&&j.wasAdded&&d){const N=(d.vote_count||0)+1;K.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:N}}).catch(console.error)}},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),_=Bt({mutationFn:async j=>{const{error:N}=await K.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:j});if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),b=Bt({mutationFn:async j=>{const{error:N}=await K.from("wishlist_comments").delete().eq("id",j);if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),w=()=>{o.trim()&&_.mutate(o.trim())};return u?e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(gs,{className:"h-8 w-32 mb-6"}),e.jsx(gs,{className:"h-48 w-full mb-6"}),e.jsx(gs,{className:"h-32 w-full"})]})}):d?e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(Ba,{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:()=>v.mutate(d.has_voted),className:It("flex flex-col items-center justify-center min-w-[60px] py-3 px-4 rounded-lg border transition-colors",d.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Rd,{className:It("h-5 w-5",d.has_voted&&"fill-current")}),e.jsx("span",{className:"text-lg font-bold",children:d.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:d.title}),e.jsx(nt,{className:It("text-xs",ITe[d.status].color),children:ITe[d.status].label})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap mb-4",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(mn,{className:"h-6 w-6",children:e.jsx(pn,{className:"bg-primary/20 text-primary text-xs",children:d.user_initials})}),e.jsx("span",{children:d.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(d.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 (",f.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(oae,{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(Z,{onClick:w,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(Pa,{className:"h-4 w-4"})})]}),g?e.jsx("div",{className:"space-y-4",children:[1,2].map(j=>e.jsx(gs,{className:"h-20 w-full"},j))}):f.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:f.map(j=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(mn,{className:"h-8 w-8",children:e.jsx(pn,{className:"bg-primary/20 text-primary text-xs",children:j.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:j.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(j.created_at).toLocaleDateString()})]}),e.jsx(vbe,{content:j.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===j.user_id&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>b.mutate(j.id),children:e.jsx(Cr,{className:"h-4 w-4"})})]},j.id))})]})]})}):e.jsx(Ms,{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(Z,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const LTe={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"}},DTe=["open","under_review","planned","in_progress","launched","declined"];function lDt(){const{toast:t}=La(),s=Or(),r=ds(),[n,a]=M.useState(""),[o,l]=M.useState("all"),[i,d]=M.useState(!1),[u,f]=M.useState(null),{data:g=[],isLoading:v}=Tt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:N,error:S}=await K.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(S)throw S;const A=[...new Set((N==null?void 0:N.map(H=>H.user_id))||[])],{data:I}=await K.from("profiles").select("id, name, email").in("id",A),L=new Map((I==null?void 0:I.map(H=>[H.id,H]))||[]),F=(N==null?void 0:N.map(H=>H.id))||[],{data:$}=await K.from("wishlist_comments").select("item_id").in("item_id",F),q=new Map;return $==null||$.forEach(H=>{q.set(H.item_id,(q.get(H.item_id)||0)+1)}),N==null?void 0:N.map(H=>{const U=L.get(H.user_id);return{...H,user_name:(U==null?void 0:U.name)||"Unknown",user_email:(U==null?void 0:U.email)||"",comment_count:q.get(H.id)||0}})}}),_=Bt({mutationFn:async({itemId:N,status:S})=>{const{error:A}=await K.from("wishlist_items").update({status:S}).eq("id",N);if(A)throw A},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),b=Bt({mutationFn:async N=>{const{error:S}=await K.from("wishlist_items").delete().eq("id",N);if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),f(null),t({title:"Item deleted!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),w=g.filter(N=>{const S=N.title.toLowerCase().includes(n.toLowerCase())||N.description.toLowerCase().includes(n.toLowerCase())||N.user_name.toLowerCase().includes(n.toLowerCase()),A=o==="all"||N.status===o;return S&&A}),j={total:g.length,open:g.filter(N=>N.status==="open").length,inProgress:g.filter(N=>N.status==="in_progress").length,launched:g.filter(N=>N.status==="launched").length,highVotes:g.filter(N=>N.vote_count>=10).length};return e.jsx(Ms,{title:"Admin - Wishlist",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(Ba,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:j.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:j.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:j.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:j.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:j.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search ideas, users...",value:n,onChange:N=>a(N.target.value),className:"pl-10"})]}),e.jsxs(tr,{value:o,onValueChange:N=>l(N),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),DTe.map(N=>e.jsx(At,{value:N,children:LTe[N].label},N))]})]})]}),v?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(N=>e.jsx(gs,{className:"h-16 w-full"},N))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:w.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):w.map(N=>e.jsxs(ks,{className:It(N.vote_count>=10&&"bg-primary/5"),children:[e.jsx(lt,{children:e.jsx(nt,{variant:N.vote_count>=10?"default":"secondary",children:N.vote_count})}),e.jsx(lt,{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(lt,{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(lt,{className:"hidden sm:table-cell",children:N.comment_count}),e.jsx(lt,{children:e.jsxs(tr,{value:N.status,onValueChange:S=>_.mutate({itemId:N.id,status:S}),children:[e.jsx(Js,{className:"w-[140px] h-8",children:e.jsx(rr,{})}),e.jsx(er,{children:DTe.map(S=>e.jsx(At,{value:S,children:LTe[S].label},S))})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${N.id}`,"_blank"),children:e.jsx(un,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{f(N.id),d(!0)},children:e.jsx(Cr,{className:"h-4 w-4"})})]})})]},N.id))})]})}),e.jsx(bs,{open:i,onOpenChange:d,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Z,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(Z,{variant:"destructive",onClick:()=>u&&b.mutate(u),disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function cDt(){const{user:t}=Qs(),[s,r]=M.useState([]),[n,a]=M.useState(!0),[o,l]=M.useState(!1),[i,d]=M.useState(null),[u,f]=M.useState(!1),[g,v]=M.useState(null),[_,b]=M.useState(""),[w,j]=M.useState(""),[N,S]=M.useState(""),[A,I]=M.useState(""),[L,F]=M.useState(""),[$,q]=M.useState(!1),[H,U]=M.useState(""),[Q,se]=M.useState("once"),[te,Y]=M.useState([]),[ce,oe]=M.useState([]),[le,de]=M.useState(!1),[xe,be]=M.useState(!1),[ye,ve]=M.useState([]),[ke,Ge]=M.useState({total:0,dismissed:0});M.useEffect(()=>{Ne()},[]);const Ne=async()=>{const{data:Ze,error:ht}=await K.from("levelup_briefs").select("*").order("created_at",{ascending:!1});ht?(ge.error("Failed to fetch briefs"),console.error(ht)):r(Ze||[]),a(!1)},Ae=()=>{b(""),j(""),S(""),I(""),F(""),q(!1),U(new Date().toISOString().slice(0,16)),se("once"),Y([]),oe([]),d(null)},Pe=()=>{Ae(),l(!0)},Fe=async Ze=>{d(Ze),b(Ze.title),j(Ze.description||""),S(Ze.video_url||""),I(Ze.graphic_url||""),F(Ze.graphic_link_url||""),q(Ze.is_published),U(Ze.publish_date.slice(0,16)),se(Ze.show_frequency);const{data:ht}=await K.from("levelup_brief_links").select("*").eq("brief_id",Ze.id).order("sort_order");Y((ht==null?void 0:ht.map(qe=>({title:qe.title,url:qe.url})))||[]);const{data:Ke}=await K.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(Ke){const qe=[];for(const Je of Ke){const{data:Lt}=await K.from("levelup_brief_poll_options").select("*").eq("poll_id",Je.id).order("sort_order");qe.push({question:Je.question,poll_type:Je.poll_type,options:(Lt==null?void 0:Lt.map(zt=>zt.option_text))||[]})}oe(qe)}l(!0)},Ie=async Ze=>{var Ke;const ht=(Ke=Ze.target.files)==null?void 0:Ke[0];if(ht){de(!0);try{const qe=await K.functions.invoke("bunny-upload",{body:{action:"create",title:ht.name.replace(/\.[^/.]+$/,"")}});if(qe.error)throw qe.error;const{videoId:Je,libraryId:Lt}=qe.data,zt=await K.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Je}});if(zt.error)throw zt.error;const{uploadUrl:is,apiKey:Kt}=zt.data,Qt=new XMLHttpRequest;await new Promise((dr,bt)=>{Qt.upload.addEventListener("progress",ws=>{if(ws.lengthComputable){const ir=Math.round(ws.loaded/ws.total*100);console.log("Upload progress:",ir)}}),Qt.addEventListener("load",()=>{Qt.status>=200&&Qt.status<300?dr():bt(new Error(`Upload failed with status ${Qt.status}`))}),Qt.addEventListener("error",()=>bt(new Error("Upload failed"))),Qt.open("PUT",is),Qt.setRequestHeader("AccessKey",Kt),Qt.send(ht)});const fs=`https://player.mediadelivery.net/embed/${Lt}/${Je}`;S(fs),ge.success("Video uploaded successfully! It may take a few minutes to process.")}catch(qe){console.error("Upload error:",qe),ge.error("Failed to upload video")}finally{de(!1)}}},Ve=async()=>{if(!_.trim()){ge.error("Title is required");return}try{let Ze;if(i){const{error:ht}=await K.from("levelup_briefs").update({title:_,description:w||null,video_url:N||null,graphic_url:A||null,graphic_link_url:L||null,is_published:$,publish_date:H,show_frequency:Q}).eq("id",i.id);if(ht)throw ht;Ze=i.id,await K.from("levelup_brief_links").delete().eq("brief_id",Ze);const{data:Ke}=await K.from("levelup_brief_polls").select("id").eq("brief_id",Ze);if(Ke)for(const qe of Ke)await K.from("levelup_brief_poll_options").delete().eq("poll_id",qe.id);await K.from("levelup_brief_polls").delete().eq("brief_id",Ze)}else{const{data:ht,error:Ke}=await K.from("levelup_briefs").insert({title:_,description:w||null,video_url:N||null,graphic_url:A||null,graphic_link_url:L||null,is_published:$,publish_date:H,show_frequency:Q,created_by:t==null?void 0:t.id}).select().single();if(Ke)throw Ke;Ze=ht.id}if(te.length>0){const ht=te.map((Ke,qe)=>({brief_id:Ze,title:Ke.title,url:Ke.url,sort_order:qe}));await K.from("levelup_brief_links").insert(ht)}for(let ht=0;ht0){const Lt=Ke.options.map((zt,is)=>({poll_id:qe.id,option_text:zt,sort_order:is}));await K.from("levelup_brief_poll_options").insert(Lt)}}ge.success(i?"Brief updated":"Brief created"),l(!1),Ae(),Ne()}catch(Ze){console.error("Error saving brief:",Ze),ge.error("Failed to save brief")}},dt=async Ze=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:ht}=await K.from("levelup_briefs").delete().eq("id",Ze);if(ht)throw ht;ge.success("Brief deleted"),Ne()}catch(ht){console.error("Error deleting brief:",ht),ge.error("Failed to delete brief")}},Le=async Ze=>{v(Ze);const{count:ht}=await K.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id),{count:Ke}=await K.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id).not("dismissed_at","is",null);Ge({total:ht||0,dismissed:Ke||0});const{data:qe}=await K.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(qe){const Je=[];for(const Lt of qe){const{data:zt}=await K.from("levelup_brief_poll_options").select("*").eq("poll_id",Lt.id).order("sort_order"),{data:is}=await K.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Lt.id),Kt=[...new Set((is==null?void 0:is.map(ws=>ws.user_id))||[])];let Qt={};if(Kt.length>0){const{data:ws}=await K.from("profiles").select("id, name, email").in("id",Kt);ws&&ws.forEach(ir=>{Qt[ir.id]=ir.name||ir.email||"Unknown"})}const fs=(is||[]).map(ws=>({optionId:ws.option_id,userName:Qt[ws.user_id]||"Unknown",userId:ws.user_id})),dr={};let bt=0;zt&&zt.forEach(ws=>{const ir=(is==null?void 0:is.filter(Rr=>Rr.option_id===ws.id).length)||0;dr[ws.id]=ir,bt+=ir}),Je.push({...Lt,options:zt||[],results:dr,respondents:fs,totalResponses:Lt.poll_type==="single"?new Set(is==null?void 0:is.map(ws=>ws.user_id)).size:bt})}ve(Je)}f(!0)},Rt=()=>{Y([...te,{title:"",url:""}])},fe=(Ze,ht,Ke)=>{const qe=[...te];qe[Ze][ht]=Ke,Y(qe)},Qe=Ze=>{Y(te.filter((ht,Ke)=>Ke!==Ze))},at=()=>{oe([...ce,{question:"",poll_type:"single",options:["",""]}])},rt=(Ze,ht)=>{const Ke=[...ce];Ke[Ze].question=ht,oe(Ke)},je=(Ze,ht)=>{const Ke=[...ce];Ke[Ze].poll_type=ht,oe(Ke)},mt=Ze=>{const ht=[...ce];ht[Ze].options.push(""),oe(ht)},He=(Ze,ht,Ke)=>{const qe=[...ce];qe[Ze].options[ht]=Ke,oe(qe)},ct=(Ze,ht)=>{const Ke=[...ce];Ke[Ze].options=Ke[Ze].options.filter((qe,Je)=>Je!==ht),oe(Ke)},We=Ze=>{oe(ce.filter((ht,Ke)=>Ke!==Ze))};return e.jsxs(Ms,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(Z,{onClick:Pe,children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:n?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ze=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:Ze.title}),e.jsx(lt,{children:e.jsx(nt,{variant:Ze.is_published?"default":"secondary",children:Ze.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"capitalize",children:Ze.show_frequency.replace("_"," ")}),e.jsx(lt,{children:js(new Date(Ze.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>Le(Ze),children:e.jsx(ol,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>Fe(Ze),children:e.jsx(Pc,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>dt(Ze.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},Ze.id))})]})})})]}),e.jsx(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(Ia,{defaultValue:"content",className:"w-full",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-4",children:[e.jsx(Ts,{value:"content",children:"Content"}),e.jsx(Ts,{value:"media",children:"Media"}),e.jsx(Ts,{value:"links",children:"Links"}),e.jsx(Ts,{value:"polls",children:"Polls"})]}),e.jsxs(Vs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Title *"}),e.jsx(Re,{value:_,onChange:Ze=>b(Ze.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Wg,{content:w,onChange:Ze=>j(Ze),placeholder:"Brief overview for agents...",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Publish Date"}),e.jsx(Re,{type:"datetime-local",value:H,onChange:Ze=>U(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Show Frequency"}),e.jsxs(tr,{value:Q,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"once",children:"Once (until dismissed)"}),e.jsx(At,{value:"every_login",children:"Every login"}),e.jsx(At,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qr,{checked:$,onCheckedChange:q}),e.jsx(_e,{children:"Publish immediately"})]})]}),e.jsxs(Vs,{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(_e,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Re,{type:"file",accept:"video/*",onChange:Ie,disabled:le})}),le&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Or paste embed URL"}),e.jsx(Re,{value:N,onChange:Ze=>S(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(_e,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Re,{type:"file",accept:"image/*",onChange:async Ze=>{var Ke;const ht=(Ke=Ze.target.files)==null?void 0:Ke[0];if(ht){be(!0);try{const qe=ht.name.split(".").pop(),Je=`brief-graphics/${Date.now()}.${qe}`,{error:Lt}=await K.storage.from("banner-images").upload(Je,ht,{upsert:!0});if(Lt)throw Lt;const{data:zt}=K.storage.from("banner-images").getPublicUrl(Je);I(zt.publicUrl),ge.success("Image uploaded!")}catch(qe){console.error(qe),ge.error("Failed to upload image")}finally{be(!1)}}},disabled:xe})}),xe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Or paste Image URL"}),e.jsx(Re,{value:A,onChange:Ze=>I(Ze.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Click-through Link (optional)"}),e.jsx(Re,{value:L,onChange:Ze=>F(Ze.target.value),placeholder:"https://example.com/landing-page"})]}),A&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:A,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),e.jsxs(Vs,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(_e,{children:"Quick Links"}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:Rt,children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),te.map((Ze,ht)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Re,{value:Ze.title,onChange:Ke=>fe(ht,"title",Ke.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Re,{value:Ze.url,onChange:Ke=>fe(ht,"url",Ke.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>Qe(ht),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]},ht)),te.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(Vs,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(_e,{children:"Polls"}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:at,children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ce.map((Ze,ht)=>e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(Re,{value:Ze.question,onChange:Ke=>rt(ht,Ke.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(tr,{value:Ze.poll_type,onValueChange:Ke=>je(ht,Ke),children:[e.jsx(Js,{className:"w-32",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"single",children:"Single"}),e.jsx(At,{value:"multi",children:"Multi-select"})]})]}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>We(ht),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Ze.options.map((Ke,qe)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:Ke,onChange:Je=>He(ht,qe,Je.target.value),placeholder:`Option ${qe+1}`}),Ze.options.length>2&&e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>ct(ht,qe),children:e.jsx(Cr,{className:"h-4 w-4 text-muted-foreground"})})]},qe)),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>mt(ht),children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},ht)),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(Z,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Z,{onClick:Ve,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(bs,{open:u,onOpenChange:f,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Results: ",g==null?void 0:g.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:ke.total})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:ke.dismissed})})]})]}),ye.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),ye.map(Ze=>e.jsxs(De,{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(ht=>{const Ke=Ze.results[ht.id]||0,qe=Ze.totalResponses>0?Math.round(Ke/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:ht.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[Ke," (",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}%`}})}),Ke>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ze.respondents||[]).filter(Je=>Je.optionId===ht.id).map((Je,Lt)=>e.jsx(nt,{variant:"secondary",className:"text-xs font-normal",children:Je.userName},Lt))})]},ht.id)})})]},Ze.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const dDt=()=>{const{user:t}=Qs(),{toast:s}=La(),r=ds(),[n,a]=M.useState(!1),[o,l]=M.useState(null),[i,d]=M.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,f]=M.useState(null),[g,v]=M.useState(""),{data:_=[],isLoading:b}=Tt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:L,error:F}=await K.from("additional_services").select("*").order("publish_date",{ascending:!1});if(F)throw F;return L}}),w=Bt({mutationFn:async L=>{let F=L.existingImageUrl;if(L.image){const q=L.image.name.split(".").pop(),H=`${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:U}=await K.storage.from("service-images").upload(H,L.image);if(U)throw U;const{data:Q}=K.storage.from("service-images").getPublicUrl(H);F=Q.publicUrl}const $={name:L.item.name,description:L.item.description||null,preview_image_url:F,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:q}=await K.from("additional_services").update($).eq("id",L.itemId);if(q)throw q}else{const{error:q}=await K.from("additional_services").insert($);if(q)throw q}},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"})}}),j=Bt({mutationFn:async L=>{const{error:F}=await K.from("additional_services").delete().eq("id",L);if(F)throw F},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=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),f(null),v(""),l(null)},S=L=>{l(L),d({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}),v(L.preview_image_url||""),a(!0)},A=L=>{var $;const F=($=L.target.files)==null?void 0:$[0];F&&(f(F),v(URL.createObjectURL(F)))},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}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ms,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(L=>L.is_published).length})})]})]}),e.jsxs(bs,{open:n,onOpenChange:L=>{a(L),L||N()},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{htmlFor:"name",children:"Name *"}),e.jsx(Re,{id:"name",value:i.name,onChange:L=>d({...i,name:L.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Wg,{content:i.description,onChange:L=>d({...i,description:L}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(Re,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:L=>d({...i,signup_link_url:L.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:i.publish_date,onChange:L=>d({...i,publish_date:L.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:L=>d({...i,is_published:L})}),e.jsx(_e,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),g?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:g,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(Z,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{f(null),v("")},children:e.jsx(Vr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(Xo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Re,{type:"file",accept:"image/*",onChange:A,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:b?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"})}):_.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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:_.map(L=>e.jsxs(ks,{children:[e.jsx(lt,{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(Xo,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(lt,{className:"font-medium",children:L.name}),e.jsx(lt,{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(un,{className:"h-3 w-3"}),"Link"]})}),e.jsx(lt,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(nt,{variant:L.is_published?"default":"secondary",children:L.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>S(L),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&j.mutate(L.id)},children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function uDt(){const{toast:t}=La(),[s,r]=M.useState([]),[n,a]=M.useState(!0),[o,l]=M.useState(!1),[i,d]=M.useState(!1),[u,f]=M.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});M.useEffect(()=>{g()},[]);const g=async()=>{try{const{data:j,error:N}=await K.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(N)throw N;r(j.coupons||[])}catch(j){console.error("Error fetching coupons:",j),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},v=async()=>{if(!u.name){t({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(u.discountType==="percent"&&!u.percentOff){t({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(u.discountType==="amount"&&!u.amountOff){t({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(u.duration==="repeating"&&!u.durationInMonths){t({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const j={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?j.percent_off=parseFloat(u.percentOff):(j.amount_off=Math.round(parseFloat(u.amountOff)*100),j.currency="usd"),u.duration==="repeating"&&(j.duration_in_months=parseInt(u.durationInMonths));const{data:N,error:S}=await K.functions.invoke("stripe-manage-coupons",{body:j});if(S)throw S;t({title:"Success",description:"Coupon created successfully"}),d(!1),f({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),g()}catch(j){console.error("Error creating coupon:",j),t({title:"Error",description:j.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async j=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:N}=await K.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:j}});if(N)throw N;t({title:"Success",description:"Coupon deleted successfully"}),g()}catch(N){console.error("Error deleting coupon:",N),t({title:"Error",description:N.message||"Failed to delete coupon",variant:"destructive"})}},b=j=>j.percent_off?`${j.percent_off}% off`:j.amount_off?`$${(j.amount_off/100).toFixed(2)} off`:"N/A",w=j=>{switch(j.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${j.duration_in_months} months`;default:return j.duration}};return e.jsx(Ms,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(bs,{open:i,onOpenChange:d,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create New Coupon"}),e.jsx(Kr,{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(_e,{children:"Promotion Code (what users will type)"}),e.jsx(Re,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:j=>f({...u,promotionCode:j.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Coupon Name (internal label)"}),e.jsx(Re,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:j=>f({...u,name:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Discount Type"}),e.jsxs(tr,{value:u.discountType,onValueChange:j=>{const N=j==="amount"&&u.duration==="forever"?"once":u.duration;f({...u,discountType:j,duration:N})},children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(c5,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(At,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(Uc,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:j=>f({...u,percentOff:j.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{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(Re,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:u.amountOff,onChange:j=>f({...u,amountOff:j.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Duration"}),e.jsxs(tr,{value:u.duration,onValueChange:j=>f({...u,duration:j}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"once",children:"Once (first payment only)"}),e.jsx(At,{value:"repeating",children:"Multiple months"}),e.jsxs(At,{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(_e,{children:"Number of Months"}),e.jsx(Re,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:j=>f({...u,durationInMonths:j.target.value})})]}),e.jsx(Z,{onClick:v,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Active Coupons"}),e.jsx(_r,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Rs,{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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:s.map(j=>{var N;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-mono font-medium",children:((N=j.promotion_codes)==null?void 0:N.length)>0?j.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(lt,{children:j.name||"-"}),e.jsx(lt,{children:b(j)}),e.jsx(lt,{children:w(j)}),e.jsx(lt,{children:j.times_redeemed}),e.jsx(lt,{children:e.jsx(nt,{variant:j.valid?"default":"secondary",children:j.valid?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>_(j.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})})]},j.id)})})]})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"How to Use Coupons"})}),e.jsxs(Oe,{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"1. Create a coupon above with your desired discount."}),e.jsx("p",{children:'2. Share the coupon code (shown in the "Code" column) with users.'}),e.jsx("p",{children:"3. Users can enter the code during checkout to receive the discount."}),e.jsx("p",{children:"4. Alternatively, you can create a promotion code in Stripe dashboard for public-facing promotions."})]})]})]})})}const bme={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 hDt(){const[t,s]=M.useState(""),[r,n]=M.useState("all"),[a,o]=M.useState(null),{data:l,isLoading:i,refetch:d}=Tt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:b,error:w}=await K.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(w)throw w;return b}}),{data:u}=Tt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:b,error:w}=await K.from("brokerages").select("*").order("name");if(w)throw w;return await Promise.all((b||[]).map(async N=>{const{data:S}=await K.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",N.id),{data:A}=await K.from("user_roles").select("user_id").eq("role","brokerage_manager"),I=(A==null?void 0:A.map($=>$.user_id))||[],L=(S==null?void 0:S.filter($=>I.includes($.id)))||[],F=(S==null?void 0:S.length)||0;return{...N,managers:L,agentCount:F}}))}}),f=b=>{if(b.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(b.brokerage_id&&!b.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(b.is_trial&&b.trial_expires_at)return new Date(b.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(b.subscription_status==="active"||b.subscription_status==="trialing"){const w=bme[b.subscription_product_id];return{status:(w==null?void 0:w.name)||"Active",badge:b.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return b.subscription_status==="canceled"||b.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},g=l==null?void 0:l.filter(b=>{var j,N;if(!(((j=b.name)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||((N=b.email)==null?void 0:N.toLowerCase().includes(t.toLowerCase()))))return!1;switch(f(b),r){case"active":return b.subscription_status==="active";case"trialing":return b.subscription_status==="trialing"||b.is_trial&&new Date(b.trial_expires_at)>new Date;case"grandfathered":return b.is_grandfathered;case"brokerage":return b.brokerage_id&&!b.subscription_product_id&&!b.is_grandfathered;case"expired":return b.subscription_status==="canceled"||b.subscription_status==="past_due"||b.is_trial&&new Date(b.trial_expires_at)<=new Date;case"none":return!b.subscription_status||b.subscription_status==="none";default:return!0}}),v={totalUsers:(l==null?void 0:l.length)||0,activeSubscriptions:(l==null?void 0:l.filter(b=>b.subscription_status==="active").length)||0,trials:(l==null?void 0:l.filter(b=>b.subscription_status==="trialing"||b.is_trial&&new Date(b.trial_expires_at)>new Date).length)||0,grandfathered:(l==null?void 0:l.filter(b=>b.is_grandfathered).length)||0,brokerageMembers:(l==null?void 0:l.filter(b=>b.brokerage_id&&!b.subscription_product_id&&!b.is_grandfathered).length)||0,individualSubscribers:(l==null?void 0:l.filter(b=>b.subscription_status==="active"&&b.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(l==null?void 0:l.filter(b=>b.subscription_status==="active"&&(b.subscription_product_id==="prod_Tc08MupgoVySDG"||b.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},_=b=>{window.open(`https://dashboard.stripe.com/customers/${b}`,"_blank")};return e.jsx(Ms,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(Z,{onClick:()=>d(),variant:"outline",size:"sm",children:[e.jsx(Ao,{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(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xr,{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:v.totalUsers})]})}),e.jsx(De,{className:"border-green-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cp,{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:v.activeSubscriptions})]})}),e.jsx(De,{className:"border-blue-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{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:v.trials})]})}),e.jsx(De,{className:"border-purple-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dh,{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:v.grandfathered})]})}),e.jsx(De,{className:"border-orange-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_a,{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:v.brokerageMembers})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J1,{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:v.individualSubscribers})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_a,{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:v.brokerageSubscribers})]})})]}),e.jsxs(Ia,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"users",children:"All Users"}),e.jsx(Ts,{value:"brokerages",children:"Brokerages"})]}),e.jsxs(Vs,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:t,onChange:b=>s(b.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:r,onValueChange:b=>n(b),children:[e.jsx(Js,{className:"w-[200px]",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Users"}),e.jsx(At,{value:"active",children:"Active Subscriptions"}),e.jsx(At,{value:"trialing",children:"Trials"}),e.jsx(At,{value:"grandfathered",children:"Grandfathered"}),e.jsx(At,{value:"brokerage",children:"Brokerage Members"}),e.jsx(At,{value:"expired",children:"Expired/Canceled"}),e.jsx(At,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:i?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(g==null?void 0:g.length)===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):g==null?void 0:g.map(b=>{var N,S;const w=f(b),j=bme[b.subscription_product_id];return e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:b.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:b.email})]})}),e.jsx(lt,{children:e.jsx(nt,{variant:w.variant,children:w.badge})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm",children:b.is_grandfathered?"Legacy Access":b.brokerage_id&&!b.subscription_product_id?"Brokerage Subscription":(j==null?void 0:j.name)||w.status})}),e.jsx(lt,{children:(N=b.brokerages)!=null&&N.name?e.jsx("span",{className:"text-sm",children:b.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(lt,{children:b.subscription_end_date?e.jsx("span",{className:"text-sm",children:js(new Date(b.subscription_end_date),"MMM d, yyyy")}):b.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",js(new Date(b.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b.stripe_customer_id&&e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>_(b.stripe_customer_id),children:e.jsx(un,{className:"h-4 w-4"})}),e.jsxs(bs,{children:[e.jsx(Si,{asChild:!0,children:e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>o(b),children:"Details"})}),e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Subscription Details"}),e.jsxs(Kr,{children:[b.name," (",b.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(nt,{variant:w.variant,className:"mt-1",children:w.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:b.is_grandfathered?"Grandfathered (Legacy)":b.brokerage_id&&!b.subscription_product_id?"Brokerage Subscription":(j==null?void 0:j.name)||"None"})]}),b.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((S=b.brokerages)==null?void 0:S.name)||"Unknown"})]}),b.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:js(new Date(b.subscription_end_date),"MMMM d, yyyy")})]}),b.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:js(new Date(b.trial_expires_at),"MMMM d, yyyy")})]}),b.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:b.stripe_customer_id})]})]}),b.stripe_customer_id&&e.jsxs(Z,{className:"w-full",onClick:()=>_(b.stripe_customer_id),children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},b.id)})})]})})})]}),e.jsx(Vs,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:u==null?void 0:u.map(b=>{var j,N;const w=(j=b.managers)==null?void 0:j.some(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(De,{children:[e.jsx($t,{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(_a,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-lg",children:b.name}),e.jsxs(_r,{children:[b.agentCount," agents"]})]})]}),e.jsx(nt,{variant:w?"default":"outline",children:w?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Oe,{children:((N=b.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:"}),b.managers.map(S=>{const A=bme[S.subscription_product_id];return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.email})]}),e.jsx("div",{className:"text-right",children:A?e.jsxs("div",{children:[e.jsx(nt,{variant:"default",children:A.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:A.price})]}):e.jsx(nt,{variant:"outline",children:"No Subscription"})})]},S.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},b.id)})})})]})]})})}function mDt(){const[t,s]=M.useState([]),[r,n]=M.useState(!0),[a,o]=M.useState(""),[l,i]=M.useState("all"),[d,u]=M.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});M.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:b,error:w}=await K.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(w)throw w;s(b||[]);const j=(b==null?void 0:b.filter(A=>A.status==="qualified").length)||0,N=(b==null?void 0:b.filter(A=>A.status==="pending").length)||0,S=(b==null?void 0:b.filter(A=>A.status==="cancelled").length)||0;u({total:(b==null?void 0:b.length)||0,qualified:j,pending:N,cancelled:S,totalDiscounts:j*25})}catch(b){console.error("Error fetching referrals:",b),ge.error("Failed to load referrals")}finally{n(!1)}},g=async()=>{try{ge.loading("Processing qualifications...");const{error:b}=await K.functions.invoke("process-referral-qualifications");if(b)throw b;ge.dismiss(),ge.success("Qualifications processed successfully"),f()}catch(b){ge.dismiss(),console.error("Error processing qualifications:",b),ge.error("Failed to process qualifications")}},v=t.filter(b=>{var N,S,A,I,L,F;const w=((S=(N=b.referrer_brokerage)==null?void 0:N.name)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((I=(A=b.referred_brokerage)==null?void 0:A.name)==null?void 0:I.toLowerCase().includes(a.toLowerCase()))||((F=(L=b.referred_user)==null?void 0:L.email)==null?void 0:F.toLowerCase().includes(a.toLowerCase())),j=l==="all"||b.status===l;return w&&j}),_=b=>{switch(b){case"qualified":return e.jsxs(nt,{className:"bg-green-100 text-green-800",children:[e.jsx(hi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(nt,{variant:"secondary",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(nt,{variant:"destructive",children:[e.jsx(bc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(nt,{children:b})}};return e.jsx(Ms,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(Z,{onClick:g,variant:"outline",children:[e.jsx(Ao,{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(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hi,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.pending}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bc,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.cancelled}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Uc,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",d.totalDiscounts]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Discounts"})]})]})})})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"All Referrals"}),e.jsx(_r,{children:"View and manage all referral relationships"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by brokerage or email...",value:a,onChange:b=>o(b.target.value),className:"pl-10"})]}),e.jsxs(tr,{value:l,onValueChange:i,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),e.jsx(At,{value:"pending",children:"Pending"}),e.jsx(At,{value:"qualified",children:"Qualified"}),e.jsx(At,{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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:v.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):v.map(b=>{var w,j,N,S;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:((w=b.referrer_brokerage)==null?void 0:w.name)||"Unknown"}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((j=b.referred_brokerage)==null?void 0:j.name)||((N=b.referred_user)==null?void 0:N.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(S=b.referred_user)==null?void 0:S.email})]})}),e.jsx(lt,{children:js(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(lt,{children:_(b.status)}),e.jsx(lt,{children:b.qualified_date?js(new Date(b.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(lt,{children:b.discount_applied?e.jsx(nt,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},b.id)})})]})]})]})]})})}const wme=[{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"}],pDt=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function fDt(){const[t,s]=M.useState([]),[r,n]=M.useState(!0),[a,o]=M.useState(!1),[l,i]=M.useState(null),[d,u]=M.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});M.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:S,error:A}=await K.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(A)throw A;s(S||[])}catch(S){console.error("Error fetching checklist items:",S),ge.error("Failed to load checklist items")}finally{n(!1)}},g=()=>{i(null),u({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},v=S=>{i(S),u({title:S.title,description:S.description||"",action_type:S.action_type,target_role:S.target_role,is_active:S.is_active}),o(!0)},_=async()=>{if(!d.title.trim()){ge.error("Title is required");return}try{if(l){const{error:S}=await K.from("onboarding_checklist_items").update({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active}).eq("id",l.id);if(S)throw S;ge.success("Checklist item updated")}else{const S=t.filter(I=>I.target_role===d.target_role).reduce((I,L)=>Math.max(I,L.sort_order),-1),{error:A}=await K.from("onboarding_checklist_items").insert({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active,sort_order:S+1});if(A)throw A;ge.success("Checklist item created")}o(!1),f()}catch(S){console.error("Error saving checklist item:",S),ge.error("Failed to save checklist item")}},b=async S=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:A}=await K.from("onboarding_checklist_items").delete().eq("id",S);if(A)throw A;ge.success("Checklist item deleted"),f()}catch(A){console.error("Error deleting checklist item:",A),ge.error("Failed to delete checklist item")}},w=async S=>{try{const{error:A}=await K.from("onboarding_checklist_items").update({is_active:!S.is_active}).eq("id",S.id);if(A)throw A;ge.success(S.is_active?"Item deactivated":"Item activated"),f()}catch(A){console.error("Error toggling item:",A),ge.error("Failed to update item")}},j=t.filter(S=>S.target_role==="brokerage_manager"),N=t.filter(S=>S.target_role==="agent");return e.jsxs(Ms,{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(Z,{onClick:g,className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(nt,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Oe,{children:j.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:j.map((S,A)=>{var I;return e.jsxs(ks,{children:[e.jsx(lt,{className:"text-muted-foreground",children:A+1}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(lt,{children:e.jsx(nt,{variant:"outline",children:((I=wme.find(L=>L.value===S.action_type))==null?void 0:I.label)||S.action_type})}),e.jsx(lt,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>v(S),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>b(S.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(nt,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Oe,{children:N.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:N.map((S,A)=>{var I;return e.jsxs(ks,{children:[e.jsx(lt,{className:"text-muted-foreground",children:A+1}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(lt,{children:e.jsx(nt,{variant:"outline",children:((I=wme.find(L=>L.value===S.action_type))==null?void 0:I.label)||S.action_type})}),e.jsx(lt,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>v(S),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>b(S.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]})]}),e.jsx(bs,{open:a,onOpenChange:o,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:d.title,onChange:S=>u({...d,title:S.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",value:d.description,onChange:S=>u({...d,description:S.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Target Role"}),e.jsxs(tr,{value:d.target_role,onValueChange:S=>u({...d,target_role:S}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:pDt.map(S=>e.jsx(At,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Action Type"}),e.jsxs(tr,{value:d.action_type,onValueChange:S=>u({...d,action_type:S}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:wme.map(S=>e.jsx(At,{value:S.value,children:S.label},S.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:d.is_active,onCheckedChange:S=>u({...d,is_active:S})}),e.jsx(_e,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(Z,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function gDt(){const[t,s]=M.useState(""),[r,n]=M.useState("all"),[a,o]=M.useState("name"),[l,i]=M.useState("asc"),[d,u]=M.useState(""),[f,g]=M.useState(""),[v,_]=M.useState(""),[b,w]=M.useState(""),{data:j}=Tt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:U,error:Q}=await K.from("brokerages").select("id, name").order("name");if(Q)throw Q;return U}}),N=async U=>{let se=[],te=0,Y=!0;for(;Y;){const{data:ce,error:oe}=await U(te,te+1e3-1);if(oe)throw oe;ce&&ce.length>0?(se=[...se,...ce],te+=1e3,Y=ce.length===1e3):Y=!1}return se},{data:S,isLoading:A}=Tt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const U=await N((Fe,Ie)=>K.from("profiles").select("id, name, email, brokerage_id, created_at").range(Fe,Ie)),{data:Q}=await K.from("brokerages").select("id, name"),se=new Map((Q==null?void 0:Q.map(Fe=>[Fe.id,Fe.name]))||[]),[{data:te},{data:Y},{data:ce},{data:oe},{data:le},{data:de},{data:xe}]=await Promise.all([K.rpc("get_admin_contact_counts"),K.rpc("get_admin_video_counts"),K.rpc("get_admin_popby_counts"),K.rpc("get_admin_listing_counts"),K.rpc("get_admin_deal_counts"),K.rpc("get_admin_portal_counts"),K.rpc("get_admin_sendable_card_counts")]),be=new Map;te==null||te.forEach(Fe=>be.set(Fe.owner_user_id,Fe.contact_count));const ye=new Map;Y==null||Y.forEach(Fe=>ye.set(Fe.owner_user_id,Fe.video_count));const ve=new Map;ce==null||ce.forEach(Fe=>ve.set(Fe.owner_user_id,Fe.popby_count));const ke=new Map;oe==null||oe.forEach(Fe=>ke.set(Fe.agent_id,Fe.listing_count));const Ge=new Map;le==null||le.forEach(Fe=>Ge.set(Fe.owner_user_id,Fe.deal_count));const Ne=new Map;de==null||de.forEach(Fe=>Ne.set(Fe.owner_user_id,{total:Fe.portal_count,active:Fe.active_portal_count}));const Ae=new Map;return xe==null||xe.forEach(Fe=>Ae.set(Fe.owner_user_id,{total:Fe.card_count,sent:Fe.sent_card_count,views:Fe.total_card_views})),U.map(Fe=>{const Ie=Ne.get(Fe.id),Ve=Ae.get(Fe.id);return{id:Fe.id,name:Fe.name||"Unknown",email:Fe.email||"",brokerage_id:Fe.brokerage_id,brokerage_name:Fe.brokerage_id&&se.get(Fe.brokerage_id)||null,contact_count:be.get(Fe.id)||0,video_count:ye.get(Fe.id)||0,popby_count:ve.get(Fe.id)||0,listing_count:ke.get(Fe.id)||0,deal_count:Ge.get(Fe.id)||0,portal_count:(Ie==null?void 0:Ie.total)||0,active_portal_count:(Ie==null?void 0:Ie.active)||0,card_count:(Ve==null?void 0:Ve.total)||0,sent_card_count:(Ve==null?void 0:Ve.sent)||0,total_card_views:(Ve==null?void 0:Ve.views)||0,created_at:Fe.created_at}})}}),I=M.useMemo(()=>{if(!S)return[];let U=S.filter(Q=>{const se=t.toLowerCase(),te=!t||Q.name.toLowerCase().includes(se)||Q.email.toLowerCase().includes(se),Y=r==="all"||r==="none"&&!Q.brokerage_id||Q.brokerage_id===r,ce=parseInt(d)||0,oe=parseInt(f)||0,le=parseInt(v)||0,de=parseInt(b)||0,xe=Q.contact_count>=ce&&Q.video_count>=oe&&Q.popby_count>=le&&Q.listing_count>=de;return te&&Y&&xe});return U.sort((Q,se)=>{let te=0;return a==="name"?te=Q.name.localeCompare(se.name):te=Q[a]-se[a],l==="asc"?te:-te}),U},[S,t,r,a,l,d,f,v,b]),L=U=>{a===U?i(l==="asc"?"desc":"asc"):(o(U),i("desc"))},F=()=>{const U=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],Q=I.map(oe=>[oe.name,oe.email,oe.brokerage_name||"None",oe.contact_count,oe.video_count,oe.popby_count,oe.listing_count,oe.deal_count,`${oe.portal_count} (${oe.active_portal_count})`,oe.card_count,oe.sent_card_count,oe.total_card_views]),se=[U.join(","),...Q.map(oe=>oe.map(le=>`"${le}"`).join(","))].join(` `),te=new Blob([se],{type:"text/csv"}),Y=URL.createObjectURL(te),ce=document.createElement("a");ce.href=Y,ce.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ce.click(),URL.revokeObjectURL(Y)},$=M.useMemo(()=>I.length?I.reduce((U,Q)=>({contacts:U.contacts+Q.contact_count,videos:U.videos+Q.video_count,popbys:U.popbys+Q.popby_count,listings:U.listings+Q.listing_count,deals:U.deals+Q.deal_count,portals:U.portals+Q.portal_count,activePortals:U.activePortals+Q.active_portal_count,cards:U.cards+Q.card_count,sentCards:U.sentCards+Q.sent_card_count,cardViews:U.cardViews+Q.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]),q=M.useMemo(()=>I.length?{portals:I.filter(U=>U.portal_count>0).length,cards:I.filter(U=>U.card_count>0).length}:{portals:0,cards:0},[I]),H=({field:U,children:Q})=>e.jsx(kt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(U),children:e.jsxs("div",{className:"flex items-center gap-1",children:[Q,e.jsx($c,{className:`h-3 w-3 ${a===U?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(HN,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(De,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(g0,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:$.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Portals"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(De,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ar,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:$.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Created"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.sentCards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Sent"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:$.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(_r,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:F,children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-6",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:t,onChange:U=>s(U.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsxs(Js,{children:[e.jsx(_a,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(rr,{placeholder:"Brokerage"})]}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Brokerages"}),e.jsx(At,{value:"none",children:"No Brokerage"}),j==null?void 0:j.map(U=>e.jsx(At,{value:U.id,children:U.name},U.id))]})]})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min contacts",value:d,onChange:U=>u(U.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min videos",value:f,onChange:U=>g(U.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min popbys",value:v,onChange:U=>_(U.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:$.contacts.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.videos.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Videos"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.popbys.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Popbys"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.listings.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Listings"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.deals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{className:"bg-blue-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.portals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Portals"})]}),e.jsxs("div",{className:"bg-violet-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),A?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Rs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(H,{field:"name",children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Brokerage"}),e.jsx(H,{field:"contact_count",children:"Contacts"}),e.jsx(H,{field:"video_count",children:"Videos"}),e.jsx(H,{field:"popby_count",children:"Popbys"}),e.jsx(H,{field:"listing_count",children:"Listings"}),e.jsx(H,{field:"deal_count",children:"Deals"}),e.jsx(H,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(g0,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(H,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ar,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Ln,{children:I.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):I.map(U=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:U.name}),e.jsx(lt,{className:"text-muted-foreground",children:U.email}),e.jsx(lt,{children:U.brokerage_name?e.jsx(nt,{variant:"secondary",children:U.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{children:e.jsx(nt,{variant:U.contact_count>0?"default":"outline",children:U.contact_count})}),e.jsx(lt,{children:e.jsx(nt,{variant:U.video_count>0?"default":"outline",children:U.video_count})}),e.jsx(lt,{children:e.jsx(nt,{variant:U.popby_count>0?"default":"outline",children:U.popby_count})}),e.jsx(lt,{children:e.jsx(nt,{variant:U.listing_count>0?"default":"outline",children:U.listing_count})}),e.jsx(lt,{children:e.jsx(nt,{variant:U.deal_count>0?"default":"outline",children:U.deal_count})}),e.jsx(lt,{children:U.portal_count>0?e.jsxs(Mu,{children:[e.jsx(Tu,{children:e.jsxs(nt,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[U.portal_count,U.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",U.active_portal_count," active)"]})]})}),e.jsxs(au,{children:[e.jsxs("p",{children:[U.portal_count," total portals"]}),e.jsxs("p",{children:[U.active_portal_count," currently active"]})]})]}):e.jsx(nt,{variant:"outline",children:"0"})}),e.jsx(lt,{children:U.card_count>0?e.jsxs(Mu,{children:[e.jsx(Tu,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(nt,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:U.card_count}),U.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(Pa,{className:"h-3 w-3"}),U.sent_card_count]}),U.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(Na,{className:"h-3 w-3"}),U.total_card_views]})]})}),e.jsxs(au,{children:[e.jsxs("p",{children:[U.card_count," cards created"]}),e.jsxs("p",{children:[U.sent_card_count," sent"]}),e.jsxs("p",{children:[U.total_card_views," total views"]})]})]}):e.jsx(nt,{variant:"outline",children:"0"})})]},U.id))})]})})]})]})]})})}function xDt(){La(),ds();const[t,s]=M.useState("user-analytics"),{data:r}=Tt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:_,error:b}=await K.from("feature_flags").select("*").order("key");if(b)throw b;return _}}),{data:n,isLoading:a}=Tt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:_,error:b}=await K.from("relationship_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:o,isLoading:l}=Tt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:_,error:b}=await K.from("action_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:i,isLoading:d}=Tt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:_,error:b}=await K.from("action_scripts").select("*, action_type:action_types(*)");if(b)throw b;return _}}),{data:u,isLoading:f}=Tt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:b}=await K.from("touchpoint_plans").select("*").order("name");if(b)throw b;return _}}),{data:g,isLoading:v}=Tt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:_,error:b}=await K.from("popby_items").select("*").is("owner_user_id",null).order("name");if(b)throw b;return _}});return e.jsx(Ms,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(Ia,{value:t,onValueChange:s,children:[e.jsxs(Aa,{className:"grid w-full grid-cols-9",children:[e.jsxs(Ts,{value:"user-analytics",className:"gap-2",children:[e.jsx(ol,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(Ts,{value:"relationship-types",className:"gap-2",children:[e.jsx(xr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(Ts,{value:"action-types",className:"gap-2",children:[e.jsx(ga,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(Ts,{value:"scripts",className:"gap-2",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(Ts,{value:"video-scripts",className:"gap-2",children:[e.jsx(eu,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(Ts,{value:"plans",className:"gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(Ts,{value:"popbys",className:"gap-2",children:[e.jsx(uo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(Ts,{value:"settings",className:"gap-2",children:[e.jsx(Pl,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(Ts,{value:"feature-flags",className:"gap-2",children:[e.jsx(v0,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(Vs,{value:"user-analytics",className:"mt-6",children:e.jsx(gDt,{})}),e.jsx(Vs,{value:"relationship-types",className:"mt-6",children:e.jsx(yDt,{types:n||[],isLoading:a})}),e.jsx(Vs,{value:"action-types",className:"mt-6",children:e.jsx(vDt,{types:o||[],isLoading:l})}),e.jsx(Vs,{value:"scripts",className:"mt-6",children:e.jsx(_Dt,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(Vs,{value:"video-scripts",className:"mt-6",children:e.jsx(kDt,{})}),e.jsx(Vs,{value:"plans",className:"mt-6",children:e.jsx(bDt,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:f})}),e.jsx(Vs,{value:"popbys",className:"mt-6",children:e.jsx(jDt,{items:g||[],isLoading:v})}),e.jsx(Vs,{value:"settings",className:"mt-6",children:e.jsx(NDt,{})}),e.jsx(Vs,{value:"feature-flags",className:"mt-6",children:e.jsx(wDt,{flags:r||[]})})]})]})})}function yDt({types:t,isLoading:s}){const{toast:r}=La(),n=ds(),[a,o]=M.useState(null),[l,i]=M.useState(!1),d=Bt({mutationFn:async f=>{if(f.id){const{error:g}=await K.from("relationship_types").update({name:f.name,description:f.description,icon:f.icon}).eq("id",f.id);if(g)throw g}else{const{error:g}=await K.from("relationship_types").insert([{name:f.name,description:f.description,icon:f.icon,sort_order:t.length}]);if(g)throw g}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),u=async f=>{await K.from("relationship_types").update({active:!f.active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Relationship Types"}),e.jsx(_r,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(Z,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Rs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:t.map(f=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsx(Rh,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(lt,{className:"font-medium",children:f.name}),e.jsx(lt,{className:"text-muted-foreground",children:f.description}),e.jsx(lt,{children:e.jsx(qr,{checked:f.active,onCheckedChange:()=>u(f)})}),e.jsx(lt,{children:e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Ga,{className:"h-4 w-4"})})})]},f.id))})]})}),e.jsx(bs,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.currentTarget);d.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description"),icon:g.get("icon")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"icon",children:"Icon"}),e.jsx(Re,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function vDt({types:t,isLoading:s}){const{toast:r}=La(),n=ds(),[a,o]=M.useState(null),[l,i]=M.useState(!1),d=Bt({mutationFn:async f=>{if(f.id){const{error:g}=await K.from("action_types").update({name:f.name,description:f.description,icon:f.icon,color:f.color}).eq("id",f.id);if(g)throw g}else{const{error:g}=await K.from("action_types").insert([{name:f.name,description:f.description,icon:f.icon,color:f.color,sort_order:t.length}]);if(g)throw g}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),u=async f=>{await K.from("action_types").update({active:!f.active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Action Types"}),e.jsx(_r,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(Z,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Rs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:t.map(f=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:f.name}),e.jsx(lt,{className:"text-muted-foreground",children:f.description}),e.jsx(lt,{children:f.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:f.color}})}),e.jsx(lt,{children:e.jsx(qr,{checked:f.active,onCheckedChange:()=>u(f)})}),e.jsx(lt,{children:e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Ga,{className:"h-4 w-4"})})})]},f.id))})]})}),e.jsx(bs,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.currentTarget);d.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description"),icon:g.get("icon"),color:g.get("color")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"icon",children:"Icon"}),e.jsx(Re,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"color",children:"Color"}),e.jsx(Re,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function _Dt({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=La(),a=ds(),[o,l]=M.useState(null),[i,d]=M.useState(!1),u=Bt({mutationFn:async g=>{if(g.id){const{error:v}=await K.from("action_scripts").update({title:g.title,action_type_id:g.action_type_id,tone:g.tone,script_body:g.script_body,active:g.active}).eq("id",g.id);if(v)throw v}else{const{error:v}=await K.from("action_scripts").insert([{title:g.title,action_type_id:g.action_type_id,tone:g.tone,script_body:g.script_body,active:!0}]);if(v)throw v}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),d(!1),l(null),n({title:"Saved successfully"})},onError:g=>{n({title:"Error",description:g.message,variant:"destructive"})}}),f=Bt({mutationFn:async g=>{const{error:v}=await K.from("action_scripts").delete().eq("id",g);if(v)throw v},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Script Library"}),e.jsx(_r,{children:"Create and manage scripts for each action type"})]}),e.jsxs(Z,{onClick:()=>{l(null),d(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Rs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:t.map(g=>{var v;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:g.title}),e.jsx(lt,{children:e.jsx(nt,{variant:"outline",children:((v=g.action_type)==null?void 0:v.name)||"Unknown"})}),e.jsx(lt,{className:"text-muted-foreground",children:g.tone}),e.jsx(lt,{children:e.jsx(nt,{variant:g.active?"default":"secondary",children:g.active?"Active":"Inactive"})}),e.jsxs(lt,{className:"flex gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{l(g),d(!0)},children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>f.mutate(g.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})]},g.id)})})]})}),e.jsx(bs,{open:i,onOpenChange:d,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:g=>{g.preventDefault();const v=new FormData(g.currentTarget);u.mutate({id:o==null?void 0:o.id,title:v.get("title"),action_type_id:v.get("action_type_id"),tone:v.get("tone"),script_body:v.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(_e,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(tr,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select action type"})}),e.jsx(er,{children:s.map(g=>e.jsx(At,{value:g.id,children:g.name},g.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(Re,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Lr,{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(qn,{className:"mt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function bDt({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=La(),o=ds(),[l,i]=M.useState(null),[d,u]=M.useState(!1),[f,g]=M.useState(null),[v,_]=M.useState(!1),[b,w]=M.useState(null),[j,N]=M.useState(null),{data:S}=Tt({queryKey:["plan-items",f],queryFn:async()=>{if(!f)return[];const{data:H,error:U}=await K.from("touchpoint_plan_items").select("*").eq("plan_id",f).order("month_number");if(U)throw U;return H},enabled:!!f}),A=Bt({mutationFn:async H=>{if(H.id){const{error:U}=await K.from("touchpoint_plans").update({name:H.name,description:H.description,active:H.active}).eq("id",H.id);if(U)throw U}else{const{error:U}=await K.from("touchpoint_plans").insert([{name:H.name,description:H.description,active:!0}]);if(U)throw U}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:H=>{a({title:"Error",description:H.message,variant:"destructive"})}}),I=Bt({mutationFn:async H=>{if(H.id){const{error:U}=await K.from("touchpoint_plan_items").update({action_type_id:H.action_type_id,default_script_id:H.default_script_id,notes:H.notes}).eq("id",H.id);if(U)throw U}else{const{error:U}=await K.from("touchpoint_plan_items").insert([{plan_id:H.plan_id,month_number:H.month_number,action_type_id:H.action_type_id,default_script_id:H.default_script_id,notes:H.notes}]);if(U)throw U}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",f]}),a({title:"Item saved"})}}),L=Bt({mutationFn:async H=>{const{error:U}=await K.from("touchpoint_plan_items").delete().eq("id",H);if(U)throw U},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",f]})}}),F=Bt({mutationFn:async H=>{const{data:U,error:Q}=await K.from("action_scripts").insert([{...H,active:!0}]).select().single();if(Q)throw Q;return U},onSuccess:async H=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),b&&await I.mutateAsync({id:b.itemId,plan_id:f,month_number:b.month,action_type_id:b.actionTypeId,default_script_id:H.id}),_(!1),w(null),a({title:"Script created and assigned"})},onError:H=>{a({title:"Error",description:H.message,variant:"destructive"})}}),$=(H,U,Q)=>{w({month:H,actionTypeId:U,itemId:Q}),_(!0)},q=H=>r.find(U=>U.id===H);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Touchpoint Plans"}),e.jsx(_r,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(Z,{onClick:()=>{i(null),u(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Rs,{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(H=>e.jsxs(De,{className:`cursor-pointer transition-colors ${f===H.id?"border-primary":""}`,onClick:()=>g(H.id),children:[e.jsx($t,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Vt,{className:"text-base",children:H.name}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:U=>{U.stopPropagation(),i(H),u(!0)},children:e.jsx(Ga,{className:"h-4 w-4"})})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:H.description}),e.jsx(nt,{variant:H.active?"default":"secondary",className:"mt-2",children:H.active?"Active":"Inactive"})]})]},H.id))})})]}),f&&e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Plan Schedule"}),e.jsx(_r,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(H,U)=>U+1).map(H=>{const U=S==null?void 0:S.find(te=>te.month_number===H),Q=U!=null&&U.default_script_id?q(U.default_script_id):null,se=r.filter(te=>te.action_type_id===(U==null?void 0:U.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 ",H]}),e.jsxs(tr,{value:(U==null?void 0:U.action_type_id)||"none",onValueChange:te=>{te==="none"&&U?L.mutate(U.id):te!=="none"&&I.mutate({id:U==null?void 0:U.id,plan_id:f,month_number:H,action_type_id:te,default_script_id:null})},children:[e.jsx(Js,{className:"w-40",children:e.jsx(rr,{placeholder:"No action"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No action"}),s.filter(te=>te.active).map(te=>e.jsx(At,{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))]})]}),U&&e.jsxs(e.Fragment,{children:[e.jsxs(tr,{value:U.default_script_id||"none",onValueChange:te=>{N(null),I.mutate({id:U.id,default_script_id:te==="none"?null:te})},children:[e.jsx(Js,{className:"w-56",children:e.jsx(rr,{placeholder:"Select script"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No default script"}),se.map(te=>e.jsxs(At,{value:te.id,children:[te.title," ",te.tone&&`(${te.tone})`]},te.id))]})]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>$(H,U.action_type_id,U.id),children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"}),"New Script"]}),Q&&e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>N((j==null?void 0:j.id)===Q.id?null:Q),children:(j==null?void 0:j.id)===Q.id?"Hide":"Preview"})]})]}),j&&(U==null?void 0:U.default_script_id)===j.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(nt,{variant:"outline",children:j.title}),j.tone&&e.jsx(nt,{variant:"secondary",children:j.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:j.script_body})]})]},H)})})})]}),e.jsx(bs,{open:d,onOpenChange:u,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:H=>{H.preventDefault();const U=new FormData(H.currentTarget);A.mutate({id:l==null?void 0:l.id,name:U.get("name"),description:U.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:A.isPending,children:[A.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(bs,{open:v,onOpenChange:_,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create New Script"}),e.jsxs(Kr,{children:["Create a script for Month ",b==null?void 0:b.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:H=>{H.preventDefault();const U=new FormData(H.currentTarget);F.mutate({title:U.get("title"),action_type_id:b.actionTypeId,tone:U.get("tone"),script_body:U.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(_e,{htmlFor:"script_title",children:"Title"}),e.jsx(Re,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_tone",children:"Tone"}),e.jsx(Re,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Lr,{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(qn,{className:"mt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:F.isPending,children:[F.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function wDt({flags:t}){const{toast:s}=La(),r=ds(),n=async(a,o)=>{const{error:l}=await K.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(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Feature Flags"}),e.jsx(_r,{children:"Control which features are enabled for members"})]}),e.jsx(Oe,{children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"Flag"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Notes"}),e.jsx(kt,{children:"Last Updated"})]})}),e.jsx(Ln,{children:t.map(a=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-mono text-sm",children:a.key}),e.jsx(lt,{children:e.jsx(qr,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(lt,{children:e.jsx(Re,{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(lt,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function jDt({items:t,isLoading:s}){const{toast:r}=La(),n=ds(),[a,o]=M.useState(null),[l,i]=M.useState(!1),d=Bt({mutationFn:async g=>{if(g.id){const{error:v}=await K.from("popby_items").update({name:g.name,description:g.description}).eq("id",g.id);if(v)throw v}else{const{error:v}=await K.from("popby_items").insert([{name:g.name,description:g.description,owner_user_id:null}]);if(v)throw v}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:g=>{r({title:"Error",description:g.message,variant:"destructive"})}}),u=async g=>{await K.from("popby_items").update({is_active:!g.is_active}).eq("id",g.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},f=async g=>{await K.from("popby_items").delete().eq("id",g),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Popby Ideas"}),e.jsx(_r,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(Z,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Rs,{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(uo,{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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:t.map(g=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:g.name}),e.jsx(lt,{className:"text-muted-foreground",children:g.description}),e.jsx(lt,{children:e.jsx(qr,{checked:g.is_active,onCheckedChange:()=>u(g)})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{o(g),i(!0)},children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>f(g.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},g.id))})]})}),e.jsx(bs,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:g=>{g.preventDefault();const v=new FormData(g.currentTarget);d.mutate({id:a==null?void 0:a.id,name:v.get("name"),description:v.get("description")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function kDt(){var _;const{toast:t}=La(),s=ds(),[r,n]=M.useState(null),[a,o]=M.useState(!1),{data:l,isLoading:i}=Tt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:b,error:w}=await K.from("video_script_categories").select("*").order("sort_order");if(w)throw w;return b}}),{data:d,isLoading:u}=Tt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:b,error:w}=await K.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(w)throw w;return b}}),f=Bt({mutationFn:async b=>{var w,j;if(b.id){const{error:N}=await K.from("video_scripts").update({title:b.title,script_text:b.script_text,category_id:b.category_id,tags:((w=b.tags)==null?void 0:w.split(",").map(S=>S.trim()).filter(Boolean))||[]}).eq("id",b.id);if(N)throw N}else{const{error:N}=await K.from("video_scripts").insert([{title:b.title,script_text:b.script_text,category_id:b.category_id||null,tags:((j=b.tags)==null?void 0:j.split(",").map(S=>S.trim()).filter(Boolean))||[]}]);if(N)throw N}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:b=>t({title:"Error",description:b.message,variant:"destructive"})}),g=async b=>{await K.from("video_scripts").update({is_active:!b.is_active}).eq("id",b.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},v=async b=>{confirm("Delete this video script?")&&(await K.from("video_scripts").delete().eq("id",b),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Video Scripts"}),e.jsx(_r,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(Z,{onClick:()=>{n(null),o(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Rs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:d==null?void 0:d.map(b=>{var w;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:b.title}),e.jsx(lt,{className:"text-muted-foreground",children:((w=b.category)==null?void 0:w.name)||"Uncategorized"}),e.jsx(lt,{children:e.jsx(qr,{checked:b.is_active,onCheckedChange:()=>g(b)})}),e.jsxs(lt,{className:"flex gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>{n(b),o(!0)},children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>v(b.id),children:e.jsx(Cr,{className:"h-4 w-4"})})]})]},b.id)})})]})}),e.jsx(bs,{open:a,onOpenChange:o,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault();const w=new FormData(b.currentTarget);f.mutate({id:r==null?void 0:r.id,title:w.get("title"),script_text:w.get("script_text"),category_id:w.get("category_id")||null,tags:w.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"category_id",children:"Category"}),e.jsxs(tr,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(er,{children:l==null?void 0:l.map(b=>e.jsx(At,{value:b.id,children:b.name},b.id))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Lr,{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(_e,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(Re,{id:"tags",name:"tags",defaultValue:((_=r==null?void 0:r.tags)==null?void 0:_.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:f.isPending,children:[f.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function NDt(){const{toast:t}=La(),[s,r]=M.useState(""),[n,a]=M.useState(!0),[o,l]=M.useState(!1);M.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await K.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 K.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(De,{children:e.jsx(Oe,{className:"flex justify-center py-8",children:e.jsx(Rs,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Pi,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(_r,{children:"Configure the map feature for popbys"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(Re,{id:"mapbox-token",placeholder:"pk.eyJ1I...",value:s,onChange:d=>r(d.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(Z,{onClick:i,disabled:o,children:[o&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(nt,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const SDt=()=>{const[t,s]=M.useState(""),[r,n]=M.useState("grid"),a=Or(),{data:o=[],isLoading:l}=Tt({queryKey:["additional-services"],queryFn:async()=>{const{data:d,error:u}=await K.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(u)throw u;return d}}),i=o.filter(d=>{var f;return d.name.toLowerCase().includes(t.toLowerCase())||((f=d.description)==null?void 0:f.toLowerCase().includes(t.toLowerCase()))});return e.jsx(Ms,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search services...",value:t,onChange:d=>s(d.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[t&&e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(hp,{className:"h-4 w-4"})}),e.jsx(Z,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Fh,{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((d,u)=>e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(gs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{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(Z,{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(d=>e.jsxs(De,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${r==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${d.id}`),children:[e.jsx("div",{className:`relative overflow-hidden bg-muted ${r==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:d.preview_image_url?e.jsx("img",{src:d.preview_image_url,alt:d.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(gn,{className:"h-8 w-8"})})}),e.jsxs(Oe,{className:`p-4 flex flex-col ${r==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:d.name}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:$ie(d.description)})]})]},d.id))})]})})},CDt=()=>{const{serviceId:t}=Uo(),s=Or(),{data:r,isLoading:n}=Tt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await K.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Ms,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(gs,{className:"h-8 w-48"}),e.jsx(gs,{className:"h-64 w-full rounded-lg"}),e.jsx(gs,{className:"h-24 w-full"})]})}):r?e.jsx(Ms,{title:r.name,children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(Z,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(Ba,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(De,{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(gn,{className:"h-16 w-16"})})})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(nn,{className:"h-4 w-4 mr-1"}),"Published ",js(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(Z,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(un,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Ms,{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(Z,{onClick:()=>s("/additional-services"),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},GA=[{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 MDt(){const[t,s]=M.useState(GA[0].id),r=GA.find(n=>n.id===t)||GA[0];return e.jsx(Ms,{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(Y4,{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(tr,{value:t,onValueChange:s,children:[e.jsx(Js,{className:"w-full",children:e.jsx(rr,{placeholder:"Select a tool"})}),e.jsx(er,{children:GA.map(n=>e.jsx(At,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(Ia,{value:t,onValueChange:s,className:"w-full",children:e.jsx(Aa,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:GA.map(n=>e.jsx(Ts,{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 OTe="agent-os-onboarding-completed",V8=[{icon:$x,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:Tm,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:xr,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:jc,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:uo,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:ol,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"]}],TDt=()=>{const[t,s]=M.useState(!1),[r,n]=M.useState(0),[a,o]=M.useState(!1);M.useEffect(()=>{if(!localStorage.getItem(OTe)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(OTe,"true"),s(!1)},u=V8[r],f=u.icon,g=r===V8.length-1,v=_=>{_||d(),s(_)};return e.jsx(bs,{open:t,onOpenChange:v,children:e.jsxs(_s,{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(f,{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(gn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(Cs,{className:"text-center sm:text-center pb-2",children:[e.jsx(Ss,{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(Kr,{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+b*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(ma,{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:V8.map((_,b)=>e.jsx("button",{onClick:()=>{b!==r&&(o(!0),setTimeout(()=>{n(b),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${b===r?"w-8 bg-gradient-to-r "+u.bgGradient:b{const{user:t}=Qs();return Tt({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},EDt=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=hl(new Date,n);await K.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await K.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"]}),dn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{dn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},PDt=()=>{const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),dn({title:"Snooze cancelled"})},onError:s=>{dn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},IDt=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function hle({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=M.useState(null),l=EDt(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=u=>js(hl(new Date,u),"MMM d, yyyy");return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Kr,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:IDt.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:It("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(nn,{className:"h-3.5 w-3.5"}),"Until ",d(u.days)]})]},u.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Z,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const LDt={Crown:Dh,FileText:Un,Users:xr,Globe:up,Star:Gn,Phone:ga,MessageSquare:ho,PenTool:Jk,Video:Cn,Gift:uo};function DDt({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=Or(),[d,u]=M.useState("name"),[f,g]=M.useState("asc"),[v,_]=M.useState(null),[b,w]=M.useState(""),j=L=>{d===L?g(F=>F==="asc"?"desc":"asc"):(u(L),g("asc"))},N=M.useMemo(()=>[...t].sort((L,F)=>{var q,H;let $=0;switch(d){case"name":{const U=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),Q=`${F.contact.first_name} ${F.contact.last_name||""}`.toLowerCase();$=U.localeCompare(Q);break}case"relationship_type":$=(L.relationshipTypeName||"").localeCompare(F.relationshipTypeName||"");break;case"action_type":$=(((q=L.actionType)==null?void 0:q.name)||"").localeCompare(((H=F.actionType)==null?void 0:H.name)||"");break;case"last_touch":$=(L.monthNumber||0)-(F.monthNumber||0);break}return f==="asc"?$:-$}),[t,d,f]),S=L=>LDt[L||"Phone"]||ga,A=({field:L,children:F})=>e.jsxs(Z,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>j(L),children:[F,d===L?f==="asc"?e.jsx(Rd,{className:"ml-2 h-4 w-4"}):e.jsx(Ku,{className:"ml-2 h-4 w-4"}):e.jsx($c,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(L,F,$)=>{_(L),w(`${F} ${$||""}`.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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{className:"bg-muted/50",children:[e.jsx(kt,{className:"w-[180px]",children:e.jsx(A,{field:"name",children:"Contact"})}),e.jsx(kt,{className:"w-[130px]",children:e.jsx(A,{field:"relationship_type",children:"Type"})}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(A,{field:"action_type",children:"Action"})}),e.jsx(kt,{className:"w-[130px]",children:"Phone"}),e.jsx(kt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Ln,{children:N.map((L,F)=>{var se,te,Y,ce,oe,le;const $=L.isSpecialDate,q=L.specialDateType,H=$?q==="birthday"?Lh:Hn:S(((se=L.actionType)==null?void 0:se.icon)||null),U=L.contact.phone,Q=L.contact.email;return e.jsxs(ks,{className:It("hover:bg-muted/50 transition-colors",$&&q==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",$&&q==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(lt,{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(lt,{children:L.relationshipTypeName?e.jsx(nt,{variant:"secondary",className:"text-xs",children:L.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:$?e.jsx(nt,{className:It("gap-1",q==="birthday"&&"bg-pink-500 hover:bg-pink-600",q==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:q==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Lh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Hn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(H,{className:"h-3 w-3"}),(te=L.actionType)==null?void 0:te.name]})})}),e.jsx(lt,{children:U?e.jsx("span",{className:"text-sm font-mono",children:L.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[U&&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(ga,{className:"h-3.5 w-3.5"})}),U&&e.jsx("a",{href:a(L.contact.phone,(Y=L.script)==null?void 0:Y.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(ho,{className:"h-3.5 w-3.5"})}),Q&&(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(Ar,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(L.contact.email,(ce=L.script)==null?void 0:ce.script_body,(oe=L.script)==null?void 0:oe.email_subject,(le=L.actionType)==null?void 0:le.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(Ar,{className:"h-3.5 w-3.5"})})),$&&e.jsxs("button",{onClick:()=>{const de=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,xe=q==="birthday"?"birthday":"home_anniversary",be=new URLSearchParams({cardType:xe,contactId:L.contact.id,name:de,...L.contact.address?{address:L.contact.address}:{},...q==="anniversary"&&L.contact.home_anniversary?{date:L.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${be.toString()}`)},className:It("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",q==="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 ${q==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(Ar,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(Z,{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(mp,{className:"h-3.5 w-3.5"})}),e.jsxs(Z,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var de;return s(L.contact.id,L.actionType.id,(de=L.script)==null?void 0:de.id)},disabled:n,children:[e.jsx(Ma,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${F}`)})})]})}),e.jsx(hle,{open:!!v,onOpenChange:L=>!L&&_(null),contactId:v||"",contactName:b})]})}function G0(){const{data:t,isLoading:s}=Tt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await K.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 ODt({onSelect:t}){const[s,r]=M.useState(null),{data:n=[],isLoading:a}=Tt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:d,error:u}=await K.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return d}}),{data:o=[],isLoading:l}=Tt({queryKey:["agent-email-templates",s],queryFn:async()=>{let d=K.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(d=d.eq("category_id",s));const{data:u,error:f}=await d;if(f)throw f;return u}}),i=n.find(d=>d.id===s);return a?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(Rs,{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(ec,{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(Rs,{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(Fi,{className:"max-h-[280px]",children:e.jsx("div",{className:"space-y-1",children:o.map(d=>e.jsxs("button",{onClick:()=>t(d),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:d.title}),d.tone&&e.jsx(nt,{variant:"secondary",className:"text-[10px] shrink-0",children:d.tone})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:d.subject})]},d.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(d=>e.jsxs("button",{onClick:()=>r(d.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:d.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.name}),d.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:d.description})]})]}),e.jsx(ei,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}const RDt=5*1024*1024,FDt=["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 zDt(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function BDt(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 KA(t,s){return 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())}function AL({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const d=!!n&&n.length>0,u=d?n:r?[r]:[],f=u[0],[g,v]=M.useState((f==null?void 0:f.email)||""),[_,b]=M.useState(a),[w,j]=M.useState(o),[N,S]=M.useState(!1),[A,I]=M.useState(!1),[L,F]=M.useState([]);M.useEffect(()=>{t&&(v((f==null?void 0:f.email)||""),b(KA(a,f||{first_name:""})),j(KA(o,f||{first_name:""})),I(!a&&!o),F([]))},[t,f,a,o]);const $=async te=>{const Y=te.target.files;if(!Y)return;const ce=L.reduce((le,de)=>le+de.size,0),oe=[];for(const le of Array.from(Y)){if(!FDt.includes(le.type)){ge.error(`${le.name}: Unsupported file type`);continue}if(ce+le.size>RDt){ge.error("Total attachments exceed 20MB limit");break}try{const de=await BDt(le);oe.push({name:le.name,type:le.type,size:le.size,data:de})}catch{ge.error(`Failed to read ${le.name}`)}}F(le=>[...le,...oe]),te.target.value=""},q=te=>{F(Y=>Y.filter((ce,oe)=>oe!==te))},H=te=>{b(KA(te.subject,f||{first_name:""})),j(KA(te.body,f||{first_name:""})),I(!1)},U=te=>te.split(/\n\n+/).map(Y=>`

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

`).join(""),Q=async te=>{if(!_||!w)return ge.error("Please fill in subject and message"),!1;const Y=KA(w,te),ce=U(Y);try{const{data:oe,error:le}=await K.functions.invoke("gmail-send",{body:{to:te.email,subject:_,body:ce,contactId:te.id,attachments:L.map(({name:de,type:xe,data:be})=>({name:de,type:xe,data:be}))}});if(le)throw le;if(!(oe!=null&&oe.success))throw new Error((oe==null?void 0:oe.error)||"Failed to send");return!0}catch(oe){return console.error("Gmail send error:",oe),ge.error("Failed to send to "+te.first_name+": "+(oe instanceof Error?oe.message:"Unknown error")),!1}},se=async()=>{if(!_||!w){ge.error("Please fill in subject and message");return}if(d&&u.length>50){ge.error("Maximum 50 recipients per bulk send");return}S(!0);try{if(d){let te=0;for(const Y of u)await Q(Y)&&te++,await new Promise(oe=>setTimeout(oe,100));ge.success(`Sent ${te} of ${u.length} emails`)}else await Q(f)&&ge.success("Email sent successfully!");s(!1),i==null||i()}catch(te){console.error("Bulk send error:",te),ge.error("Error sending emails")}finally{S(!1)}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Ar,{className:"h-5 w-5 text-red-500"}),d?`Send to ${u.length} Contacts`:"Compose Email"]}),l&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:l})]})]}),e.jsxs("div",{className:"space-y-4",children:[A?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(Un,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>I(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Vr,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(ODt,{onSelect:H})]}):e.jsxs(Z,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>I(!0),children:[e.jsx(Un,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(Jl,{}),e.jsx("div",{className:"space-y-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(_e,{children:"Recipients"}),e.jsx("div",{className:"bg-muted p-3 rounded-md space-y-1 max-h-24 overflow-y-auto text-muted-foreground",children:u.map(te=>e.jsxs("div",{className:"text-sm",children:[te.first_name," ",te.last_name," — ",te.email]},te.id))})]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{htmlFor:"gmail-to",children:"To"}),e.jsx(Re,{id:"gmail-to",value:g,onChange:te=>v(te.target.value),placeholder:"recipient@example.com"})]})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(Re,{id:"gmail-subject",value:_,onChange:te=>b(te.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(_e,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(nt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>j(te=>te+"{{first_name}}"),children:"{{first_name}}"}),e.jsx(nt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>j(te=>te+"{{last_name}}"),children:"{{last_name}}"})]})]}),e.jsx(Lr,{id:"gmail-body",value:w,onChange:te=>j(te.target.value),placeholder:"Write your message...",rows:10,className:"resize-y"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Z,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var te;return(te=document.getElementById("gmail-attachments"))==null?void 0:te.click()},disabled:N,children:[e.jsx(Qk,{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:$})]}),L.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:L.map((te,Y)=>e.jsxs(nt,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(Qk,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:te.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",zDt(te.size),")"]}),e.jsx("button",{type:"button",onClick:()=>q(Y),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Vr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>s(!1),disabled:N,children:"Cancel"}),e.jsxs(Z,{onClick:se,disabled:N||!_||!w,className:"gap-2",children:[N?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(Pa,{className:"h-4 w-4"}),N?"Sending...":d?`Send to ${u.length}`:"Send Email"]})]})]})]})})}function $Dt(){const t=Or(),{data:s}=Im(),{data:r}=Doe(),n=g_e(),{isGmailConnected:a,gmailEmail:o}=G0(),[l,i]=M.useState(null),[d,u]=M.useState(!1),[f,g]=M.useState(new Set),v=qh(new Date),_=hl(v,30),b=I=>{if(!I)return null;const L=I.split(/[-/T]/);if(L.length<3)return null;const F=parseInt(L[1],10)-1,$=parseInt(L[2],10);return isNaN(F)||isNaN($)?null:new Date(v.getFullYear(),F,$)},w=M.useMemo(()=>{if(!s)return[];const I=[];for(const L of s){if(L.birthday){const F=b(L.birthday);F&&(ll(F,v)||NN(F,v)&&SN(F,_))&&I.push({contact:L,type:"birthday",date:F,daysUntil:op(F,v),dateStr:L.birthday})}if(L.home_anniversary){const F=b(L.home_anniversary);F&&(ll(F,v)||NN(F,v)&&SN(F,_))&&I.push({contact:L,type:"anniversary",date:F,daysUntil:op(F,v),dateStr:L.home_anniversary})}}return I.sort((L,F)=>L.daysUntil-F.daysUntil),I},[s]),j=async I=>{const L=(r==null?void 0:r.find(F=>F.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`}),g(F=>new Set(F).add(`${I.contact.id}-${I.type}`)),dn({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{dn({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:""}`,F=I.type==="birthday"?"birthday":"home_anniversary",$=new URLSearchParams({cardType:F,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?${$.toString()}`)},S=I=>I===0?"Today!":I===1?"Tomorrow":`${I} days`,A=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(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:[e.jsx(jc,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(nt,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[w.length," event",w.length!==1?"s":""]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[w.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Lh,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No birthdays or anniversaries in the next 30 days."}),e.jsx("p",{className:"text-xs mt-1",children:"Add dates to your contacts to see upcoming milestones here."})]}),w.map((I,L)=>{var H,U;const F=`${I.contact.id}-${I.type}`,$=f.has(F),q=`${((H=I.contact.first_name)==null?void 0:H[0])||""}${((U=I.contact.last_name)==null?void 0:U[0])||""}`.toUpperCase();return e.jsxs("div",{className:It("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(mn,{className:It("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(pn,{className:It("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:q})}),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(nt,{variant:"outline",className:It("text-[10px] shrink-0 whitespace-nowrap",A(I.daysUntil)),children:S(I.daysUntil)})]}),e.jsxs("div",{className:It("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(Lh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Hn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:js(I.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[I.contact.phone&&e.jsx(Z,{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(ga,{className:"h-3.5 w-3.5"})})}),I.contact.phone&&e.jsx(Z,{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(ho,{className:"h-3.5 w-3.5"})})}),I.contact.email&&e.jsx(Z,{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(Ar,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{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(Z,{variant:"ghost",size:"sm",className:It("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(gn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(Z,{variant:"ghost",size:"icon",className:It("h-7 w-7",$&&"text-green-600"),title:"Log a touch",disabled:$||n.isPending,onClick:()=>j(I),children:e.jsx(Ma,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${I.contact.id}`),children:e.jsx(Na,{className:"h-3.5 w-3.5"})})]})]},`${F}-${L}`)})]})]}),a&&l&&e.jsx(AL,{open:d,onOpenChange:u,contact:l,gmailEmail:o})]})}const RTe={Crown:Dh,FileText:Un,Users:xr,Globe:up,Star:Gn,Phone:ga,MessageSquare:ho,PenTool:Jk,Video:Cn,Gift:uo},qDt={"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 UDt(){var He,ct,We,Ze,ht,Ke;const t=Or(),{user:s}=Qs(),{data:r}=Vg(),{data:n}=W$e(),{data:a}=Im(),{data:o}=Doe(),{data:l}=J$e(),i=Tjt(),d=Q$e(),u=Cjt(90),f=g_e(),[g,v]=M.useState(null),[_,b]=M.useState(null),[w,j]=M.useState(!1),[N,S]=M.useState(""),[A,I]=M.useState(!1),[L,F]=M.useState(""),[$,q]=M.useState(gne()),[H,U]=M.useState("cards"),[Q,se]=M.useState(!1),[te,Y]=M.useState(null),[ce,oe]=M.useState(null),[le,de]=M.useState(""),{isGmailConnected:xe,gmailEmail:be}=G0(),ye=()=>{const qe=parseInt(L,10);if(isNaN(qe)||qe<1){dn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(qe),X$e(qe),I(!1),dn({title:"Goal updated",description:`Weekly touch goal set to ${qe}`})},ve=()=>{F($.toString()),I(!0)};M.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:Je}=await K.from("profiles").select("name").eq("id",s.id).single();Je!=null&&Je.name&&S(Je.name.split(" ")[0])})()},[s==null?void 0:s.id]),M.useEffect(()=>{i.mutate()},[]);const ke=qh(new Date),Ge=hl(ke,7),Ne=qe=>{if(!qe)return null;const Je=qe.split(/[-/T]/);if(Je.length<3)return null;const Lt=parseInt(Je[1],10)-1,zt=parseInt(Je[2],10);return isNaN(Lt)||isNaN(zt)?null:new Date(ke.getFullYear(),Lt,zt)},Ae=(a==null?void 0:a.filter(qe=>{const Je=Ne(qe.birthday),Lt=Ne(qe.home_anniversary);return Je&&ll(Je,ke)||Lt&&ll(Lt,ke)}))||[];a!=null&&a.filter(qe=>{if(!qe.birthday&&!qe.home_anniversary)return!1;const Je=Lt=>{if(!Lt)return!1;const zt=Ne(Lt);return zt?NN(zt,ke)&&SN(zt,Ge):!1};return Je(qe.birthday)||Je(qe.home_anniversary)}).slice(0,5);const Pe=[],Fe=(o==null?void 0:o.find(qe=>qe.name==="Call"))||(o==null?void 0:o[0]);for(const qe of Ae){const Je=Ne(qe.birthday),Lt=Ne(qe.home_anniversary),zt=Je&&ll(Je,ke),is=Lt&&ll(Lt,ke);zt&&Pe.push({contact:qe,actionType:Fe||{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:((We=(ct=(He=qe.tags)==null?void 0:He[0])==null?void 0:ct.relationship_type)==null?void 0:We.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),is&&Pe.push({contact:qe,actionType:Fe||{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:((Ke=(ht=(Ze=qe.tags)==null?void 0:Ze[0])==null?void 0:ht.relationship_type)==null?void 0:Ke.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const Ve=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((qe,Je)=>{var zt,is,Kt;const Lt=o==null?void 0:o[Je%((o==null?void 0:o.length)||1)];return Lt?{contact:qe,actionType:Lt,planName:"Quick Touch",relationshipTypeName:((Kt=(is=(zt=qe.tags)==null?void 0:zt[0])==null?void 0:is.relationship_type)==null?void 0:Kt.name)||"",monthNumber:0}:null}).filter(Boolean))||[],dt=[...Pe,...Ve],Le=async(qe,Je,Lt)=>{await f.mutateAsync({contactId:qe,actionTypeId:Je,scriptUsedId:Lt}),j(!1),b(null)},Rt=qe=>{qe.script?(b(qe),j(!0)):Le(qe.contact.id,qe.actionType.id)},fe=qe=>RTe[qe||"Phone"]||ga,Qe=qe=>RTe[qe||"Users"]||xr,at=(qe,Je)=>qe.replace(/\{\{FirstName\}\}/g,Je.first_name).replace(/\{\{LastName\}\}/g,Je.last_name||"").replace(/\{\{AgentName\}\}/g,N||"there"),rt=(qe,Je)=>({Call:`Thinking of you, ${Je}!`,Text:`Quick hello, ${Je}`,Email:`Checking in, ${Je}`,"Handwritten Note":`A note for ${Je}`,Video:`Video message for ${Je}`,Gift:`Something special for you, ${Je}`})[qe]||`Hello ${Je}!`,je=(qe,Je,Lt)=>{const zt=`sms:${qe}`;if(Je&&Lt){const is=at(Je,Lt);return`${zt}?body=${encodeURIComponent(is)}`}return zt},mt=(qe,Je,Lt,zt,is)=>{const Kt=`mailto:${qe}`,Qt=[];if(is){const fs=Lt||rt(zt||"Email",is.first_name);if(Qt.push(`subject=${encodeURIComponent(fs)}`),Je){const dr=at(Je,is);Qt.push(`body=${encodeURIComponent(dr)}`)}}return Qt.length>0?`${Kt}?${Qt.join("&")}`:Kt};return e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{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.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 Je=Qe(qe.icon),Lt=(n==null?void 0:n[qe.id])||0,zt=g===qe.id,is=qDt[qe.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{zt?(v(null),t("/mission-control/contacts")):(v(qe.id),t(`/mission-control/contacts?type=${qe.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${zt?is:"bg-card hover:bg-accent"} `,children:[e.jsx(Je,{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 ${zt?"opacity-90":"text-muted-foreground"}`,children:[Lt," Contacts"]})]})]},qe.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(Z,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(eu,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(Z,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(ei,{className:"h-4 w-4 ml-1"})]}),e.jsx(Z,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(Z,{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(nt,{variant:"outline",className:"gap-1",children:[e.jsx(gn,{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(Z,{variant:H==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>U("cards"),title:"Card view",children:e.jsx(hp,{className:"h-4 w-4"})}),e.jsx(Z,{variant:H==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>U("table"),title:"Table view",children:e.jsx(Fh,{className:"h-4 w-4"})})]})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-4",children:dt.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(Z,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):H==="table"?e.jsx(DDt,{actions:dt,onMarkComplete:Le,onViewScript:Rt,isLoading:f.isPending,buildSmsLink:je,buildEmailLink:mt,onGmailCompose:xe?qe=>{Y(qe),se(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[dt.map((qe,Je)=>{var bt,ws,ir,Rr,oa,ri,no;const Lt=qe.isSpecialDate,zt=qe.specialDateType,is=Lt?zt==="birthday"?Lh:Hn:fe(((bt=qe.actionType)==null?void 0:bt.icon)||null),Kt=qe.contact.phone,Qt=qe.contact.email,fs=Lt?zt==="birthday"?"#EC4899":"#8B5CF6":((ws=qe.actionType)==null?void 0:ws.color)||"#3B82F6",dr=Lt?zt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(ir=qe.actionType)==null?void 0:ir.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Lt?"ring-2 ring-offset-2":""}`,style:Lt?{"--tw-ring-color":fs}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:fs},children:[e.jsx(is,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:dr})]}),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:[Kt&&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(ga,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:je(qe.contact.phone,(Rr=qe.script)==null?void 0:Rr.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(ho,{className:"h-3 w-3"}),"Text"]})]}),Qt&&(xe?e.jsxs("button",{onClick:()=>{Y({id:qe.contact.id,first_name:qe.contact.first_name,last_name:qe.contact.last_name,email:qe.contact.email}),se(!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(Ar,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:mt(qe.contact.email,(oa=qe.script)==null?void 0:oa.script_body,(ri=qe.script)==null?void 0:ri.email_subject,(no=qe.actionType)==null?void 0:no.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(Ar,{className:"h-3 w-3"}),"Email"]}))]}),Lt&&e.jsxs("button",{onClick:()=>{const Da=`${qe.contact.first_name}${qe.contact.last_name?" "+qe.contact.last_name:""}`,yn=zt==="birthday"?"birthday":"home_anniversary",ea=new URLSearchParams({cardType:yn,contactId:qe.contact.id,name:Da,...qe.contact.address?{address:qe.contact.address}:{},...zt==="anniversary"&&qe.contact.home_anniversary?{date:qe.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${ea.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(Ar,{className:"h-3 w-3"}),"Send ",zt==="birthday"?"Birthday":"Anniversary"," Card"]}),!Kt&&!Qt&&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(nt,{variant:"secondary",className:"text-xs",children:qe.relationshipTypeName}),qe.monthNumber>0&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:["Month ",qe.monthNumber]})]}),qe.script&&e.jsx(Z,{size:"sm",variant:"outline",className:"w-full",onClick:()=>Rt(qe),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(Z,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{oe(qe.contact.id),de(`${qe.contact.first_name} ${qe.contact.last_name||""}`.trim())},children:[e.jsx(mp,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(Z,{size:"sm",className:"flex-1",onClick:()=>{var Da;return Le(qe.contact.id,qe.actionType.id,(Da=qe.script)==null?void 0:Da.id)},disabled:f.isPending,children:"Mark Complete"})]})]})]},qe.contact.id+Je)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",className:"h-full w-full",children:[e.jsx(Xp,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(mu,{children:e.jsx(Wa,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vt,{className:"text-lg",children:"Momentum"}),e.jsxs(bs,{open:A,onOpenChange:I,children:[e.jsx(Si,{asChild:!0,children:e.jsx("button",{onClick:ve,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Pl,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(_s,{className:"sm:max-w-[360px]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Set Weekly Goal"}),e.jsx(Kr,{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(_e,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(Re,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:qe=>F(qe.target.value),placeholder:"20",onKeyDown:qe=>{qe.key==="Enter"&&ye()}})]}),e.jsx(Z,{onClick:ye,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(wo,{value:Math.min(d.actionsThisWeek/$*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(dp,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[d.actionsThisWeek," / ",$]}),e.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),d.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! (",d.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(Tn,{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(ei,{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(gqe,{}),e.jsx($Dt,{})]})]}),e.jsx(bs,{open:w,onOpenChange:j,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{className:"flex items-center gap-2",children:_&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:_.actionType.color||"#3B82F6"}}),_.actionType.name," Script"]})})}),_&&_.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:[_.contact.first_name," ",_.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:at(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{variant:"outline",className:"flex-1",onClick:()=>j(!1),children:"Close"}),e.jsx(Z,{className:"flex-1",onClick:()=>{var qe;return Le(_.contact.id,_.actionType.id,(qe=_.script)==null?void 0:qe.id)},disabled:f.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(TDt,{})]}),xe&&te&&e.jsx(AL,{open:Q,onOpenChange:se,contact:te,gmailEmail:be}),e.jsx(hle,{open:!!ce,onOpenChange:qe=>!qe&&oe(null),contactId:ce||"",contactName:le})]})}var GWe="Toggle",Abe=M.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=uu({prop:r,onChange:a,defaultProp:n??!1,caller:GWe});return e.jsx(Qr.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Sr(t.onClick,()=>{t.disabled||i(!l)})})});Abe.displayName=GWe;var KWe=Abe,$_="ToggleGroup",[ZWe]=Cc($_,[P_]),YWe=P_(),Ebe=ut.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(VDt,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(HDt,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${$_}\``)});Ebe.displayName=$_;var[XWe,QWe]=ZWe($_),VDt=ut.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=uu({prop:r,defaultProp:n??"",onChange:a,caller:$_});return e.jsx(XWe,{scope:t.__scopeToggleGroup,type:"single",value:ut.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ut.useCallback(()=>i(""),[i]),children:e.jsx(JWe,{...o,ref:s})})}),HDt=ut.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=uu({prop:r,defaultProp:n??[],onChange:a,caller:$_}),d=ut.useCallback(f=>i((g=[])=>[...g,f]),[i]),u=ut.useCallback(f=>i((g=[])=>g.filter(v=>v!==f)),[i]);return e.jsx(XWe,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:d,onItemDeactivate:u,children:e.jsx(JWe,{...o,ref:s})})});Ebe.displayName=$_;var[WDt,GDt]=ZWe($_),JWe=ut.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...d}=t,u=YWe(r),f=E_(l),g={role:"group",dir:f,...d};return e.jsx(WDt,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(Qie,{asChild:!0,...u,orientation:o,dir:f,loop:i,children:e.jsx(Qr.div,{...g,ref:s})}):e.jsx(Qr.div,{...g,ref:s})})}),hae="ToggleGroupItem",eGe=ut.forwardRef((t,s)=>{const r=QWe(hae,t.__scopeToggleGroup),n=GDt(hae,t.__scopeToggleGroup),a=YWe(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},d=ut.useRef(null);return n.rovingFocus?e.jsx(Jie,{asChild:!0,...a,focusable:!l,active:o,ref:d,children:e.jsx(FTe,{...i,ref:s})}):e.jsx(FTe,{...i,ref:s})});eGe.displayName=hae;var FTe=ut.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=QWe(hae,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(Abe,{...i,...a,ref:s,onPressedChange:d=>{d?o.onItemActivate(n):o.onItemDeactivate(n)}})}),tGe=Ebe,sGe=eGe;const rGe=VN("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"}}),KDt=M.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(KWe,{ref:a,className:It(rGe({variant:s,size:r,className:t})),...n}));KDt.displayName=KWe.displayName;const nGe=M.createContext({size:"default",variant:"default"}),aGe=M.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(tGe,{ref:o,className:It("flex items-center justify-center gap-1",t),...a,children:e.jsx(nGe.Provider,{value:{variant:s,size:r},children:n})}));aGe.displayName=tGe.displayName;const iGe=M.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=M.useContext(nGe);return e.jsx(sGe,{ref:o,className:It(rGe({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});iGe.displayName=sGe.displayName;const ZDt=[{value:"bidirectional",label:"Two-Way",icon:$c,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:Rd,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Ku,tooltip:"Only pull BoldTrail → Agent OS"}];function Txe({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(aGe,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:ZDt.map(a=>e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(iGe,{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(au,{children:a.tooltip})]},a.value))})]})}function YDt(){const t=ds(),[s,r]=M.useState(!1),[n,a]=M.useState(null),[o,l]=M.useState(!1),[i,d]=M.useState(!1),[u,f]=M.useState(null),[g,v]=M.useState(null),[_,b]=M.useState(0),w=M.useRef(!1),{data:j}=Tt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:$,error:q}=await K.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(q)throw q;return $}}),N=(j==null?void 0:j.sync_direction)||"bidirectional",S=u??N,A=Bt({mutationFn:async()=>{const{data:$,error:q}=await K.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);return $},onSuccess:$=>{f(null),a($),r(!0)},onError:$=>{ge.error($.message||"Failed to generate sync preview")}}),I=Bt({mutationFn:async()=>{w.current=!1,v("Initializing sync..."),b(5);const{data:$,error:q}=await K.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:S}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);const H=$;let U=H.sync_log_id,Q=H.next_phase,se=H.next_offset;const te=H.push_total||0,Y=H.pull_total||0,ce=te+Y;let oe=0,le=0;for(;Q!=="finalize"&&!w.current;){Q==="push"?(v(`Pushing contacts to BoldTrail... (${oe}/${te})`),b(ce>0?oe/ce*100:0)):Q==="pull"&&(v(`Pulling contacts from BoldTrail... (${le}/${Y})`),b(ce>0?(te+le)/ce*100:0));const{data:be,error:ye}=await K.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:Q,offset:se,sync_log_id:U,sync_direction:S}});if(ye)throw ye;if(be!=null&&be.error)throw new Error(be.error);const ve=be;oe+=ve.chunk_pushed||0,le+=ve.chunk_pulled||0,ve.progress&&v(ve.progress),Q==="pull"&&Y>0?b(Math.min(95,le/Y*100)):Q==="push"&&te>0&&b(Math.min(95,oe/te*100)),Q=ve.next_phase,se=ve.next_offset}v("Finalizing sync..."),b(95);const{data:de,error:xe}=await K.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:U,sync_direction:S}});if(xe)throw xe;return b(100),de},onSuccess:$=>{v(null),b(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"]}),ge.success(`Sync complete! Pushed ${$.contacts_pushed||0}, pulled ${$.contacts_pulled||0}, skipped ${$.contacts_skipped||0} duplicates.`)},onError:$=>{v(null),b(0),ge.error($.message||"Sync failed")}});if(!(j!=null&&j.connected))return null;const L=S==="pull_only"?0:(n==null?void 0:n.to_push)??0,F=S==="push_only"?0:(n==null?void 0:n.to_pull)??0;return e.jsxs(e.Fragment,{children:[e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsx(Z,{variant:"outline",size:"icon",onClick:()=>A.mutate(),disabled:A.isPending,className:"shrink-0",children:A.isPending?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx($c,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(au,{children:"Sync with BoldTrail"})]}),e.jsx(bs,{open:s,onOpenChange:$=>{I.isPending||r($)},children:e.jsxs(_s,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx($c,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Kr,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Txe,{value:S,onChange:f,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:L}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Rd,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:F}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ku,{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:n.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(xr,{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"]}),L>0&&e.jsxs(Eg,{open:o,onOpenChange:l,children:[e.jsx(Pg,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Rd,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(tl,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(Ig,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map(($,q)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:$.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:$.email})]},q)),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"]})]})})]}),F>0&&e.jsxs(Eg,{open:i,onOpenChange:d,children:[e.jsx(Pg,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ku,{className:"h-3 w-3 text-blue-600"}),F," contacts to pull from BoldTrail"]}),e.jsx(tl,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(Ig,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map(($,q)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:$.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:$.email})]},q)),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"]})]})})]}),L===0&&F===0&&!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."}),I.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(wo,{value:_||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:g||"Sync in progress..."})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>r(!1),disabled:I.isPending,children:"Cancel"}),e.jsxs(Z,{onClick:()=>I.mutate(),disabled:I.isPending||L===0&&F===0,className:"gap-2",children:[I.isPending?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx($c,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const oGe=()=>{const{user:t}=Qs();return Tt({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.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})},mle=t=>{const{user:s}=Qs();return Tt({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=K.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})},Pbe=()=>{const{user:t}=Qs();return Tt({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},lGe=()=>{const{user:t}=Qs();return Tt({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},cGe=()=>{const{data:t}=Im(),{data:s}=Vg(),{data:r}=mle(),{data:n}=lGe(),{data:a}=Pbe(),o=new Map;r==null||r.forEach(f=>{const g=o.get(f.contact_id);(!g||new Date(f.completed_at)>new Date(g))&&o.set(f.contact_id,f.completed_at)});const l=new Map;a==null||a.forEach(f=>l.set(f.relationship_type_id,f.frequency_days));const i=new Map;n==null||n.filter(f=>f.is_active).forEach(f=>{i.set(f.contact_id,f.frequency_days)});const d=qh(new Date);return(t||[]).map(f=>{let g=90;if(i.has(f.id))g=i.get(f.id);else if(f.tags&&f.tags.length>0){const j=f.tags.map(N=>l.get(N.relationship_type_id)).filter(N=>N!==void 0);j.length>0&&(g=Math.min(...j))}const v=o.get(f.id)||null,_=v?zg(d,qh(new Date(v))):null,b=_===null||_>=g,w=b&&_!==null?_-g:0;return{...f,lastPopby:v,daysSinceLastPopby:_,frequencyDays:g,isDue:b,daysOverdue:w}}).sort((f,g)=>g.daysOverdue-f.daysOverdue)},dGe=()=>cGe().filter(s=>s.isDue),XDt=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{error:n}=await K.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),dn({title:"Popby item created!"})},onError:r=>{dn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},uGe=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{error:n}=await K.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),dn({title:"Popby logged!"})},onError:r=>{dn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},QDt=()=>{const t=ds(),{user:s}=Qs();return Bt({mutationFn:async r=>{const{error:n}=await K.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"]}),dn({title:"Frequency updated!"})},onError:r=>{dn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},JDt=()=>{const{data:t}=mle(30),s=dGe(),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 eOt(){const{user:t}=Qs();return Tt({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function hGe(t){const{data:s}=eOt(),{data:r}=lGe(),{data:n}=Pbe(),{data:a}=ADt();return M.useMemo(()=>{const o=a==null?void 0:a.find(j=>j.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=qh(new Date);if(l&&!SN(l,i))return{nextTouchDate:l,daysUntil:zg(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(j=>j.contact_id===t.id))||[]).sort((j,N)=>new Date(N.completed_at).getTime()-new Date(j.completed_at).getTime())[0],f=u?new Date(u.completed_at):null;let g=90;const v=r==null?void 0:r.find(j=>j.contact_id===t.id&&j.is_active);if(v)g=v.frequency_days;else if(t.tags&&t.tags.length>0){const j=t.tags.map(N=>{const S=n==null?void 0:n.find(A=>A.relationship_type_id===N.relationship_type_id);return S==null?void 0:S.frequency_days}).filter(N=>N!==void 0);j.length>0&&(g=Math.min(...j))}if(!f)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:g,lastTouchDate:null,snoozedUntil:null};const _=hl(qh(f),g),b=zg(_,i);let w;return b<0?w="overdue":b<=7?w="due-soon":w="on-track",{nextTouchDate:_,daysUntil:b,status:w,frequencyDays:g,lastTouchDate:f,snoozedUntil:null}},[t,s,r,n,a])}function Axe({contact:t}){const s=hGe(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:Yo,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:Tn,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:Ma,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:mp,text:`Snoozed until ${js(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:nn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(nt,{variant:n.variant,className:It("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function tOt({contact:t,onLogTouch:s,onSnooze:r}){const n=hGe(t),a=PDt(),[o,l]=M.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"}},d=()=>{switch(n.status){case"overdue":return e.jsx(Yo,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(Tn,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(Ma,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(mp,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(nn,{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"}},f=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d(),e.jsx("span",{className:It("font-medium",i()),children:u()})]}),n.status==="snoozed"&&n.snoozedUntil&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",js(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:"})," ",js(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:"})," ",js(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(Z,{size:"sm",variant:"outline",className:"flex-1",onClick:f,disabled:a.isPending,children:[e.jsx(Vr,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(Z,{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(Z,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(mp,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(Z,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(hle,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const jme=768;function xM(){const[t,s]=M.useState(void 0);return M.useEffect(()=>{const r=window.matchMedia(`(max-width: ${jme-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}const sOt={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"}},rOt={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 kme({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=sOt[t.status],l=rOt[n],i=e.jsxs("div",{className:It("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:It("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(HN,{children:e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:i}),e.jsx(au,{side:"top",className:"w-64 p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-semibold",children:"Relationship Score"}),e.jsxs("span",{className:It("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(wo,{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 nOt=[{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}],H8=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),d=parseInt(o);if(i>=1&&i<=12&&d>=1&&d<=31)return`${l}-${a}-${o}`}const n=new Date(s);return isNaN(n.getTime())?null:n.toISOString().split("T")[0]},aOt=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Qs(),{toast:o}=La(),l=M.useRef(null),[i,d]=M.useState("upload"),[u,f]=M.useState([]),[g,v]=M.useState([]),[_,b]=M.useState({}),[w,j]=M.useState([]),[N,S]=M.useState([]),[A,I]=M.useState(!1),[L,F]=M.useState(null),$=()=>{d("upload"),f([]),v([]),b({}),j([]),S([]),F(null),l.current&&(l.current.value="")},q=()=>{$(),s(!1)},H=be=>{const ye=be.split(` `).map(Ne=>Ne.trim()).filter(Ne=>Ne);if(ye.length===0)return{headers:[],data:[]};const ve=Ne=>{const Ae=[];let Pe="",Fe=!1;for(let Ie=0;Ie{var ke;const ye=(ke=be.target.files)==null?void 0:ke[0];if(!ye)return;const ve=new FileReader;ve.onload=Ge=>{var Ie;const Ne=(Ie=Ge.target)==null?void 0:Ie.result,{headers:Ae,data:Pe}=H(Ne);if(Ae.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}f(Ae),v(Pe);const Fe={};Ae.forEach(Ve=>{const dt=Ve.toLowerCase().replace(/[_\s-]/g,"");dt.includes("firstname")||dt==="first"?Fe.first_name=Ve:dt.includes("lastname")||dt==="last"?Fe.last_name=Ve:dt.includes("spouse")&&dt.includes("email")?Fe.spouse_email=Ve:dt.includes("spouse")||dt.includes("partner")?Fe.spouse_name=Ve:dt.includes("email")?Fe.email=Ve:dt.includes("phone")||dt.includes("mobile")||dt.includes("cell")?Fe.phone=Ve:dt.includes("address")||dt.includes("street")?Fe.address=Ve:dt==="city"?Fe.city=Ve:dt==="state"||dt==="province"?Fe.state=Ve:dt==="zip"||dt==="zipcode"||dt==="postalcode"?Fe.zip=Ve:dt.includes("company")||dt.includes("organization")||dt.includes("business")?Fe.company_name=Ve:dt.includes("jobtitle")||dt.includes("title")&&!dt.includes("spouse")?Fe.job_title=Ve:dt.includes("birthday")||dt.includes("dob")||dt.includes("birthdate")?Fe.birthday=Ve:dt.includes("anniversary")||dt.includes("homeanniversary")?Fe.home_anniversary=Ve:(dt.includes("notes")||dt.includes("comment"))&&(Fe.notes=Ve)}),b(Fe),d("mapping")},ve.readAsText(ye)},Q=(be,ye)=>{b(ve=>{if(ye==="none"){const{[be]:ke,...Ge}=ve;return Ge}return{...ve,[be]:ye}})},se=be=>{j(ye=>ye.includes(be)?ye.filter(ve=>ve!==be):[...ye,be])},te=async()=>{if(!(a!=null&&a.id))return;const{data:be}=await K.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),ye=new Set((be||[]).filter(Ge=>Ge.email).map(Ge=>Ge.email.toLowerCase())),ve=new Set((be||[]).filter(Ge=>Ge.phone).map(Ge=>Ge.phone.replace(/[^0-9]/g,""))),ke=g.map(Ge=>{const Ne=dt=>{const Le=_[dt];if(!Le)return"";const Rt=u.indexOf(Le);return Rt>=0?(Ge[Rt]||"").trim():""},Ae=Ne("first_name"),Pe=Ne("email"),Fe=Ne("phone"),Ie=Ae.length>0,Ve=!!(Pe&&ye.has(Pe.toLowerCase())||Fe&&ve.has(Fe.replace(/[^0-9]/g,"")));return{first_name:Ae,last_name:Ne("last_name"),email:Pe,phone:Fe,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:Ie,isDuplicate:Ve,error:Ie?void 0:"First name is required"}});S(ke),d("preview")},Y=be=>{const ye=be.trim().split(/\s+/);return{first_name:ye[0],last_name:ye.length>1?ye.slice(1).join(" "):null}},ce=async()=>{if(!(a!=null&&a.id))return;const be=N.filter(Ge=>Ge.isValid);if(be.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}I(!0);let ye=0,ve=0,ke=0;try{for(const Ge of be)try{let Ne=null;if(Ge.email){const{data:Fe}=await K.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ge.email).maybeSingle();Ne=Fe}if(!Ne&&Ge.phone){const Fe=Ge.phone.replace(/[^0-9]/g,""),{data:Ie}=await K.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(Ie){const Ve=Ie.find(dt=>dt.phone&&dt.phone.replace(/[^0-9]/g,"")===Fe);Ve&&(Ne={id:Ve.id})}}const Ae={owner_user_id:a.id,first_name:Ge.first_name,last_name:Ge.last_name||null,email:Ge.email||null,phone:Ge.phone||null,address:Ge.address||null,city:Ge.city||null,state:Ge.state||null,zip:Ge.zip||null,spouse_name:Ge.spouse_name||null,spouse_email:Ge.spouse_email||null,company_name:Ge.company_name||null,job_title:Ge.job_title||null,birthday:H8(Ge.birthday),home_anniversary:H8(Ge.home_anniversary),notes:Ge.notes||null};let Pe=null;if(Ne){const{data:Fe}=await K.from("innercircle_contacts").select("*").eq("id",Ne.id).single();if(Fe){const Ie={},Ve=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const dt of Ve){const Le=Fe[dt],Rt=Ae[dt];(!Le||Le==="")&&Rt&&(Ie[dt]=Rt)}Object.keys(Ie).length>0&&await K.from("innercircle_contacts").update(Ie).eq("id",Ne.id)}Pe=Ne.id,ve++}else{const{data:Fe,error:Ie}=await K.from("innercircle_contacts").insert(Ae).select("id").single();Ie?(console.error("Insert error for contact:",Ge.first_name,Ie),ke++):Fe?(Pe=Fe.id,w.length>0&&await K.from("innercircle_contact_tags").insert(w.map(Ve=>({contact_id:Fe.id,relationship_type_id:Ve}))),ye++):ke++}if(Pe&&Ge.spouse_name){const Fe=Y(Ge.spouse_name);let Ie=null;if(Ge.spouse_email){const{data:dt}=await K.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ge.spouse_email).maybeSingle();Ie=dt}if(!Ie){const{data:dt}=await K.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Fe.first_name).eq("last_name",Fe.last_name||Ge.last_name||"").maybeSingle();Ie=dt}let Ve=null;if(Ie){Ve=Ie.id;const dt=H8(Ge.home_anniversary);dt&&await K.from("innercircle_contacts").update({home_anniversary:dt}).eq("id",Ie.id).is("home_anniversary",null)}else{const{data:dt}=await K.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Fe.first_name,last_name:Fe.last_name||Ge.last_name||null,email:Ge.spouse_email||null,address:Ge.address||null,city:Ge.city||null,state:Ge.state||null,zip:Ge.zip||null,home_anniversary:H8(Ge.home_anniversary),spouse_name:`${Ge.first_name}${Ge.last_name?" "+Ge.last_name:""}`,spouse_email:Ge.email||null,notes:`Spouse of ${Ge.first_name} ${Ge.last_name||""} (imported via CSV)`.trim()}).select("id").single();dt&&(Ve=dt.id,ye++)}Ve&&(await K.from("innercircle_contacts").update({spouse_contact_id:Ve}).eq("id",Pe),await K.from("innercircle_contacts").update({spouse_contact_id:Pe}).eq("id",Ve))}}catch(Ne){console.error("Error importing contact:",Ne),ke++}F({created:ye,updated:ve,failed:ke}),d("result"),(ye>0||ve>0)&&n(),o({title:"Import Complete",description:`${ye} created, ${ve} updated${ke>0?`, ${ke} failed`:""}.`})}catch(Ge){console.error("Import error:",Ge),o({title:"Import Failed",description:Ge.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},oe=N.filter(be=>be.isValid).length,le=N.filter(be=>!be.isValid).length,de=N.filter(be=>be.isValid&&be.isDuplicate).length,xe=oe-de;return e.jsx(bs,{open:t,onOpenChange:q,children:e.jsxs(_s,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(x0,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Kr,{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:U,className:"hidden"}),e.jsx(xi,{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(Z,{onClick:()=>{var be;return(be=l.current)==null?void 0:be.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(Z,{variant:"outline",size:"sm",onClick:()=>{const be=`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`,ye=new Blob([be],{type:"text/csv"}),ve=URL.createObjectURL(ye),ke=document.createElement("a");ke.href=ve,ke.download="contact_import_template.csv",ke.click(),URL.revokeObjectURL(ve)},children:[e.jsx(Ei,{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(_e,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:nOt.map(be=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(_e,{className:"w-40 text-sm",children:[be.label,be.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(tr,{value:_[be.key]||"none",onValueChange:ye=>Q(be.key,ye),children:[e.jsx(Js,{className:"w-48",children:e.jsx(rr,{placeholder:"Select column..."})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"-- Not mapped --"}),u.map(ye=>e.jsx(At,{value:ye,children:ye},ye))]})]})]},be.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(be=>e.jsx(nt,{variant:w.includes(be.id)?"default":"outline",className:"cursor-pointer",onClick:()=>se(be.id),children:be.name},be.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",g.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(Ma,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[xe," new"]})]}),de>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Yo,{className:"h-4 w-4"}),e.jsxs("span",{children:[de," existing (will merge gaps)"]})]}),le>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Yo,{className:"h-4 w-4"}),e.jsxs("span",{children:[le," invalid"]})]})]}),de>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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:N.slice(0,100).map((be,ye)=>e.jsxs(ks,{children:[e.jsx(lt,{children:be.first_name}),e.jsx(lt,{children:be.last_name}),e.jsx(lt,{children:be.email}),e.jsx(lt,{children:be.phone}),e.jsx(lt,{children:be.isValid?be.isDuplicate?e.jsx(nt,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(nt,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(nt,{variant:"destructive",children:be.error||"Invalid"})})]},ye))})]}),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(Ma,{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(qn,{children:[i==="upload"&&e.jsx(Z,{variant:"outline",onClick:q,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{variant:"outline",onClick:$,children:"Back"}),e.jsx(Z,{onClick:te,disabled:!_.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{variant:"outline",onClick:()=>d("mapping"),children:"Back"}),e.jsx(Z,{onClick:ce,disabled:A||oe===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${oe} Contact${oe!==1?"s":""}`})]}),i==="result"&&e.jsx(Z,{onClick:q,children:"Done"})]})]})})};function iOt(){return"contacts"in navigator&&"ContactsManager"in window}function oOt(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="",d="",u="";for(const f of a){const g=f.replace(/^\s+/,"");if(g.startsWith("N:")||g.startsWith("N;")){const _=g.substring(g.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((g.startsWith("FN:")||g.startsWith("FN;"))&&!o){const _=g.substring(g.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.slice(1).join(" ")}(g.startsWith("EMAIL")||g.match(/^item\d+\.EMAIL/i))&&!i&&(i=g.substring(g.indexOf(":")+1).trim()),(g.startsWith("TEL")||g.match(/^item\d+\.TEL/i))&&!d&&(d=g.substring(g.indexOf(":")+1).trim()),(g.startsWith("ADR")||g.match(/^item\d+\.ADR/i))&&!u&&(u=g.substring(g.indexOf(":")+1).split(";").map(b=>b.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:d,address:u})}return s}function lOt({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Qs(),{data:a}=Im(),o=Loe(),l=M.useRef(null),[i,d]=M.useState("choose"),[u,f]=M.useState([]),[g,v]=M.useState(new Set),[_,b]=M.useState(0),[w,j]=M.useState(0),N=iOt(),S=M.useCallback(Q=>{if(!a)return Q;const se=new Set(a.filter(Y=>Y.email).map(Y=>Y.email.toLowerCase())),te=new Set(a.filter(Y=>Y.phone).map(Y=>Y.phone.replace(/\D/g,"")));return Q.map(Y=>{var le,de;const ce=(le=Y.email)==null?void 0:le.toLowerCase(),oe=(de=Y.phone)==null?void 0:de.replace(/\D/g,"");return ce&&se.has(ce)?{...Y,isDuplicate:!0,duplicateField:"email"}:oe&&oe.length>=7&&te.has(oe)?{...Y,isDuplicate:!0,duplicateField:"phone"}:Y})},[a]),A=async()=>{try{const Q=["name","email","tel","address"],se=await navigator.contacts.select(Q,{multiple:!0});if(!se||se.length===0)return;const te=se.map(oe=>{var xe,be,ye,ve;const de=(((xe=oe.name)==null?void 0:xe[0])||"").split(" ");return{first_name:de[0]||"",last_name:de.slice(1).join(" "),email:((be=oe.email)==null?void 0:be[0])||"",phone:((ye=oe.tel)==null?void 0:ye[0])||"",address:(ve=oe.address)!=null&&ve[0]?[oe.address[0].streetAddress,oe.address[0].city,oe.address[0].region,oe.address[0].postalCode].filter(Boolean).join(", "):""}}),Y=S(te);f(Y);const ce=new Set;Y.forEach((oe,le)=>{oe.isDuplicate||ce.add(le)}),v(ce),d("preview")}catch(Q){console.error("Contact Picker error:",Q),dn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},I=Q=>{var Y;const se=(Y=Q.target.files)==null?void 0:Y[0];if(!se)return;const te=new FileReader;te.onload=ce=>{var be;const oe=(be=ce.target)==null?void 0:be.result,le=oOt(oe);if(le.length===0){dn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const de=S(le);f(de);const xe=new Set;de.forEach((ye,ve)=>{ye.isDuplicate||xe.add(ve)}),v(xe),d("preview")},te.readAsText(se),l.current&&(l.current.value="")},L=async()=>{const Q=u.filter((te,Y)=>g.has(Y));if(Q.length===0)return;d("importing");let se=0;for(const te of Q)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}),se++,j(Math.round(se/Q.length*100))}catch(Y){console.error(`Failed to import ${te.first_name} ${te.last_name}:`,Y)}b(se),d("done")},F=Q=>{v(se=>{const te=new Set(se);return te.has(Q)?te.delete(Q):te.add(Q),te})},$=()=>{g.size===u.length?v(new Set):v(new Set(u.map((Q,se)=>se)))},q=Q=>{Q||(d("choose"),f([]),v(new Set),b(0),j(0),i==="done"&&r()),s(Q)},H=u.filter(Q=>Q.isDuplicate).length,U=g.size;return e.jsx(bs,{open:t,onOpenChange:q,children:e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(N0,{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(Kr,{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(Z,{onClick:A,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(N0,{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(Z,{variant:N?"outline":"default",onClick:()=>{var Q;return(Q=l.current)==null?void 0:Q.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(xi,{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",H>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",H," already exist)"]})]}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:$,children:g.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Fi,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((Q,se)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${Q.isDuplicate?"opacity-60":""}`,onClick:()=>F(se),children:[e.jsx($o,{checked:g.has(se),onCheckedChange:()=>F(se),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:[Q.first_name," ",Q.last_name]}),Q.isDuplicate&&e.jsxs(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",Q.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[Q.phone&&e.jsx("div",{children:Q.phone}),Q.email&&e.jsx("div",{className:"truncate",children:Q.email})]})]})]},se))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>d("choose"),children:"Back"}),e.jsxs(Z,{onClick:L,disabled:U===0,children:["Import ",U," Contact",U!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(Rs,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${w}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(ma,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[_," contact",_!==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(Z,{onClick:()=>q(!1),className:"mt-2",children:"Done"})]})]})})}function ple(){const t=vi();return Tt({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await K.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function cOt(t){return Tt({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await K.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function Ibe(){const t=ds(),s=vi();return Bt({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await K.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 dOt(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.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 uOt(){const t=ds();return Bt({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 K.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 mGe(){const t=ds();return Bt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await K.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 hOt(){const t=ds();return Bt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await K.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 mOt(){const t=vi();return Tt({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await K.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 pOt({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const{data:i}=Vg(),d=f_e(),u=ds(),{isGmailConnected:f}=G0(),{data:g}=ple(),v=Ibe(),_=mGe(),[b,w]=M.useState(!1),[j,N]=M.useState(!1),[S,A]=M.useState(!1),[I,L]=M.useState(""),F=t.size;if(F===0)return null;const $=async Y=>{w(!0);try{const oe=Array.from(t).map(de=>({contact_id:de,relationship_type_id:Y})),{error:le}=await K.from("innercircle_contact_tags").upsert(oe,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(le)throw le;u.invalidateQueries({queryKey:["innercircle-contacts"]}),u.invalidateQueries({queryKey:["innercircle-contact-counts"]}),dn({title:`Assigned type to ${F} contacts`}),r()}catch(ce){dn({title:"Error assigning type",description:ce.message,variant:"destructive"})}finally{w(!1)}},q=async Y=>{w(!0);try{const ce=Array.from(t);for(const oe of ce)try{await _.mutateAsync({contactId:oe,tagId:Y})}catch{}u.invalidateQueries({queryKey:["all-contact-custom-tags"]}),dn({title:`Tagged ${F} contacts`}),A(!1),L("")}catch(ce){dn({title:"Error adding tags",description:ce.message,variant:"destructive"})}finally{w(!1)}},H=async()=>{if(I.trim()){w(!0);try{const Y=await v.mutateAsync({name:I.trim()});await q(Y.id)}catch(Y){dn({title:"Error creating tag",description:Y.message,variant:"destructive"}),w(!1)}}},U=(g==null?void 0:g.filter(Y=>Y.name.toLowerCase().includes(I.toLowerCase())))||[],Q=g==null?void 0:g.find(Y=>Y.name.toLowerCase()===I.trim().toLowerCase()),se=()=>{const Y=s.filter(ye=>t.has(ye.id)),ce=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],oe=Y.map(ye=>{var ve;return[ye.first_name,ye.last_name||"",ye.email||"",ye.phone||"",ye.address||"",ye.birthday||"",ye.home_anniversary||"",ye.notes||"",((ve=ye.tags)==null?void 0:ve.map(ke=>{var Ge;return(Ge=ke.relationship_type)==null?void 0:Ge.name}).join("; "))||""]}),le=[ce.join(","),...oe.map(ye=>ye.map(ve=>`"${(ve||"").replace(/"/g,'""')}"`).join(","))].join(` `),de=new Blob([le],{type:"text/csv"}),xe=URL.createObjectURL(de),be=document.createElement("a");be.href=xe,be.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,be.click(),URL.revokeObjectURL(xe),dn({title:`Exported ${F} contacts`})},te=async()=>{if(confirm(`Are you sure you want to delete ${F} contacts? This cannot be undone.`)){w(!0);try{const Y=Array.from(t);for(const ce of Y)await d.mutateAsync(ce);r()}catch(Y){dn({title:"Error deleting contacts",description:Y.message,variant:"destructive"})}finally{w(!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(nt,{variant:"secondary",className:"font-semibold",children:[F," selected"]}),e.jsxs(tr,{onValueChange:$,disabled:b,children:[e.jsx(Js,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pp,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(er,{children:i==null?void 0:i.filter(Y=>Y.active).map(Y=>e.jsx(At,{value:Y.id,children:Y.name},Y.id))})]}),e.jsxs(No,{open:S,onOpenChange:A,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",disabled:b,children:[e.jsx(Ys,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(jo,{className:"w-56 p-2",align:"start",children:[e.jsx(Re,{placeholder:"Search or create tag...",value:I,onChange:Y=>L(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&I.trim()&&!Q?(Y.preventDefault(),H()):Y.key==="Enter"&&Q&&(Y.preventDefault(),q(Q.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[U.map(Y=>e.jsxs("button",{onClick:()=>q(Y.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:Y.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Y.name})]},Y.id)),I.trim()&&!Q&&e.jsxs("button",{onClick:H,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(Ys,{className:"h-3.5 w-3.5"}),'Create "',I.trim(),'"']}),U.length===0&&!I.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>N(!0),disabled:b,children:[e.jsx(Ar,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),a&&n&&e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:b,children:[e.jsx(zx,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:b,children:[e.jsx(p0,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:se,disabled:b,children:[e.jsx(Ei,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:te,disabled:b,className:"text-destructive hover:text-destructive",children:[e.jsx(Cr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Vr,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(AL,{open:j,onOpenChange:N,bulkContacts:Array.from(t).map(Y=>{const ce=s.find(oe=>oe.id===Y);return ce?{id:ce.id,first_name:ce.first_name,last_name:ce.last_name,email:ce.email||""}:null}).filter(Y=>Y!==null&&Y.email!==""),onSendComplete:()=>{N(!1),r()}})]})}function zTe({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=Or(),u=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(Xp,{className:"h-4 w-4"})})}),e.jsxs(mu,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(Wa,{onClick:()=>d(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(ga,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Wa,{onClick:()=>d(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Wa,{onClick:()=>d(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Pi,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),e.jsxs(Wa,{onClick:()=>n(t.id,u),children:[e.jsx(mp,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Wa,{onClick:()=>a(t.id),children:[e.jsx(zx,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Wa,{onClick:()=>l(t.id),children:[e.jsx(p0,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Wa,{onClick:()=>s(t),children:[e.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Wa,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(Cr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function fOt(){const{user:t}=Qs();return Tt({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function gOt(){const t=ds(),{user:s}=Qs();return Bt({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await K.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"]}),dn({title:"Smart filter saved"})},onError:r=>{dn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function xOt(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),dn({title:"Smart filter deleted"})}})}function yOt({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=fOt(),a=gOt(),o=xOt(),[l,i]=M.useState(!1),[d,u]=M.useState(""),f=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",g=async()=>{d.trim()&&(await a.mutateAsync({name:d.trim(),filters:t,sort_by:s}),u(""),i(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(y0,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(nt,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(tl,{className:"h-3.5 w-3.5"})]})}),e.jsxs(mu,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(v=>e.jsxs(Wa,{className:"flex items-center justify-between group",children:[e.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>r(v.filters,v.sort_by),children:v.name}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:_=>{_.stopPropagation(),o.mutate(v.id)},children:e.jsx(Cr,{className:"h-3 w-3 text-destructive"})})]},v.id)),e.jsx(g_,{})]}):e.jsx(Wa,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),f&&e.jsxs(Wa,{onClick:()=>i(!0),children:[e.jsx(FE,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(bs,{open:l,onOpenChange:i,children:e.jsxs(_s,{className:"max-w-sm",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Re,{placeholder:"e.g. Buyers in 40205",value:d,onChange:v=>u(v.target.value),onKeyDown:v=>v.key==="Enter"&&g(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(Z,{onClick:g,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function wE(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 $Te({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=Or(),i=BTe(t,"birthday",7),d=BTe(s,"anniversary",7);if(!i&&!d)return null;const u=(f,g)=>{g.stopPropagation();const v=new URLSearchParams;n&&v.set("contactId",n),a&&v.set("name",a),o&&v.set("address",o),f==="home_anniversary"&&s&&v.set("date",s),v.set("cardType",f),l(`/mission-control/card-studio?${v.toString()}`)};return e.jsxs("div",{className:It("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(nt,{variant:"secondary",className:It("text-[10px] gap-0.5 font-medium",i.daysUntil===0?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400 animate-pulse":"bg-pink-50 text-pink-600 dark:bg-pink-900/20 dark:text-pink-400"),children:i.label}),n&&e.jsxs("button",{onClick:f=>u("birthday",f),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(Ar,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(nt,{variant:"secondary",className:It("text-[10px] gap-0.5 font-medium",d.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:d.label}),n&&e.jsxs("button",{onClick:f=>u("home_anniversary",f),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(Ar,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function qTe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(nt,{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 vOt(){const t=vi();return Tt({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await K.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 _Ot({contactId:t,compact:s=!1}){const{data:r}=ple(),{data:n}=cOt(t),a=Ibe(),o=mGe(),l=hOt(),[i,d]=M.useState(!1),[u,f]=M.useState(""),g=M.useRef(null),v=new Set((n==null?void 0:n.map(N=>N.tag_id))||[]),_=(r==null?void 0:r.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())))||[],b=r==null?void 0:r.find(N=>N.name.toLowerCase()===u.trim().toLowerCase()),w=async N=>{v.has(N.id)?await l.mutateAsync({contactId:t,tagId:N.id}):await o.mutateAsync({contactId:t,tagId:N.id})},j=async()=>{if(!(!u.trim()||b))try{const N=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:N.id}),f("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(N=>{var S,A,I;return e.jsxs(nt,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((S=N.tag)==null?void 0:S.color)||"#6366F1",color:((A=N.tag)==null?void 0:A.color)||"#6366F1"},children:[e.jsx(pp,{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(Vr,{className:"h-2.5 w-2.5"})})]},N.id)}),e.jsxs(No,{open:i,onOpenChange:d,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{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(Ys,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(jo,{className:"w-56 p-2",align:"start",onClick:N=>N.stopPropagation(),children:[e.jsx(Re,{ref:g,placeholder:"Search or create tag...",value:u,onChange:N=>f(N.target.value),onKeyDown:N=>{N.key==="Enter"&&u.trim()&&!b?(N.preventDefault(),j()):N.key==="Enter"&&b&&!v.has(b.id)&&(N.preventDefault(),w(b))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[_.map(N=>e.jsxs("button",{onClick:()=>w(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}),v.has(N.id)&&e.jsx(ma,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},N.id)),u.trim()&&!b&&e.jsxs("button",{onClick:j,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(Ys,{className:"h-3.5 w-3.5"}),'Create "',u.trim(),'"']}),_.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 UTe({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(nt,{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 W8=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function bOt({open:t,onOpenChange:s}){const{data:r,isLoading:n}=ple(),a=Ibe(),o=uOt(),l=dOt(),[i,d]=M.useState(""),[u,f]=M.useState(W8[0]),[g,v]=M.useState(null),[_,b]=M.useState(""),[w,j]=M.useState(""),N=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),d(""),f(W8[0]),dn({title:"Tag created"})}catch(L){dn({title:"Error",description:L.message,variant:"destructive"})}},S=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:w}),v(null),dn({title:"Tag updated"})}catch(F){dn({title:"Error",description:F.message,variant:"destructive"})}},A=async(L,F)=>{if(confirm(`Delete tag "${F}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),dn({title:"Tag deleted"})}catch($){dn({title:"Error",description:$.message,variant:"destructive"})}},I=L=>{v(L.id),b(L.name),j(L.color)};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"New tag name...",value:i,onChange:L=>d(L.target.value),onKeyDown:L=>L.key==="Enter"&&N(),className:"flex-1 h-9"}),e.jsxs(Z,{size:"sm",onClick:N,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:W8.map(L=>e.jsx("button",{onClick:()=>f(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:g===L.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:W8.map(F=>e.jsx("button",{onClick:()=>j(F),className:`h-5 w-5 rounded-full border-2 ${w===F?"border-foreground":"border-transparent"}`,style:{backgroundColor:F}},F))}),e.jsx(Re,{value:_,onChange:F=>b(F.target.value),onKeyDown:F=>F.key==="Enter"&&S(L.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(L.id),children:e.jsx(ma,{className:"h-4 w-4 text-primary"})}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>v(null),children:e.jsx(Vr,{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(Z,{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(Ga,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{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:()=>A(L.id,L.name),children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function pGe({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=gL(),a=hqe(),[o,l]=M.useState(!1),[i,d]=M.useState(""),u=async()=>{if(i.trim())try{const f=await a.mutateAsync(i.trim());f&&(s(f.id),d(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:t||"_none",onValueChange:f=>s(f==="_none"?"":f),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select lead source"})}),e.jsxs(er,{children:[e.jsx(At,{value:"_none",children:"No source"}),n==null?void 0:n.map(f=>e.jsx(At,{value:f.id,children:f.name},f.id))]})]}),e.jsx(Z,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(Vr,{className:"h-4 w-4"}):e.jsx(Ys,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"New lead source name...",value:i,onChange:f=>d(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),u())},className:"flex-1"}),e.jsx(Z,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function Exe({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=Or(),[d,u]=M.useState(!1),[f,g]=M.useState(""),{data:v}=Tt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:b,error:w}=await K.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(w)throw w;return b},enabled:!!s}),{data:_}=Tt({queryKey:["spouse-search",f],queryFn:async()=>{let b=K.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);f.trim()&&(b=b.or(`first_name.ilike.%${f}%,last_name.ilike.%${f}%,email.ilike.%${f}%,phone.ilike.%${f}%`));const{data:w,error:j}=await b;if(j)throw j;return w},enabled:d});if(s&&v){const b=`${v.first_name} ${v.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{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(mo,{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/${v.id}`),className:"text-sm font-medium text-primary hover:underline truncate block",children:b}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[v.phone,v.email].filter(Boolean).join(" · ")||"No contact info"})]}),l&&e.jsxs(Z,{variant:"ghost",size:"sm",onClick:o,className:"shrink-0 h-7 px-2",children:[e.jsx(nN,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${v.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Ai,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{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(mo,{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(No,{open:d,onOpenChange:u,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(Al,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(jo,{className:"w-72 p-2",align:"end",children:e.jsx(VTe,{search:f,setSearch:g,results:_,onSelect:b=>{a(b),u(!1),g("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(No,{open:d,onOpenChange:u,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(Al,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(jo,{className:"w-72 p-2",align:"start",children:e.jsx(VTe,{search:f,setSearch:g,results:_,onSelect:b=>{a(b),u(!1),g("")}})})]})]}):null}function VTe({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(xn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Fi,{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 wOt(){var ea;const t=Or(),[s]=Gc(),{user:r}=Qs(),n=xM(),a=ds(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:d,isLoading:u}=y_e(),{data:f}=Vg(),{data:g}=vOt(),{data:v}=ple(),{data:_}=mOt(),[b,w]=M.useState(new Set),[j,N]=M.useState("any"),S=Loe(),A=G$e(),I=f_e(),L=K$e(),[F,$]=M.useState(""),[q,H]=M.useState(o||"all"),[U,Q]=M.useState(l||"all"),[se,te]=M.useState("date-added"),[Y,ce]=M.useState(i),[oe,le]=M.useState(null),[de,xe]=M.useState(!1),[be,ye]=M.useState(!1),[ve,ke]=M.useState(null),[Ge,Ne]=M.useState(""),[Ae,Pe]=M.useState(new Set),[Fe,Ie]=M.useState(!1),[Ve,dt]=M.useState(1),[Le,Rt]=M.useState(50),[fe,Qe]=M.useState("my"),[at,rt]=M.useState(!1),{data:je}=Ug(),{addToLeadPond:mt}=hWe(je==null?void 0:je.teamId),He=!!((ea=je==null?void 0:je.team)!=null&&ea.lead_pond_enabled&&(je!=null&&je.teamId)),ct=!!(je!=null&&je.teamId),[We,Ze]=M.useState([]),[ht,Ke]=M.useState(!1),qe=Zt=>{Ze([Zt]),Ke(!0)},Je=Zt=>{Ze(Zt),Ke(!0)},Lt=Zt=>{je!=null&&je.teamId&&mt.mutate({contact_id:Zt,team_id:je.teamId})},zt=Zt=>{je!=null&&je.teamId&&Zt.forEach(yr=>{mt.mutate({contact_id:yr,team_id:je.teamId})})},is=M.useCallback(Zt=>{Ie(!1),Pe(yr=>{const Gr=new Set(yr);return Gr.has(Zt)?Gr.delete(Zt):Gr.add(Zt),Gr})},[]);M.useEffect(()=>{if(!(r!=null&&r.id))return;const Zt=K.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()=>{K.removeChannel(Zt)}},[a,r==null?void 0:r.id]),M.useEffect(()=>{l&&Q(l)},[l]);const[Kt,Qt]=M.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});M.useEffect(()=>{i&&ce(!0)},[i]),M.useEffect(()=>{var Zt;oe&&Qt({first_name:oe.first_name||"",last_name:oe.last_name||"",email:oe.email||"",phone:oe.phone||"",address:oe.address||"",city:oe.city||"",state:oe.state||"",zip_code:oe.zip_code||"",birthday:oe.birthday||"",home_anniversary:oe.home_anniversary||"",spouse_name:oe.spouse_name||"",spouse_email:oe.spouse_email||"",lead_source_id:oe.lead_source_id||"",notes:oe.notes||"",tagIds:((Zt=oe.tags)==null?void 0:Zt.map(yr=>yr.relationship_type_id))||[]})},[oe]);const fs=M.useMemo(()=>{if(!d)return[];let Zt=d.filter(yr=>{var An,la,qa;const Gr=F===""||`${yr.first_name} ${yr.last_name}`.toLowerCase().includes(F.toLowerCase())||((An=yr.email)==null?void 0:An.toLowerCase().includes(F.toLowerCase()))||((la=yr.phone)==null?void 0:la.includes(F)),Dn=q==="all"||((qa=yr.tags)==null?void 0:qa.some(Jr=>Jr.relationship_type_id===q)),rs=b.size===0||(()=>{const Jr=(_==null?void 0:_.filter(Ka=>Ka.contact_id===yr.id).map(Ka=>Ka.tag_id))||[];return j==="any"?Jr.some(Ka=>b.has(Ka)):Array.from(b).every(Ka=>Jr.includes(Ka))})();return Gr&&Dn&&rs});return U==="not-touched-90"?Zt=Zt.filter(yr=>{const Gr=yr.relationshipScore.daysSinceTouch;return Gr===null||Gr>90}):U==="at-risk"?Zt=Zt.filter(yr=>yr.relationshipScore.status==="at-risk"):U==="cooling"?Zt=Zt.filter(yr=>yr.relationshipScore.status==="cooling"):U==="warm"?Zt=Zt.filter(yr=>yr.relationshipScore.status==="warm"):U==="has-deal"?Zt=Zt.filter(yr=>g&&g[yr.id]):U==="no-deal"?Zt=Zt.filter(yr=>!g||!g[yr.id]):U==="open-house"&&(Zt=Zt.filter(yr=>{var Dn;return(((Dn=yr.lead_source_ref)==null?void 0:Dn.name)||yr.lead_source)==="Open House"})),Zt=[...Zt].sort((yr,Gr)=>{switch(se){case"important-dates":{const Dn=wE(yr.birthday),rs=wE(Gr.birthday),An=wE(yr.home_anniversary),la=wE(Gr.home_anniversary),qa=[Dn,An].filter(Ka=>Ka!==null).sort((Ka,Dl)=>(Ka??1/0)-(Dl??1/0))[0]??1/0,Jr=[rs,la].filter(Ka=>Ka!==null).sort((Ka,Dl)=>(Ka??1/0)-(Dl??1/0))[0]??1/0;return qa-Jr}case"last-touched":{const Dn=yr.relationshipScore.lastTouchDate,rs=Gr.relationshipScore.lastTouchDate;return!Dn&&!rs?0:Dn?rs?new Date(Dn).getTime()-new Date(rs).getTime():1:-1}case"next-touch":{const Dn=yr.relationshipScore.daysSinceTouch,rs=Gr.relationshipScore.daysSinceTouch;return Dn===null&&rs===null?0:Dn===null?-1:rs===null?1:rs-Dn}case"score":return yr.relationshipScore.score-Gr.relationshipScore.score;case"date-added":{const Dn=yr.created_at,rs=Gr.created_at;return!Dn&&!rs?0:Dn?rs?new Date(rs).getTime()-new Date(Dn).getTime():-1:1}case"name":default:{const Dn=`${yr.first_name||""} ${yr.last_name||""}`.toLowerCase(),rs=`${Gr.first_name||""} ${Gr.last_name||""}`.toLowerCase();return Dn.localeCompare(rs)}}}),Zt},[d,F,q,b,j,U,se,g,_]),dr=fs.length,bt=Math.max(1,Math.ceil(dr/Le)),ws=Math.min(Ve,bt),ir=M.useMemo(()=>{const Zt=(ws-1)*Le;return fs.slice(Zt,Zt+Le)},[fs,ws,Le]);M.useEffect(()=>{dt(1)},[F,q,b,j,U,se]);const Rr=M.useCallback(()=>{Ie(!1),Pe(Zt=>Zt.size>0?new Set:new Set(ir.map(yr=>yr.id)))},[ir]),oa=M.useCallback(()=>{Ie(!0),Pe(new Set(fs.map(Zt=>Zt.id)))},[fs]),ri=M.useCallback((Zt,yr)=>{$(Zt.search||""),H(Zt.type||"all"),Q(Zt.status||"all"),te(yr||"name")},[]),no=()=>{Qt({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},Da=async Zt=>{Zt.preventDefault();const yr={...Kt,lead_source_id:Kt.lead_source_id||null};oe?(await A.mutateAsync({id:oe.id,...yr}),le(null)):(await S.mutateAsync(yr),ce(!1)),no()},yn=async Zt=>{confirm("Are you sure you want to delete this contact?")&&await I.mutateAsync(Zt)};return e.jsx(Ms,{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"})]}),je&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>Qe("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${fe==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(je.team.contact_visibility==="full_team"||je.team.contact_visibility==="leader_only"&&je.role==="team_leader")&&e.jsxs("button",{onClick:()=>Qe("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${fe==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(xr,{className:"h-3.5 w-3.5"}),"Team"]}),je.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>Qe("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${fe==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(zx,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(ec,{className:"h-4 w-4 mr-1"}),"Back"]})}),fe==="team"?e.jsx(_be,{}):fe==="lead-pond"&&je?e.jsx(bbe,{teamId:je.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(De,{children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or phone...",value:F,onChange:Zt=>$(Zt.target.value),className:"pl-9"})]}),e.jsxs(Z,{onClick:()=>ce(!0),className:"shrink-0",children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(Z,{variant:"outline",onClick:()=>xe(!0),className:"shrink-0",children:[e.jsx(xi,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(Z,{variant:"outline",onClick:()=>ye(!0),className:"shrink-0",children:[e.jsx(N0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(YDt,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(tr,{value:q,onValueChange:H,children:[e.jsx(Js,{className:"w-[145px] h-9 text-sm",children:e.jsx(rr,{placeholder:"Filter by type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),f==null?void 0:f.filter(Zt=>Zt.active).map(Zt=>e.jsx(At,{value:Zt.id,children:Zt.name},Zt.id))]})]}),v&&v.length>0&&e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(pp,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),b.size===0?"Filter by Tags":`${b.size} tag${b.size>1?"s":""}`]})}),e.jsx(jo,{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:()=>N("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${j==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>N("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${j==="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:v.map(Zt=>{const yr=b.has(Zt.id);return e.jsxs("button",{onClick:()=>{w(Gr=>{const Dn=new Set(Gr);return Dn.has(Zt.id)?Dn.delete(Zt.id):Dn.add(Zt.id),Dn})},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($o,{checked:yr,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Zt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Zt.name})]},Zt.id)})}),b.size>0&&e.jsx(Z,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>w(new Set),children:"Clear tags"})]})})]}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>rt(!0),title:"Manage Tags",children:e.jsx(Pl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs(tr,{value:U,onValueChange:Q,children:[e.jsx(Js,{className:"w-[145px] h-9 text-sm",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Status"}),e.jsx(At,{value:"warm",children:"🟢 Warm"}),e.jsx(At,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(At,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(At,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(At,{value:"no-deal",children:"📭 No Deal"}),e.jsx(At,{value:"open-house",children:"🏠 Open House"})]})]}),e.jsxs(tr,{value:se,onValueChange:te,children:[e.jsx(Js,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($c,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(rr,{placeholder:"Sort by"})]})}),e.jsxs(er,{children:[e.jsx(At,{value:"name",children:"Name (A-Z)"}),e.jsx(At,{value:"important-dates",children:"Important Dates"}),e.jsx(At,{value:"last-touched",children:"Last Touched"}),e.jsx(At,{value:"next-touch",children:"Next Touch Due"}),e.jsx(At,{value:"score",children:"Relationship Score"}),e.jsx(At,{value:"date-added",children:"Date Added"})]})]}),e.jsx(yOt,{currentFilters:{search:F,type:q,status:U},currentSortBy:se,onApplySmartList:ri})]})]})})}),e.jsx(pOt,{selectedIds:Ae,contacts:fs,onClearSelection:()=>{Pe(new Set),Ie(!1)},showLeadPondAction:He,onSendToLeadPond:zt,showTransferAction:ct,onTransfer:Je}),Ae.size>0&&Ae.size===ir.length&&!Fe&&dr>Le&&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 ",ir.length," contacts on this page are selected."]}),e.jsxs(Z,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:oa,children:["Select all ",dr.toLocaleString()," matching contacts"]})]}),Fe&&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 ",dr.toLocaleString()," matching contacts are selected.",e.jsx(Z,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Pe(new Set),Ie(!1)},children:"Clear selection"})]}),n?e.jsx("div",{className:"space-y-3",children:u?e.jsx(De,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):fs.length===0?e.jsx(De,{className:"p-6 text-center text-muted-foreground",children:F||q!=="all"||U!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):ir.map(Zt=>{var Gr,Dn,rs;const{relationshipScore:yr}=Zt;return e.jsx(De,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const An=new URLSearchParams;F&&An.set("search",F),q!=="all"&&An.set("type",q),U!=="all"&&An.set("filter",U);const la=An.toString();t(`/mission-control/contacts/${Zt.id}${la?`?${la}`:""}`)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[Zt.first_name," ",Zt.last_name]}),e.jsx(ei,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Zt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ar,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:Zt.email})]}),Zt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ga,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Zt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(kme,{score:yr,size:"sm"}),e.jsx(Axe,{contact:Zt}),(((Gr=Zt.lead_source_ref)==null?void 0:Gr.name)||Zt.lead_source)&&e.jsx(nt,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((Dn=Zt.lead_source_ref)==null?void 0:Dn.name)||Zt.lead_source}),(rs=Zt.tags)==null?void 0:rs.map(An=>{var la;return e.jsx(nt,{variant:"secondary",className:"text-xs",children:(la=An.relationship_type)==null?void 0:la.name},An.id)}),e.jsx(UTe,{contactId:Zt.id,tags:_==null?void 0:_.filter(An=>An.contact_id===Zt.id)}),e.jsx(qTe,{deal:g==null?void 0:g[Zt.id]})]}),e.jsx($Te,{birthday:Zt.birthday,homeAnniversary:Zt.home_anniversary,className:"mb-2",contactId:Zt.id,contactName:`${Zt.first_name}${Zt.last_name?" "+Zt.last_name:""}`,contactAddress:[Zt.address,Zt.city,Zt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[yr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),js(new Date(yr.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Zt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),js(new Date(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Hn,{className:"h-3 w-3"}),js(new Date(Zt.home_anniversary),"MMM d")]}),Zt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ys,{className:"h-3 w-3"}),"Added ",js(new Date(Zt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:An=>An.stopPropagation(),children:e.jsx(zTe,{contact:Zt,onEdit:le,onDelete:yn,onSnooze:(An,la)=>{ke(An),Ne(la)},showLeadPondAction:He,onSendToLeadPond:Lt,showTransferAction:ct,onTransfer:qe})})]})})},Zt.id)})}):e.jsx(De,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Pn,{className:"min-w-[800px]",children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx($o,{checked:ir.length>0&&ir.every(Zt=>Ae.has(Zt.id)),onCheckedChange:()=>Rr()})}),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:()=>te(se==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",se==="date-added"&&e.jsx($c,{className:"h-3 w-3"})]})}),e.jsx(kt,{children:"Important Dates"}),e.jsx(kt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Ln,{children:u?e.jsx(ks,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):fs.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:F||q!=="all"||U!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):ir.map(Zt=>{var Dn,rs,An;const{relationshipScore:yr}=Zt,Gr=g==null?void 0:g[Zt.id];return e.jsxs(ks,{className:`cursor-pointer hover:bg-accent/50 ${Ae.has(Zt.id)?"bg-accent/30":""}`,onClick:()=>{const la=new URLSearchParams;F&&la.set("search",F),q!=="all"&&la.set("type",q),U!=="all"&&la.set("status",U);const qa=la.toString();t(`/mission-control/contacts/${Zt.id}${qa?`?${qa}`:""}`)},children:[e.jsx(lt,{onClick:la=>la.stopPropagation(),children:e.jsx($o,{checked:Ae.has(Zt.id),onCheckedChange:()=>is(Zt.id)})}),e.jsxs(lt,{className:"font-medium",children:[Zt.first_name," ",Zt.last_name]}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(kme,{score:yr,size:"sm"}),e.jsx(Axe,{contact:Zt})]})}),e.jsx(lt,{children:e.jsx(kme,{score:yr,size:"sm",showScore:!0})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Zt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Ar,{className:"h-3 w-3"}),Zt.email]}),Zt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ga,{className:"h-3 w-3"}),Zt.phone]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((Dn=Zt.lead_source_ref)==null?void 0:Dn.name)||Zt.lead_source)&&e.jsx(nt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((rs=Zt.lead_source_ref)==null?void 0:rs.name)||Zt.lead_source}),(An=Zt.tags)==null?void 0:An.map(la=>{var qa;return e.jsx(nt,{variant:"secondary",className:"text-xs",children:(qa=la.relationship_type)==null?void 0:qa.name},la.id)}),e.jsx(UTe,{contactId:Zt.id,tags:_==null?void 0:_.filter(la=>la.contact_id===Zt.id)}),e.jsx(qTe,{deal:Gr})]})}),e.jsx(lt,{children:e.jsx("div",{className:"text-sm",children:yr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),js(new Date(yr.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Zt.created_at?js(new Date(Zt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx($Te,{birthday:Zt.birthday,homeAnniversary:Zt.home_anniversary,contactId:Zt.id,contactName:`${Zt.first_name}${Zt.last_name?" "+Zt.last_name:""}`,contactAddress:[Zt.address,Zt.city,Zt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Zt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),js(new Date(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Hn,{className:"h-3 w-3"}),js(new Date(Zt.home_anniversary),"MMM d")]})]})]})}),e.jsx(lt,{children:e.jsx(zTe,{contact:Zt,onEdit:le,onDelete:yn,onSnooze:(la,qa)=>{ke(la),Ne(qa)},showLeadPondAction:He,onSendToLeadPond:Lt,showTransferAction:ct,onTransfer:qe})})]},Zt.id)})})]})})}),dr>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 ",(ws-1)*Le+1,"–",Math.min(ws*Le,dr)," of ",dr.toLocaleString()," contacts"]}),e.jsxs(tr,{value:String(Le),onValueChange:Zt=>{Rt(Number(Zt)),dt(1)},children:[e.jsx(Js,{className:"w-[80px] h-8",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"50",children:"50"}),e.jsx(At,{value:"100",children:"100"}),e.jsx(At,{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(Z,{variant:"outline",size:"sm",disabled:ws<=1,onClick:()=>dt(1),children:"First"}),e.jsx(Z,{variant:"outline",size:"sm",disabled:ws<=1,onClick:()=>dt(Zt=>Zt-1),children:e.jsx(ec,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",ws," of ",bt]}),e.jsx(Z,{variant:"outline",size:"sm",disabled:ws>=bt,onClick:()=>dt(Zt=>Zt+1),children:e.jsx(ei,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"outline",size:"sm",disabled:ws>=bt,onClick:()=>dt(bt),children:"Last"})]})]}),e.jsx(bs,{open:Y||!!oe,onOpenChange:Zt=>{Zt||(ce(!1),le(null),no())},children:e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:oe?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:Da,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"first_name",children:"First Name *"}),e.jsx(Re,{id:"first_name",value:Kt.first_name,onChange:Zt=>Qt({...Kt,first_name:Zt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Re,{id:"last_name",value:Kt.last_name,onChange:Zt=>Qt({...Kt,last_name:Zt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:Kt.email,onChange:Zt=>Qt({...Kt,email:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",value:Kt.phone,onChange:Zt=>Qt({...Kt,phone:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"address",children:"Address"}),e.jsx(Re,{id:"address",value:Kt.address,onChange:Zt=>Qt({...Kt,address:Zt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:Kt.city,onChange:Zt=>Qt({...Kt,city:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:Kt.state,onChange:Zt=>Qt({...Kt,state:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Re,{id:"zip_code",value:Kt.zip_code,onChange:Zt=>Qt({...Kt,zip_code:Zt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Re,{id:"birthday",type:"date",value:Kt.birthday,onChange:Zt=>Qt({...Kt,birthday:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Re,{id:"home_anniversary",type:"date",value:Kt.home_anniversary,onChange:Zt=>Qt({...Kt,home_anniversary:Zt.target.value})})]})]}),oe&&e.jsx(Exe,{contactId:oe.id,currentSpouseContactId:(oe==null?void 0:oe.spouse_contact_id)||null,currentSpouseName:(oe==null?void 0:oe.spouse_name)||null,currentSpouseEmail:(oe==null?void 0:oe.spouse_email)||null,onLink:Zt=>L.mutate({contactId:oe.id,spouseContactId:Zt}),onUnlink:()=>L.mutate({contactId:oe.id,spouseContactId:null}),isEditing:!0}),e.jsx(pGe,{value:Kt.lead_source_id,onChange:Zt=>Qt({...Kt,lead_source_id:Zt})}),e.jsxs("div",{children:[e.jsx(_e,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:f==null?void 0:f.filter(Zt=>Zt.active).map(Zt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx($o,{checked:Kt.tagIds.includes(Zt.id),onCheckedChange:yr=>{Qt(yr?{...Kt,tagIds:[...Kt.tagIds,Zt.id]}:{...Kt,tagIds:Kt.tagIds.filter(Gr=>Gr!==Zt.id)})}}),e.jsx("span",{className:"text-sm",children:Zt.name})]},Zt.id))})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"notes",children:"Notes"}),e.jsx(Lr,{id:"notes",value:Kt.notes,onChange:Zt=>Qt({...Kt,notes:Zt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>{ce(!1),le(null),no()},children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:S.isPending||A.isPending,children:[oe?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(aOt,{open:de,onOpenChange:xe,relationshipTypes:(f==null?void 0:f.filter(Zt=>Zt.active))||[],onSuccess:()=>{xe(!1)}}),e.jsx(lOt,{open:be,onOpenChange:ye,onComplete:()=>ye(!1)}),e.jsx(hle,{open:!!ve,onOpenChange:Zt=>{Zt||ke(null)},contactId:ve||"",contactName:Ge}),e.jsx(bOt,{open:at,onOpenChange:rt}),e.jsx(mWe,{open:ht,onOpenChange:Ke,contactIds:We,contactNames:We.map(Zt=>{const yr=fs.find(Gr=>Gr.id===Zt);return yr?`${yr.first_name} ${yr.last_name||""}`.trim():""}),onComplete:()=>{Ze([]),Pe(new Set),Ie(!1)}})]})]})})}function jOt(){return Tt({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await K.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function kOt(t){return Tt({queryKey:["video-scripts",t],queryFn:async()=>{let s=K.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 NOt(){const{user:t}=Qs();return Tt({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await K.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 SOt(){const{user:t}=Qs(),s=ds();return Bt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await K.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 COt(t){const{user:s}=Qs();return Tt({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=K.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 MOt(t){return Tt({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await K.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 XN(){const{user:t}=Qs(),s=ds();return Bt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await K.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 TOt(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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 AOt(){const t=ds();return Bt({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 K.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 K.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await K.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 fle(){const{user:t}=Qs();return Tt({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await K.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 fGe(){const{data:t,isLoading:s}=fle(),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 EL(t){const{data:s,error:r}=await K.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function PL(t){const{data:s,error:r}=await K.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function y3(t){const{data:s,error:r}=await K.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function EOt(){const{user:t}=Qs(),s=ds();return Bt({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await K.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 K.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 POt(t){return Tt({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 IOt(t){return Tt({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function Lbe(){const t=vi(),s=ds();return Bt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await K.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 IL(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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 LOt(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 DOt(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 OOt(){const t=ds();return Bt({mutationFn:async({id:s,dealId:r})=>{await K.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await K.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 gGe(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 ROt(){const t=vi();return Tt({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 FOt(){const t=vi(),s=ds();return Bt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await K.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 zOt(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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 BOt(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function M0(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function $Ot({contactId:t}){const s=Or(),r=ds(),[n,a]=M.useState(null),[o,l]=M.useState(!1),[i,d]=M.useState(!1),[u,f]=M.useState(""),[g,v]=M.useState(""),[_,b]=M.useState(null),w=IL(),j=gGe(),{data:N,isLoading:S}=Tt({queryKey:["contact-portals",t],queryFn:async()=>{const{data:q,error:H}=await K.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(H)throw H;if(!q||q.length===0)return[];const U=q.map(te=>te.id),{data:Q,error:se}=await K.from("client_portals").select("*").in("deal_id",U).is("archived_at",null);if(se)throw se;return(Q||[]).map(te=>({...te,deal:q.find(Y=>Y.id===te.deal_id)}))},enabled:!!t}),A=(N==null?void 0:N.map(q=>q.id))||[],{data:I}=Tt({queryKey:["contact-portal-updates",A],queryFn:async()=>{if(A.length===0)return{};const{data:q,error:H}=await K.from("portal_updates").select("*").in("portal_id",A).order("created_at",{ascending:!1});if(H)throw H;const U={};return(q||[]).forEach(Q=>{U[Q.portal_id]||(U[Q.portal_id]=Q)}),U},enabled:A.length>0}),L=q=>{navigator.clipboard.writeText(M0(q)),a(q),ge.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},F=async q=>{u.trim()&&(await j.mutateAsync({portal_id:q,title:u,content:g||void 0}),d(!1),f(""),v(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),ge.success("Portal update posted!"))},$=async()=>{_&&(await w.mutateAsync({id:_.id,welcome_message:_.welcome_message,next_step_text:_.next_step_text,is_enabled:_.is_enabled,show_post_close_tips:_.show_post_close_tips,review_url:_.review_url}),l(!1),b(null),r.invalidateQueries({queryKey:["contact-portals",t]}),ge.success("Portal settings updated!"))};return S||!N||N.length===0?null:e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(up,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Oe,{className:"space-y-3",children:N.map(q=>{var se,te,Y;const H=((se=q.stage_mapping)==null?void 0:se.length)>0?q.stage_mapping:H1e(((te=q.deal)==null?void 0:te.deal_type)||"buyer"),U=H==null?void 0:H[q.current_stage_index??0],Q=I==null?void 0:I[q.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:((Y=q.deal)==null?void 0:Y.deal_name)||"Portal"}),U&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",U.label||U.name]})]}),e.jsx(nt,{variant:q.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:q.is_enabled?"Active":"Disabled"})]}),Q&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:Q.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:js(new Date(Q.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(Z,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>L(q.slug),children:[n===q.slug?e.jsx(ma,{className:"h-3 w-3 mr-1"}):e.jsx(Ni,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(Z,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(M0(q.slug),"_blank"),children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(bs,{open:i,onOpenChange:d,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>d(!0),children:[e.jsx(ho,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Re,{value:u,onChange:ce=>f(ce.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Details (optional)"}),e.jsx(Lr,{value:g,onChange:ce=>v(ce.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(Z,{onClick:()=>F(q.id),disabled:!u.trim()||j.isPending,className:"w-full",children:[e.jsx(Pa,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(bs,{open:o,onOpenChange:l,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{b({...q}),l(!0)},children:[e.jsx(Pl,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Portal Settings"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Portal Enabled"}),e.jsx(qr,{checked:_.is_enabled,onCheckedChange:ce=>b({..._,is_enabled:ce})})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Welcome Message"}),e.jsx(Lr,{value:_.welcome_message||"",onChange:ce=>b({..._,welcome_message:ce.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Next Step"}),e.jsx(Re,{value:_.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(_e,{children:"Review URL"}),e.jsx(Re,{value:_.review_url||"",onChange:ce=>b({..._,review_url:ce.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Show Post-Close Tips"}),e.jsx(qr,{checked:_.show_post_close_tips,onCheckedChange:ce=>b({..._,show_post_close_tips:ce})})]}),e.jsx(Jl,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{onClick:$,disabled:w.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(Z,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${q.deal_id}`),children:[e.jsx(Ai,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),N.length>1&&e.jsx(Jl,{})]},q.id)})})]})}function qOt({videoId:t}){var l;const{data:s,isLoading:r,error:n}=MOt(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"w-full aspect-video rounded-lg"}),e.jsx(gs,{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(jh,{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 d=i;return d.includes("iframe.mediadelivery.net/play/")&&(d=d.replace("/play/","/embed/"),d+=(d.includes("?")?"&":"?")+"autoplay=true&responsive=true"),d},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 UOt({contactId:t}){const s=Or(),[r,n]=M.useState(!1),{data:a,isLoading:o}=Tt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:g,error:v}=await K.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(v)throw v;return g},enabled:!!t}),l=async(g,v)=>{const _=v==="done"?"todo":"done";await K.from("deal_tasks").update({status:_,completed_at:_==="done"?new Date().toISOString():null}).eq("id",g),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=Tt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:g,error:v}=await K.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(v)throw v;return g},enabled:!!t}),d={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(g=>g.status!=="done"))||[],f=(a==null?void 0:a.filter(g=>g.status==="done"))||[];return e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(ma,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(Ys,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Oe,{className:"space-y-1",children:o?e.jsx(gs,{className:"h-8 w-full"}):u.length===0&&f.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(g=>e.jsxs("button",{onClick:async()=>{await l(g.id,g.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:[d[g.priority]," ",g.title]}),g.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:js(new Date(g.due_date),"MMM d")})]},g.id)),f.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:[f.length," completed"]})})]})}),r&&e.jsx(VOt,{contactId:t,open:r,onOpenChange:g=>{n(g),g||i()}})]})}function VOt({contactId:t,open:s,onOpenChange:r}){const[n,a]=M.useState(""),[o,l]=M.useState("medium"),[i,d]=M.useState(),{data:u}=Tt({queryKey:["session"],queryFn:async()=>{const{data:g}=await K.auth.getSession();return g.session}}),f=async()=>{var v;if(!n.trim()||!((v=u==null?void 0:u.user)!=null&&v.id))return;const{error:g}=await K.from("deal_tasks").insert([{owner_user_id:u.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?js(i,"yyyy-MM-dd"):null}]);if(g){console.error("Task create error:",g);return}r(!1)};return e.jsx(bs,{open:s,onOpenChange:r,children:e.jsxs(_s,{className:"sm:max-w-[400px]",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Re,{value:n,onChange:g=>a(g.target.value),placeholder:"Task title...",onKeyDown:g=>g.key==="Enter"&&f()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Priority"}),e.jsxs("select",{value:o,onChange:g=>l(g.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(_e,{children:"Due Date"}),e.jsx(Re,{type:"date",value:i?js(i,"yyyy-MM-dd"):"",onChange:g=>d(g.target.value?new Date(g.target.value+"T00:00:00"):void 0)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(Z,{onClick:f,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function HOt({contactId:t}){const s=Or(),{data:r,isLoading:n}=Tt({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await K.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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(Zu,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Oe,{className:"space-y-2",children:r.map(a=>{const o=a.stage;return e.jsx("button",{onClick:()=>s(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(nt,{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(Ai,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function WOt(){var He,ct,We,Ze,ht;const{contactId:t}=Uo(),s=Or(),[r]=Gc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=gjt(t||""),{data:d}=Vg(),{data:u}=Doe(),{data:f}=Ooe(365),{data:g}=mle(365),{data:v}=POt(t),{contactsWithScores:_}=y_e(),b=G$e(),w=f_e(),j=g_e(),N=K$e(),[S,A]=M.useState(!1),[I,L]=M.useState({}),[F,$]=M.useState(!1),[q,H]=M.useState(null),[U,Q]=M.useState(""),[se,te]=M.useState(void 0),[Y,ce]=M.useState(""),[oe,le]=M.useState(null),[de,xe]=M.useState(!1),[be,ye]=M.useState(null),{isGmailConnected:ve,gmailEmail:ke}=G0(),{data:Ge}=Tt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:Ke,error:qe}=await K.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(qe)throw qe;return Ke},enabled:!!t}),Ne=Ke=>{if(!Ke)return null;const qe=Ke.match(/Video ID:\s*([a-f0-9-]+)/i);return qe?qe[1]:null},Ae=M.useMemo(()=>{if(!_)return[];let Ke=_.filter(qe=>{var zt,is,Kt;const Je=n===""||`${qe.first_name} ${qe.last_name}`.toLowerCase().includes(n.toLowerCase())||((zt=qe.email)==null?void 0:zt.toLowerCase().includes(n.toLowerCase()))||((is=qe.phone)==null?void 0:is.includes(n)),Lt=a==="all"||((Kt=qe.tags)==null?void 0:Kt.some(Qt=>Qt.relationship_type_id===a));return Je&&Lt});return o==="not-touched-90"?Ke=Ke.filter(qe=>{const Je=qe.relationshipScore.daysSinceTouch;return Je===null||Je>90}):o==="at-risk"?Ke=Ke.filter(qe=>qe.relationshipScore.status==="at-risk"):o==="cooling"?Ke=Ke.filter(qe=>qe.relationshipScore.status==="cooling"):o==="warm"&&(Ke=Ke.filter(qe=>qe.relationshipScore.status==="warm")),Ke.map(qe=>qe.id)},[_,n,a,o]),Pe=Ae.indexOf(t||""),Fe=Pe>0?Ae[Pe-1]:null,Ie=Pe1&&Pe!==-1,dt=Ke=>{const qe=new URLSearchParams;n&&qe.set("search",n),a!=="all"&&qe.set("type",a),o!=="all"&&qe.set("status",o);const Je=qe.toString();return`/mission-control/contacts/${Ke}${Je?`?${Je}`:""}`},Le=M.useMemo(()=>{const Ke=((f==null?void 0:f.filter(Je=>Je.contact_id===t))||[]).map(Je=>{var Kt,Qt,fs;const Lt=Ne(Je.notes);let zt=((Kt=Je.action_type)==null?void 0:Kt.name)||"Touch",is=Je.notes;if(zt==="Other"&&((Qt=Je.notes)!=null&&Qt.startsWith("["))){const dr=Je.notes.indexOf("]");dr>0&&(zt=Je.notes.substring(1,dr),is=Je.notes.substring(dr+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:Je.id,type:"touch",completed_at:Je.completed_at,name:zt,color:((fs=Je.action_type)==null?void 0:fs.color)||"#3B82F6",notes:is,videoId:Lt}}),qe=((g==null?void 0:g.filter(Je=>Je.contact_id===t))||[]).map(Je=>({id:Je.id,type:"popby",completed_at:Je.completed_at,name:"Pop-by",color:"#F97316",notes:Je.notes,videoId:null}));return[...Ke,...qe].sort((Je,Lt)=>new Date(Lt.completed_at).getTime()-new Date(Je.completed_at).getTime())},[f,g,t]),Rt=()=>{var Ke;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:((Ke=l.tags)==null?void 0:Ke.map(qe=>qe.relationship_type_id))||[]}),A(!0))},fe=async()=>{await b.mutateAsync({id:t,...I,lead_source_id:I.lead_source_id||null}),A(!1)},Qe=async()=>{confirm("Are you sure you want to delete this contact?")&&(await w.mutateAsync(t),s("/mission-control/contacts"))},rt=((He=u==null?void 0:u.find(Ke=>Ke.id===q))==null?void 0:He.name)==="Other",je=async()=>{if(!q||rt&&!Y.trim())return;const Ke=se?new Date(se.getFullYear(),se.getMonth(),se.getDate(),12,0,0).toISOString():void 0,qe=rt?`[${Y.trim()}]${U?" — "+U:""}`:U;await j.mutateAsync({contactId:t,actionTypeId:q,notes:qe,completedAt:Ke}),$(!1),H(null),Q(""),te(void 0),ce("")},mt=(Ke,qe)=>{ve&&l?(ye({email:Ke,name:qe||`${l.first_name} ${l.last_name||""}`.trim()}),xe(!0)):window.location.href=`mailto:${Ke}`};return i?e.jsx(Ms,{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(Ms,{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(Z,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/contacts"),children:[e.jsx(ec,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),Ve&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>Fe&&s(dt(Fe)),disabled:!Fe,className:"px-2",children:[e.jsx(ec,{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:[Pe+1," of ",Ae.length]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>Ie&&s(dt(Ie)),disabled:!Ie,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(ei,{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(Z,{variant:"outline",onClick:()=>mt(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(Ar,{className:"h-4 w-4 mr-1"}),"Email"]}),e.jsxs(Z,{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(bs,{open:F,onOpenChange:$,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(Ke=>Ke.active).map(Ke=>e.jsxs("button",{onClick:()=>H(Ke.id),className:` p-3 rounded-lg border text-left transition-all ${q===Ke.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:Ke.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ke.description})]},Ke.id))}),rt&&e.jsxs("div",{className:"mt-3",children:[e.jsx(_e,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(Re,{id:"custom-action-name",value:Y,onChange:Ke=>ce(Ke.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Date (optional — backdate if needed)"}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("w-full justify-start text-left font-normal mt-2",!se&&"text-muted-foreground"),children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),se?js(se,"PPP"):"Today (default)"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:se,onSelect:te,disabled:Ke=>Ke>new Date,initialFocus:!0,className:It("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Lr,{id:"action-notes",value:U,onChange:Ke=>Q(Ke.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(Z,{onClick:je,disabled:!q||rt&&!Y.trim()||j.isPending,className:"w-full",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(Z,{variant:"outline",onClick:Rt,children:[e.jsx(Pc,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(Z,{variant:"destructive",size:"icon",onClick:Qe,children:e.jsx(Cr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"bg-card border rounded-lg p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold",children:[l.first_name," ",l.last_name||""]}),(((ct=l.lead_source_ref)==null?void 0:ct.name)||l.lead_source)&&e.jsx(nt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((We=l.lead_source_ref)==null?void 0:We.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:()=>mt(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(Ar,{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(ga,{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(Axe,{contact:l}),(Ze=l.tags)==null?void 0:Ze.map(Ke=>{const qe=d==null?void 0:d.find(Je=>Je.id===Ke.relationship_type_id);return qe?e.jsx(nt,{variant:"secondary",className:"text-xs",children:qe.name},Ke.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(_Ot,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(De,{className:"md:col-span-2",children:[e.jsx($t,{children:e.jsx(Vt,{children:"Contact Information"})}),e.jsx(Oe,{children:S?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"first_name",children:"First Name"}),e.jsx(Re,{id:"first_name",value:I.first_name,onChange:Ke=>L({...I,first_name:Ke.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Re,{id:"last_name",value:I.last_name,onChange:Ke=>L({...I,last_name:Ke.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:I.email,onChange:Ke=>L({...I,email:Ke.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",value:I.phone,onChange:Ke=>L({...I,phone:Ke.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"address",children:"Street Address"}),e.jsx(Re,{id:"address",value:I.address,onChange:Ke=>L({...I,address:Ke.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(_e,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:I.city,onChange:Ke=>L({...I,city:Ke.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:I.state,onChange:Ke=>L({...I,state:Ke.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(Re,{id:"zip_code",value:I.zip_code,onChange:Ke=>L({...I,zip_code:Ke.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(_e,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Re,{id:"birthday",type:"date",value:I.birthday,onChange:Ke=>L({...I,birthday:Ke.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Re,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:Ke=>L({...I,home_anniversary:Ke.target.value})})]})]}),e.jsx(Jl,{}),e.jsx(Exe,{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:Ke=>N.mutate({contactId:t,spouseContactId:Ke}),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(_e,{htmlFor:"company_name",children:"Company"}),e.jsx(Re,{id:"company_name",value:I.company_name,onChange:Ke=>L({...I,company_name:Ke.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"job_title",children:"Job Title"}),e.jsx(Re,{id:"job_title",value:I.job_title,onChange:Ke=>L({...I,job_title:Ke.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(pGe,{value:I.lead_source_id||"",onChange:Ke=>L({...I,lead_source_id:Ke})}),e.jsxs("div",{children:[e.jsx(_e,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d==null?void 0:d.filter(Ke=>Ke.active).map(Ke=>{var qe;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx($o,{checked:(qe=I.tagIds)==null?void 0:qe.includes(Ke.id),onCheckedChange:Je=>{var Lt;L(Je?{...I,tagIds:[...I.tagIds||[],Ke.id]}:{...I,tagIds:(Lt=I.tagIds)==null?void 0:Lt.filter(zt=>zt!==Ke.id)})}}),e.jsx("span",{className:"text-sm",children:Ke.name})]},Ke.id)})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"notes",children:"Notes"}),e.jsx(Lr,{id:"notes",value:I.notes,onChange:Ke=>L({...I,notes:Ke.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{onClick:fe,disabled:b.isPending,children:"Save Changes"}),e.jsx(Z,{variant:"outline",onClick:()=>A(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[Le.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",js(new Date(Le[0].completed_at),"MMM d, yyyy")," ","(",Le[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(Ar,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>mt(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(ga,{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(Pi,{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(nn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",js(new Date(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",js(new Date(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ys,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",js(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(Jl,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Exe,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:Ke=>N.mutate({contactId:t,spouseContactId:Ke}),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(_a,{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(Jl,{}),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:(ht=l.tags)!=null&&ht.length?l.tags.map(Ke=>{var qe;return e.jsx(nt,{variant:"secondary",children:(qe=Ke.relationship_type)==null?void 0:qe.name},Ke.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(Jl,{}),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(tOt,{contact:l,onLogTouch:()=>$(!0)}),e.jsx(HOt,{contactId:t}),e.jsx($Ot,{contactId:t}),e.jsx(UOt,{contactId:t}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Activity Log"})}),e.jsx(Oe,{children:Le.length>0?e.jsx("div",{className:"space-y-4",children:Le.map(Ke=>{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:Ke.color},children:Ke.type==="popby"?e.jsx(uo,{className:"h-4 w-4"}):(qe=Ke.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:Ke.name}),Ke.videoId&&e.jsxs(Z,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>le(Ke.videoId),children:[e.jsx(dl,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:js(new Date(Ke.completed_at),"MMM d, yyyy h:mm a")}),Ke.notes&&!Ke.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ke.notes})]})]},Ke.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),v&&v.length>0&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(ho,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:v.map(Ke=>{var qe,Je;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(qe=Ke.video)!=null&&qe.thumbnail_url?e.jsx("img",{src:Ke.video.thumbnail_url,alt:Ke.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>le(Ke.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:()=>le(Ke.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: ",((Je=Ke.video)==null?void 0:Je.title)||"Untitled Video"]}),e.jsxs(Z,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>le(Ke.video_id),children:[e.jsx(dl,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:js(new Date(Ke.created_at),"MMM d, yyyy h:mm a")}),Ke.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',Ke.message,'"']})]})]},Ke.id)})})})]}),Ge&&Ge.length>0&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Pa,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:Ge.map(Ke=>e.jsxs(bs,{children:[e.jsx(Si,{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(Ar,{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:Ke.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",Ke.to_email," · ",js(new Date(Ke.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(ei,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Ar,{className:"h-5 w-5 text-sky-500"}),Ke.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",Ke.to_email," · ",js(new Date(Ke.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:Ke.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${Ke.subject}`})})]})]},Ke.id))})})]})]}),e.jsx(bs,{open:!!oe,onOpenChange:Ke=>!Ke&&le(null),children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Video Preview"})}),oe&&e.jsx(qOt,{videoId:oe})]})})]})]})}),ve&&l&&be&&e.jsx(AL,{open:de,onOpenChange:xe,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:be.email},gmailEmail:ke})]}):e.jsx(Ms,{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(Z,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const HTe={Crown:Dh,FileText:Un,Users:xr,Globe:up,Star:Gn,Phone:ga,MessageSquare:ho,PenTool:Jk,Video:Cn,Gift:uo},Nme=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function GOt(){var ht,Ke;const t=Or(),{user:s}=Qs(),{data:r}=Vg(),{data:n}=yjt(),{data:a}=Njt(),{data:o}=W$e(),{data:l}=Doe(),{data:i}=xjt(),d=Sjt(),u=vjt(),f=bjt(),g=wjt(),v=jjt(),_=kjt(),b=_jt(),[w,j]=M.useState(null),[N,S]=M.useState(!1),[A,I]=M.useState(null),[L,F]=M.useState(""),[$,q]=M.useState(""),[H,U]=M.useState([]),[Q,se]=M.useState(null),[te,Y]=M.useState(null),[ce,oe]=M.useState(!1),[le,de]=M.useState(""),[xe,be]=M.useState(""),[ye,ve]=M.useState(""),[ke,Ge]=M.useState(""),Ne=(qe,Je)=>a==null?void 0:a.some(Lt=>Lt.plan_id===qe&&Lt.relationship_type_id===Je&&Lt.active),Ae=qe=>a==null?void 0:a.find(Je=>Je.relationship_type_id===qe&&Je.active),Pe=async(qe,Je)=>{const Lt=Ne(qe,Je);await d.mutateAsync({planId:qe,relationshipTypeId:Je,active:!Lt})},Fe=(n==null?void 0:n.filter(qe=>qe.active&&!qe.owner_user_id))||[],Ie=(n==null?void 0:n.filter(qe=>qe.owner_user_id===(s==null?void 0:s.id)))||[],Ve=r==null?void 0:r.find(qe=>qe.id===w),dt=w?Ae(w):null,Le=n==null?void 0:n.find(qe=>qe.id===(dt==null?void 0:dt.plan_id)),Rt=async()=>{if(!L.trim())return;const qe=await u.mutateAsync({name:L,description:$});qe&&H.length>0&&await v.mutateAsync({planId:qe.id,items:H}),at()},fe=async()=>{!L.trim()||!A||(await f.mutateAsync({id:A,name:L,description:$}),await v.mutateAsync({planId:A,items:H}),at())},Qe=qe=>{var Je;I(qe.id),F(qe.name),q(qe.description||""),U(((Je=qe.items)==null?void 0:Je.map(Lt=>({month_number:Lt.month_number,action_type_id:Lt.action_type_id,default_script_id:Lt.default_script_id||void 0,notes:Lt.notes||void 0})))||[]),S(!0)},at=()=>{S(!1),I(null),F(""),q(""),U([])},rt=(qe,Je)=>{Y(Je)},je=(qe,Je,Lt)=>{U(zt=>[...zt.filter(Kt=>Kt.month_number!==qe),{month_number:qe,action_type_id:Je,default_script_id:Lt}]),se(null),Y(null)},mt=qe=>{U(Je=>Je.filter(Lt=>Lt.month_number!==qe))},He=async()=>{if(!le.trim()||!xe.trim()||!te)return;const qe=await _.mutateAsync({actionTypeId:te,title:le,scriptBody:xe,emailSubject:ye||void 0,tone:ke||void 0});qe&&Q!==null&&je(Q,te,qe.id),oe(!1),de(""),be(""),ve(""),Ge("")},ct=te?i==null?void 0:i.filter(qe=>qe.action_type_id===te&&qe.active):[],We=qe=>HTe[qe||"Phone"]||ga,Ze=qe=>HTe[qe||"Users"]||xr;return e.jsxs(Ms,{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(Z,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(ec,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(Z,{onClick:()=>S(!0),className:"w-full sm:w-auto",children:[e.jsx(Ys,{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 Je=Ze(qe.icon),Lt=(o==null?void 0:o[qe.id])||0,zt=Ae(qe.id),is=n==null?void 0:n.find(Qt=>Qt.id===(zt==null?void 0:zt.plan_id)),Kt=w===qe.id;return e.jsxs("button",{onClick:()=>j(qe.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Kt?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(Je,{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:[Lt," contacts"]})]}),is?e.jsxs(nt,{variant:"secondary",className:"text-xs",children:[e.jsx(hi,{className:"h-3 w-3 mr-1"}),is.name.split(" ")[0]]}):e.jsx(nt,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},qe.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:w&&Ve?e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[(()=>{const qe=Ze(Ve.icon);return e.jsx(qe,{className:"h-5 w-5"})})(),Ve.name," Touchpoint Plan"]}),e.jsxs(_r,{children:["Choose a plan for your ",Ve.name," contacts"]})]}),e.jsxs(Oe,{className:"space-y-6",children:[Le&&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(hi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",Le.name]}),Le.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Le.description})]}),e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>Pe(Le.id,w),children:"Disable"})]}),Le.items&&Le.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(nn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:Nme.map((qe,Je)=>{var Kt,Qt;const Lt=((Kt=Le.items)==null?void 0:Kt.filter(fs=>fs.month_number===Je+1))||[],zt=(Qt=Lt[0])==null?void 0:Qt.action_type,is=zt?We(zt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Lt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:qe}),is&&e.jsx(is,{className:"h-4 w-4 mx-auto mt-1",style:{color:(zt==null?void 0:zt.color)||"#3B82F6"}})]},Je)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:Le?"Switch to a Different Plan":"Choose a Plan"}),Fe.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"}),Fe.map(qe=>{var Lt;const Je=(Le==null?void 0:Le.id)===qe.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${Je?"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:[((Lt=qe.items)==null?void 0:Lt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:b.isPending,onClick:()=>{const zt=`${qe.name} (Copy)`;b.mutate({sourcePlanId:qe.id,newName:zt})},children:e.jsx(Ni,{className:"h-4 w-4"})}),e.jsx(Z,{size:"sm",variant:Je?"outline":"default",disabled:Je||d.isPending,onClick:()=>Pe(qe.id,w),children:Je?"Active":"Use This"})]})]},qe.id)})]}),Ie.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),Ie.map(qe=>{var Lt;const Je=(Le==null?void 0:Le.id)===qe.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${Je?"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:[((Lt=qe.items)==null?void 0:Lt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Qe(qe),children:e.jsx(Cx,{className:"h-4 w-4"})}),e.jsx(Z,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>g.mutate(qe.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})}),e.jsx(Z,{size:"sm",variant:Je?"outline":"default",disabled:Je||d.isPending,onClick:()=>Pe(qe.id,w),children:Je?"Active":"Use This"})]})]},qe.id)})]}),Fe.length===0&&Ie.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(De,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(nn,{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(De,{className:"bg-muted/50",children:e.jsx(Oe,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(bs,{open:N,onOpenChange:qe=>{qe?S(!0):at()},children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:A?"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(_e,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(Re,{id:"plan-name",value:L,onChange:qe=>F(qe.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Lr,{id:"plan-description",value:$,onChange:qe=>q(qe.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(_e,{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:Nme.map((qe,Je)=>{const Lt=Je+1,zt=H.find(Qt=>Qt.month_number===Lt),is=zt?l==null?void 0:l.find(Qt=>Qt.id===zt.action_type_id):null,Kt=is?We(is.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>se(Q===Lt?null:Lt),className:` w-full p-3 rounded-lg border text-center transition-all ${zt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${Q===Lt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:qe}),Kt?e.jsx(Kt,{className:"h-5 w-5 mx-auto mt-1",style:{color:(is==null?void 0:is.color)||"#3B82F6"}}):e.jsx(Ys,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),zt&&e.jsx("button",{type:"button",onClick:Qt=>{Qt.stopPropagation(),mt(Lt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Vr,{className:"h-3 w-3"})})]},Je)})}),Q!==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 ",Nme[Q-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(qe=>qe.active).map(qe=>{const Je=We(qe.icon);return e.jsxs("button",{type:"button",onClick:()=>rt(Q,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(Je,{className:"h-4 w-4",style:{color:qe.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:qe.name})]},qe.id)})})]}),Q!==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(Z,{variant:"ghost",size:"sm",onClick:()=>Y(null),children:[e.jsx(ec,{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:()=>je(Q,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"})]})}),ct==null?void 0:ct.map(qe=>e.jsx("button",{type:"button",onClick:()=>je(Q,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(nt,{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:()=>oe(!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(Ys,{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"})]})]})]})]})]}),H.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[H.length," touchpoint",H.length!==1?"s":""," per year"]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:at,children:"Cancel"}),e.jsxs(Z,{onClick:A?fe:Rt,disabled:!L.trim()||u.isPending||f.isPending,children:[e.jsx(zh,{className:"h-4 w-4 mr-2"}),A?"Save Changes":"Create Plan"]})]})]})}),e.jsx(bs,{open:ce,onOpenChange:oe,children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script-title",children:"Script Title"}),e.jsx(Re,{id:"script-title",value:le,onChange:qe=>de(qe.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(tr,{value:ke,onValueChange:Ge,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select tone..."})}),e.jsxs(er,{children:[e.jsx(At,{value:"friendly",children:"Friendly"}),e.jsx(At,{value:"professional",children:"Professional"}),e.jsx(At,{value:"casual",children:"Casual"}),e.jsx(At,{value:"formal",children:"Formal"})]})]})]}),((Ke=(ht=l==null?void 0:l.find(qe=>qe.id===te))==null?void 0:ht.name)==null?void 0:Ke.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(Re,{id:"script-email-subject",value:ye,onChange:qe=>ve(qe.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Lr,{id:"script-body",value:xe,onChange:qe=>be(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(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>oe(!1),children:"Cancel"}),e.jsxs(Z,{onClick:He,disabled:!le.trim()||!xe.trim()||_.isPending,children:[e.jsx(zh,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const KOt="0dde5abb-0005-4c8c-a471-30d0cbc9e280",ZOt=[{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 YOt(){const t=Or(),s=dGe(),{data:r}=oGe(),{data:n}=Vg(),{data:a}=Pbe(),{data:o}=mle(90),{data:l}=Im(),i=JDt(),d=uGe(),u=XDt(),f=QDt(),{data:g=[],isLoading:v}=Tt({queryKey:["popby-templates"],queryFn:async()=>{const{data:ce,error:oe}=await K.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",KOt).order("publish_date",{ascending:!1});if(oe)throw oe;const{data:le}=await K.from("template_likes").select("template_id"),{data:de}=await K.from("template_comments").select("template_id"),xe=new Map;le==null||le.forEach(ye=>{xe.set(ye.template_id,(xe.get(ye.template_id)||0)+1)});const be=new Map;return de==null||de.forEach(ye=>{be.set(ye.template_id,(be.get(ye.template_id)||0)+1)}),(ce||[]).map(ye=>({...ye,likesCount:xe.get(ye.id)||0,commentsCount:be.get(ye.id)||0}))}}),_=ce=>{const oe=l==null?void 0:l.find(le=>le.id===ce);return oe?`${oe.first_name} ${oe.last_name||""}`.trim():"Unknown"},b=ce=>{if(!ce)return null;const oe=r==null?void 0:r.find(le=>le.id===ce);return(oe==null?void 0:oe.name)||null},[w,j]=M.useState(null),[N,S]=M.useState(!1),[A,I]=M.useState(!1),[L,F]=M.useState(!1),[$,q]=M.useState({popby_item_id:"",notes:""}),[H,U]=M.useState({name:"",description:""}),Q=async()=>{w&&(await d.mutateAsync({contact_id:w.id,popby_item_id:$.popby_item_id||void 0,notes:$.notes||void 0}),S(!1),j(null),q({popby_item_id:"",notes:""}))},se=async()=>{H.name.trim()&&(await u.mutateAsync({name:H.name.trim(),description:H.description.trim()||void 0}),F(!1),U({name:"",description:""}))},te=async(ce,oe)=>{await f.mutateAsync({relationship_type_id:ce,frequency_days:parseInt(oe)})},Y=ce=>{var le;const oe=a==null?void 0:a.find(de=>de.relationship_type_id===ce);return((le=oe==null?void 0:oe.frequency_days)==null?void 0:le.toString())||"90"};return e.jsx(Ms,{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(De,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-primary",children:i.thisWeekCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Week"})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-emerald-500",children:i.thisMonthCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Month"})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Z,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(Pi,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(Z,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(Pl,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(Z,{variant:"outline",onClick:()=>F(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(Ia,{defaultValue:"due",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"due",children:"Due for Popby"}),e.jsx(Ts,{value:"activity",children:"Recent Activity"}),e.jsx(Ts,{value:"library",children:"Popby Library"}),e.jsx(Ts,{value:"templates",children:"Popby Templates"})]}),e.jsx(Vs,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(uo,{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(De,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium",children:[ce.first_name," ",ce.last_name]}),ce.daysOverdue>0&&e.jsxs(nt,{variant:"destructive",className:"text-xs",children:[ce.daysOverdue,"+ days overdue"]}),ce.daysSinceLastPopby===null&&e.jsx(nt,{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(Pi,{className:"h-3 w-3"}),ce.city||ce.address]}),ce.tags&&ce.tags.length>0&&e.jsx("span",{children:ce.tags.map(oe=>{var le;return(le=oe.relationship_type)==null?void 0:le.name}).join(", ")})]}),ce.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",js(new Date(ce.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ce.phone&&e.jsx(Z,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${ce.phone}`,children:e.jsx(ga,{className:"h-4 w-4"})})}),e.jsxs(Z,{size:"sm",onClick:()=>{j(ce),S(!0)},children:[e.jsx(hi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ce.id))})}),e.jsx(Vs,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Tn,{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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Oe,{className:"space-y-3",children:o.map(ce=>e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0 last:pb-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(uo,{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:_(ce.contact_id)}),b(ce.popby_item_id)&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:b(ce.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:js(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(Vs,{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(De,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(uo,{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(nt,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},ce.id)),e.jsx(De,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>F(!0),children:e.jsx(Oe,{className:"p-4 flex items-center justify-center h-full min-h-[100px]",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Ys,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(Vs,{value:"templates",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[g.length," template",g.length!==1?"s":""," found"]}),v&&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,oe)=>e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(gs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(gs,{className:"h-5 w-16"}),e.jsx(gs,{className:"h-5 w-20"})]})]})},oe))}),!v&&g.length===0&&e.jsx(De,{children:e.jsxs(Oe,{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."})]})}),!v&&g.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:g.map(ce=>e.jsxs(De,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${ce.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:ce.preview_image_url?e.jsx("img",{src:ce.preview_image_url,alt:ce.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"})}),e.jsxs(Oe,{className:"p-4 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:ce.name}),ce.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:$ie(ce.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(nt,{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(lu,{className:"h-3.5 w-3.5"}),ce.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mc,{className:"h-3.5 w-3.5"}),ce.commentsCount]})]}),e.jsxs(Z,{size:"sm",className:"w-full gap-2",onClick:oe=>{oe.stopPropagation(),t(`/templates/${ce.id}`)},children:[e.jsx(un,{className:"h-4 w-4"}),"View Template"]})]})]},ce.id))})]})]}),e.jsx(bs,{open:N,onOpenChange:S,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Log Popby for ",w==null?void 0:w.first_name," ",w==null?void 0:w.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Popby Item (optional)"}),e.jsxs(tr,{value:$.popby_item_id,onValueChange:ce=>q(oe=>({...oe,popby_item_id:ce})),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select a popby item..."})}),e.jsx(er,{children:r==null?void 0:r.map(ce=>e.jsx(At,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Notes (optional)"}),e.jsx(Lr,{placeholder:"Any notes about this popby...",value:$.notes,onChange:ce=>q(oe=>({...oe,notes:ce.target.value}))})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(Z,{onClick:Q,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(bs,{open:A,onOpenChange:I,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{className:"font-medium",children:ce.name}),e.jsxs(tr,{value:Y(ce.id),onValueChange:oe=>te(ce.id,oe),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{})}),e.jsx(er,{children:ZOt.map(oe=>e.jsx(At,{value:oe.value,children:oe.label},oe.value))})]})]},ce.id))]}),e.jsx(qn,{children:e.jsx(Z,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(bs,{open:L,onOpenChange:F,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Name *"}),e.jsx(Re,{placeholder:"e.g., Homemade cookies",value:H.name,onChange:ce=>U(oe=>({...oe,name:ce.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{placeholder:"Optional description...",value:H.description,onChange:ce=>U(oe=>({...oe,description:ce.target.value}))})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),e.jsx(Z,{onClick:se,disabled:!H.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}function XOt(){const t=Or(),{isAdmin:s}=Qs(),r=M.useRef(null),n=M.useRef(null),a=M.useRef([]),o=cGe(),{data:l}=oGe(),i=uGe(),[d,u]=M.useState(""),[f,g]=M.useState(""),[v,_]=M.useState(!0),[b,w]=M.useState(null),[j,N]=M.useState(null),[S,A]=M.useState(!1),[I,L]=M.useState({popby_item_id:"",notes:""}),F=o.filter(U=>U.address||U.city&&U.state);M.useEffect(()=>{(async()=>{_(!0);try{const{data:Q}=await K.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();Q!=null&&Q.value&&u(Q.value)}catch(Q){console.error("Error fetching mapbox token:",Q)}_(!1)})()},[]),M.useEffect(()=>{"geolocation"in navigator&&navigator.geolocation.getCurrentPosition(U=>{w([U.coords.longitude,U.coords.latitude])},U=>{console.log("Could not get location:",U)})},[]),M.useEffect(()=>{if(!(!r.current||!d||n.current))return Fc.accessToken=d,n.current=new Fc.Map({container:r.current,style:"mapbox://styles/mapbox/streets-v12",zoom:b?12:4,center:b||[-98.5795,39.8283]}),n.current.addControl(new Fc.NavigationControl,"top-right"),()=>{var U;(U=n.current)==null||U.remove(),n.current=null}},[d,b]),M.useEffect(()=>{!n.current||!d||(a.current.forEach(U=>U.remove()),a.current=[],F.forEach(async U=>{var se;const Q=[U.address,U.city,U.state,U.zip].filter(Boolean).join(", ");if(Q)try{const Y=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(Q)}.json?access_token=${d}`)).json();if(Y.features&&Y.features.length>0){const[ce,oe]=Y.features[0].center,le=document.createElement("div");le.className="cursor-pointer",le.innerHTML=`
${U.first_name[0]}${((se=U.last_name)==null?void 0:se[0])||""}
${U.isDue?'
':""}
`;const de=new Fc.Marker(le).setLngLat([ce,oe]).addTo(n.current);le.addEventListener("click",()=>{N(U)}),a.current.push(de)}}catch(te){console.error("Geocoding error for",U.first_name,te)}}))},[F,d]);const $=()=>{b&&n.current?n.current.flyTo({center:b,zoom:13}):dn({title:"Location not available",description:"Please enable location services",variant:"destructive"})},q=async()=>{j&&(await i.mutateAsync({contact_id:j.id,popby_item_id:I.popby_item_id||void 0,notes:I.notes||void 0,latitude:b==null?void 0:b[1],longitude:b==null?void 0:b[0]}),A(!1),N(null),L({popby_item_id:"",notes:""}))},H=async()=>{if(f.trim())try{await K.from("settings").upsert({key:"mapbox_public_token",value:f.trim()}),u(f.trim()),dn({title:"Mapbox token saved!"})}catch{dn({title:"Error saving token",variant:"destructive"})}};return v?e.jsx(Ms,{title:"Popby Map",children:e.jsx("div",{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"})})}):d?e.jsx(Ms,{title:"Popby Map",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Z,{variant:"ghost",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]}),e.jsxs(Z,{onClick:$,children:[e.jsx(YE,{className:"h-4 w-4 mr-2"}),"My Location"]})]}),e.jsxs("div",{className:"flex 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 bg-primary"}),e.jsx("span",{children:"Up to date"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full bg-amber-500"}),e.jsx("span",{children:"Due for popby"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:r,className:"w-full h-[60vh] rounded-lg shadow-lg"}),F.length===0&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 rounded-lg",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(Yo,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"font-medium",children:"No contacts with addresses"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Add addresses to your contacts to see them on the map."})]})})]}),j&&e.jsx(De,{className:"fixed bottom-4 left-4 right-4 md:left-auto md:right-4 md:w-96 z-50 shadow-xl",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold",children:[j.first_name," ",j.last_name]}),j.address&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[j.city,", ",j.state]})]}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>N(null),children:"×"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[j.isDue?e.jsxs(nt,{variant:"destructive",children:[j.daysOverdue,"+ days overdue"]}):e.jsx(nt,{variant:"secondary",children:"Up to date"}),j.lastPopby&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last: ",js(new Date(j.lastPopby),"MMM d")]})]}),e.jsxs("div",{className:"flex gap-2",children:[j.phone&&e.jsx(Z,{size:"sm",variant:"outline",asChild:!0,className:"flex-1",children:e.jsxs("a",{href:`tel:${j.phone}`,children:[e.jsx(ga,{className:"h-4 w-4 mr-1"}),"Call"]})}),j.address&&e.jsxs(Z,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const U=[j.address,j.city,j.state,j.zip].filter(Boolean).join(", ");window.open(`https://maps.google.com/maps?daddr=${encodeURIComponent(U)}`,"_blank")},children:[e.jsx(nP,{className:"h-4 w-4 mr-1"}),"Navigate"]}),e.jsxs(Z,{size:"sm",className:"flex-1",onClick:()=>A(!0),children:[e.jsx(uo,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})}),e.jsx(bs,{open:S,onOpenChange:A,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{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(_e,{children:"Popby Item (optional)"}),e.jsxs(tr,{value:I.popby_item_id,onValueChange:U=>L(Q=>({...Q,popby_item_id:U})),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select a popby item..."})}),e.jsx(er,{children:l==null?void 0:l.map(U=>e.jsx(At,{value:U.id,children:U.name},U.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Notes (optional)"}),e.jsx(Lr,{placeholder:"Any notes about this popby...",value:I.notes,onChange:U=>L(Q=>({...Q,notes:U.target.value}))})]}),b&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Pi,{className:"h-3 w-3"}),"Your current location will be recorded"]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),e.jsxs(Z,{onClick:q,disabled:i.isPending,children:[e.jsx(hi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})]})}):s?e.jsx(Ms,{title:"Popby Map",children:e.jsx("div",{className:"max-w-md mx-auto mt-8",children:e.jsx(De,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx(Pi,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Setup Map"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your Mapbox public token to enable the map feature."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Mapbox Public Token"}),e.jsx(Re,{placeholder:"pk.eyJ1I...",value:f,onChange:U=>g(U.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"})]})]}),e.jsx(Z,{onClick:H,className:"w-full",children:"Save Token"}),e.jsxs(Z,{variant:"outline",className:"w-full",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})}):e.jsx(Ms,{title:"Popby Map",children:e.jsx("div",{className:"max-w-md mx-auto mt-8",children:e.jsx(De,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(Yo,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Map Not Available"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The map feature has not been configured yet. Please contact your administrator."})]}),e.jsxs(Z,{variant:"outline",className:"w-full",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})})}const QOt=O_({property_address:Ko().min(1,"Property address is required"),city:Ko().optional(),state:Ko().optional(),zip:Ko().optional(),transaction_type:j9e(["buyer","seller"]),close_date:Ko().min(1,"Close date is required"),sale_price:AP().min(0,"Sale price must be positive"),commission_amount:AP().optional(),lead_source_id:Ko().optional(),client_type_id:Ko().optional(),contact_id:Ko().optional(),notes:Ko().optional(),is_win:__t()});function xGe({open:t,onOpenChange:s,transaction:r}){const[n,a]=M.useState(!1),[o,l]=M.useState(""),[i,d]=M.useState(!1),[u,f]=M.useState(""),g=Roe(),v=ukt(),{data:_}=gL(),{data:b}=Vg(),{data:w}=Im(),j=Loe(),N=hqe(),{data:S}=Foe(),A=(S==null?void 0:S.show_commission)??!0,I=Soe({resolver:Coe(QOt),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}});M.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 H=>{const U={property_address:H.property_address,transaction_type:H.transaction_type,close_date:H.close_date,sale_price:H.sale_price,is_win:H.is_win,commission_amount:H.commission_amount||null,lead_source_id:H.lead_source_id||null,client_type_id:H.client_type_id||null,contact_id:H.contact_id||null,city:H.city||null,state:H.state||null,zip:H.zip||null,notes:H.notes||null};r?await v.mutateAsync({id:r.id,...U}):await g.mutateAsync(U),s(!1)},F=async()=>{if(!o.trim())return;const[H,...U]=o.trim().split(" "),Q=U.join(" ")||null,se=await j.mutateAsync({first_name:H,last_name:Q,tagIds:[]});se&&(I.setValue("contact_id",se.id),l(""),d(!1),a(!1))},$=async()=>{if(!u.trim())return;const H=await N.mutateAsync(u.trim());H&&(I.setValue("lead_source_id",H.id),f(""))},q=w==null?void 0:w.find(H=>H.id===I.watch("contact_id"));return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Fi,{className:"max-h-[70vh] pr-4",children:e.jsx(Moe,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(L),className:"space-y-4",children:[e.jsx(yc,{control:I.control,name:"property_address",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Property Address *"}),e.jsx(lc,{children:e.jsx(Re,{placeholder:"123 Main St",...H})}),e.jsx(Nh,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(yc,{control:I.control,name:"city",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"City"}),e.jsx(lc,{children:e.jsx(Re,{placeholder:"City",...H})})]})}),e.jsx(yc,{control:I.control,name:"state",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"State"}),e.jsx(lc,{children:e.jsx(Re,{placeholder:"TX",...H})})]})}),e.jsx(yc,{control:I.control,name:"zip",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Zip"}),e.jsx(lc,{children:e.jsx(Re,{placeholder:"75001",...H})})]})})]}),e.jsx(yc,{control:I.control,name:"transaction_type",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Transaction Type *"}),e.jsxs(tr,{onValueChange:H.onChange,value:H.value,children:[e.jsx(lc,{children:e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select type"})})}),e.jsxs(er,{children:[e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"})]})]}),e.jsx(Nh,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(yc,{control:I.control,name:"close_date",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Close Date *"}),e.jsx(lc,{children:e.jsx(Re,{type:"date",...H})}),e.jsx(Nh,{})]})}),e.jsx(yc,{control:I.control,name:"sale_price",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Sale Price *"}),e.jsx(lc,{children:e.jsx(Re,{type:"number",placeholder:"0",...H,onChange:U=>H.onChange(Number(U.target.value))})}),e.jsx(Nh,{})]})})]}),A&&e.jsx(yc,{control:I.control,name:"commission_amount",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Commission"}),e.jsx(lc,{children:e.jsx(Re,{type:"number",placeholder:"0",...H,value:H.value??"",onChange:U=>H.onChange(U.target.value?Number(U.target.value):void 0)})})]})}),e.jsx(yc,{control:I.control,name:"lead_source_id",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Lead Source"}),e.jsxs(tr,{onValueChange:H.onChange,value:H.value||"",children:[e.jsx(lc,{children:e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select source"})})}),e.jsx(er,{children:_==null?void 0:_.map(U=>e.jsx(At,{value:U.id,children:U.name},U.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Add custom source...",value:u,onChange:H=>f(H.target.value),className:"flex-1"}),e.jsx(Z,{type:"button",variant:"outline",size:"icon",onClick:$,disabled:!u.trim(),children:e.jsx(Ys,{className:"h-4 w-4"})})]}),e.jsx(yc,{control:I.control,name:"client_type_id",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Client Type"}),e.jsxs(tr,{onValueChange:H.onChange,value:H.value||"",children:[e.jsx(lc,{children:e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select client type"})})}),e.jsx(er,{children:b==null?void 0:b.map(U=>e.jsx(At,{value:U.id,children:U.name},U.id))})]})]})}),e.jsx(yc,{control:I.control,name:"contact_id",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Client Contact"}),e.jsxs(No,{open:n,onOpenChange:a,children:[e.jsx(So,{asChild:!0,children:e.jsx(lc,{children:e.jsxs(Z,{variant:"outline",role:"combobox",className:It("w-full justify-between",!H.value&&"text-muted-foreground"),children:[q?`${q.first_name} ${q.last_name||""}`.trim():"Select contact",e.jsx(of,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(jo,{className:"w-full p-0",align:"start",children:[e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search contacts..."}),e.jsxs(yf,{children:[e.jsx(vf,{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(Z,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(_f,{children:w==null?void 0:w.map(U=>e.jsxs(_m,{value:`${U.first_name} ${U.last_name||""}`,onSelect:()=>{H.onChange(U.id),a(!1)},children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",U.id===H.value?"opacity-100":"opacity-0")}),U.first_name," ",U.last_name||""]},U.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(Re,{placeholder:"Enter contact name...",value:o,onChange:U=>l(U.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{size:"sm",onClick:F,disabled:!o.trim()||j.isPending,children:"Add Contact"}),e.jsx(Z,{size:"sm",variant:"outline",onClick:()=>{d(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(yc,{control:I.control,name:"notes",render:({field:H})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Notes"}),e.jsx(lc,{children:e.jsx(Lr,{placeholder:"Any notes about this transaction...",...H})})]})}),e.jsx(yc,{control:I.control,name:"is_win",render:({field:H})=>e.jsxs(ic,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(oc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(lc,{children:e.jsx(qr,{checked:H.value,onCheckedChange:H.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:g.isPending||v.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function Dbe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=M.useState(null),[i,d]=M.useState(null),[u,f]=M.useState(""),[g,v]=M.useState("all"),[_,b]=M.useState("all"),[w,j]=M.useState("all"),[N,S]=M.useState(!1),A=hkt(),I=Roe(),{data:L}=gL(),{data:F}=Vg(),$=xM(),q=Q=>{const{id:se,created_at:te,updated_at:Y,lead_source:ce,client_type:oe,contact:le,...de}=Q;I.mutate(de)},H=()=>{i&&(A.mutate(i),d(null))},U=t.filter(Q=>{var le,de,xe,be;const se=u===""||Q.property_address.toLowerCase().includes(u.toLowerCase())||((de=(le=Q.contact)==null?void 0:le.first_name)==null?void 0:de.toLowerCase().includes(u.toLowerCase()))||((be=(xe=Q.contact)==null?void 0:xe.last_name)==null?void 0:be.toLowerCase().includes(u.toLowerCase())),te=g==="all"||Q.transaction_type===g,Y=_==="all"||Q.lead_source_id===_,ce=w==="all"||Q.client_type_id===w,oe=!N||Q.is_win;return se&&te&&Y&&ce&&oe});return r?e.jsx(De,{children:e.jsx(Oe,{className:"p-6 space-y-4",children:[1,2,3].map(Q=>e.jsx(gs,{className:"h-16 w-full"},Q))})}):e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx($t,{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(Vt,{children:["Transactions (",U.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search...",value:u,onChange:Q=>f(Q.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{className:"w-[100px]",children:e.jsx(rr,{placeholder:"Type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"})]})]}),e.jsxs(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[130px]",children:e.jsx(rr,{placeholder:"Lead Source"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Sources"}),L==null?void 0:L.map(Q=>e.jsx(At,{value:Q.id,children:Q.name},Q.id))]})]}),e.jsxs(Z,{variant:N?"default":"outline",size:"sm",onClick:()=>S(!N),children:[e.jsx(dc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Oe,{children:U.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):$?e.jsx("div",{className:"space-y-3",children:U.map(Q=>e.jsxs(De,{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:Q.property_address}),Q.is_win&&e.jsx(dc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Q.city,Q.state?`, ${Q.state}`:""]})]}),e.jsx(nt,{variant:Q.transaction_type==="buyer"?"default":"secondary",children:Q.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: "}),UCe(Q.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Sl(Q.sale_price)]}),s&&Q.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Sl(Q.commission_amount)]}),Q.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),Q.lead_source.name]}),Q.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),Q.contact.first_name," ",Q.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[Q.owner_user_id]||"Unknown"]})]}),!a&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>l(Q),children:e.jsx(Pc,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>q(Q),children:e.jsx(Ni,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>d(Q.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})]},Q.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:U.map(Q=>{var se;return e.jsxs(ks,{children:[n&&e.jsx(lt,{className:"font-medium text-sm",children:n[Q.owner_user_id]||"Unknown"}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[Q.is_win&&e.jsx(dc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Q.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Q.city,Q.state?`, ${Q.state}`:""]})]})]})}),e.jsx(lt,{children:e.jsx(nt,{variant:Q.transaction_type==="buyer"?"default":"secondary",children:Q.transaction_type})}),e.jsx(lt,{children:UCe(Q.close_date)}),e.jsx(lt,{children:Sl(Q.sale_price)}),s&&e.jsx(lt,{children:Q.commission_amount?Sl(Q.commission_amount):"-"}),e.jsx(lt,{children:((se=Q.lead_source)==null?void 0:se.name)||"-"}),e.jsx(lt,{children:Q.contact?`${Q.contact.first_name} ${Q.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(lt,{children:e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",children:e.jsx(xg,{className:"h-4 w-4"})})}),e.jsxs(mu,{align:"end",children:[e.jsxs(Wa,{onClick:()=>l(Q),children:[e.jsx(Pc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Wa,{onClick:()=>q(Q),children:[e.jsx(Ni,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Wa,{onClick:()=>d(Q.id),className:"text-destructive",children:[e.jsx(Cr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},Q.id)})})]})})})]}),e.jsx(xGe,{open:!!o,onOpenChange:Q=>!Q&&l(null),transaction:o||void 0}),e.jsx(uc,{open:!!i,onOpenChange:Q=>!Q&&d(null),children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete Transaction?"}),e.jsx(Xl,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:H,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function yGe({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=(v,_)=>{if(!_||_===0)return null;const b=Math.min(v/_*100,100),w=Math.max(_-v,0),j=l>0?w/l:0,N=o/12*100,S=b>=N?"ahead":b>=N*.8?"on-track":"behind";return{percent:b,remaining:w,pace:j,status:S}},d=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),f=n?i(s.totalCommission,t.gci_goal):null,g=v=>{switch(v){case"ahead":return e.jsxs(nt,{className:"bg-green-500 text-white",children:[e.jsx(Vc,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(nt,{variant:"secondary",children:[e.jsx(K1,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(nt,{variant:"destructive",children:[e.jsx(rN,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mm,{className:"h-5 w-5 text-primary"}),e.jsxs(Vt,{children:[r," Goals Progress"]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[t.transactions_goal&&d&&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"}),g(d.status)]}),e.jsx(wo,{value:d.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(d.percent),"%"]})]}),d.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.ceil(d.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"}),g(u.status)]}),e.jsx(wo,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Sl(s.totalVolume,!0)," of ",Sl(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 ",Sl(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&f&&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"}),g(f.status)]}),e.jsx(wo,{value:f.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Sl(s.totalCommission,!0)," of ",Sl(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(f.percent),"%"]})]}),f.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Sl(f.pace,!0),"/month"]})]})]})})]})}var JOt=Array.isArray,Dm=JOt,e8t=typeof a0=="object"&&a0&&a0.Object===Object&&a0,vGe=e8t,t8t=vGe,s8t=typeof self=="object"&&self&&self.Object===Object&&self,r8t=t8t||s8t||Function("return this")(),dy=r8t,n8t=dy,a8t=n8t.Symbol,LL=a8t,WTe=LL,_Ge=Object.prototype,i8t=_Ge.hasOwnProperty,o8t=_Ge.toString,ZA=WTe?WTe.toStringTag:void 0;function l8t(t){var s=i8t.call(t,ZA),r=t[ZA];try{t[ZA]=void 0;var n=!0}catch{}var a=o8t.call(t);return n&&(s?t[ZA]=r:delete t[ZA]),a}var c8t=l8t,d8t=Object.prototype,u8t=d8t.toString;function h8t(t){return u8t.call(t)}var m8t=h8t,GTe=LL,p8t=c8t,f8t=m8t,g8t="[object Null]",x8t="[object Undefined]",KTe=GTe?GTe.toStringTag:void 0;function y8t(t){return t==null?t===void 0?x8t:g8t:KTe&&KTe in Object(t)?p8t(t):f8t(t)}var K0=y8t;function v8t(t){return t!=null&&typeof t=="object"}var Z0=v8t,_8t=K0,b8t=Z0,w8t="[object Symbol]";function j8t(t){return typeof t=="symbol"||b8t(t)&&_8t(t)==w8t}var yM=j8t,k8t=Dm,N8t=yM,S8t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,C8t=/^\w*$/;function M8t(t,s){if(k8t(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||N8t(t)?!0:C8t.test(t)||!S8t.test(t)||s!=null&&t in Object(s)}var Obe=M8t;function T8t(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var q_=T8t;const vM=vo(q_);var A8t=K0,E8t=q_,P8t="[object AsyncFunction]",I8t="[object Function]",L8t="[object GeneratorFunction]",D8t="[object Proxy]";function O8t(t){if(!E8t(t))return!1;var s=A8t(t);return s==I8t||s==L8t||s==P8t||s==D8t}var Rbe=O8t;const gi=vo(Rbe);var R8t=dy,F8t=R8t["__core-js_shared__"],z8t=F8t,Sme=z8t,ZTe=function(){var t=/[^.]+$/.exec(Sme&&Sme.keys&&Sme.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function B8t(t){return!!ZTe&&ZTe in t}var $8t=B8t,q8t=Function.prototype,U8t=q8t.toString;function V8t(t){if(t!=null){try{return U8t.call(t)}catch{}try{return t+""}catch{}}return""}var bGe=V8t,H8t=Rbe,W8t=$8t,G8t=q_,K8t=bGe,Z8t=/[\\^$.*+?()[\]{}|]/g,Y8t=/^\[object .+?Constructor\]$/,X8t=Function.prototype,Q8t=Object.prototype,J8t=X8t.toString,eRt=Q8t.hasOwnProperty,tRt=RegExp("^"+J8t.call(eRt).replace(Z8t,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function sRt(t){if(!G8t(t)||W8t(t))return!1;var s=H8t(t)?tRt:Y8t;return s.test(K8t(t))}var rRt=sRt;function nRt(t,s){return t==null?void 0:t[s]}var aRt=nRt,iRt=rRt,oRt=aRt;function lRt(t,s){var r=oRt(t,s);return iRt(r)?r:void 0}var QN=lRt,cRt=QN,dRt=cRt(Object,"create"),gle=dRt,YTe=gle;function uRt(){this.__data__=YTe?YTe(null):{},this.size=0}var hRt=uRt;function mRt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var pRt=mRt,fRt=gle,gRt="__lodash_hash_undefined__",xRt=Object.prototype,yRt=xRt.hasOwnProperty;function vRt(t){var s=this.__data__;if(fRt){var r=s[t];return r===gRt?void 0:r}return yRt.call(s,t)?s[t]:void 0}var _Rt=vRt,bRt=gle,wRt=Object.prototype,jRt=wRt.hasOwnProperty;function kRt(t){var s=this.__data__;return bRt?s[t]!==void 0:jRt.call(s,t)}var NRt=kRt,SRt=gle,CRt="__lodash_hash_undefined__";function MRt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=SRt&&s===void 0?CRt:s,this}var TRt=MRt,ARt=hRt,ERt=pRt,PRt=_Rt,IRt=NRt,LRt=TRt;function _M(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var XRt=YRt,QRt=xle;function JRt(t,s){var r=this.__data__,n=QRt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var eFt=JRt,tFt=RRt,sFt=HRt,rFt=KRt,nFt=XRt,aFt=eFt;function bM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},Nk=function(s){return DN(s)&&s.indexOf("%")===s.length-1},sn=function(s){return Nzt(s)&&!DL(s)},Tzt=function(s){return Gi(s)},Od=function(s){return sn(s)||DN(s)},Azt=0,OL=function(s){var r=++Azt;return"".concat(s||"").concat(r)},Th=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(!sn(s)&&!DN(s))return n;var o;if(Nk(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return DL(o)&&(o=n),a&&o>r&&(o=r),o},m1=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},Ezt=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 Fzt(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 rAe={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"},T0=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},nAe=null,Mme=null,Gbe=function t(s){if(s===nAe&&Array.isArray(Mme))return Mme;var r=[];return M.Children.forEach(s,function(n){Gi(n)||(_zt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Mme=r,nAe=s,r};function hf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return T0(a)}):n=[T0(s)],Gbe(t).forEach(function(a){var o=yp(a,"type.displayName")||yp(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function Qm(t,s){var r=hf(t,s);return r&&r[0]}var aAe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!sn(n)||n<=0||!sn(a)||a<=0)},zzt=["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"],Bzt=function(s){return s&&s.type&&DN(s.type)&&zzt.indexOf(s.type)>=0},$zt=function(s,r,n,a){var o,l=(o=Cme==null?void 0:Cme[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!gi(s)&&(a&&l.includes(r)||Lzt.includes(r))||n&&Wbe.includes(r)},ci=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(M.isValidElement(s)&&(a=s.props),!vM(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;$zt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},Lxe=function t(s,r){if(s===r)return!0;var n=M.Children.count(s);if(n!==M.Children.count(r))return!1;if(n===0)return!0;if(n===1)return iAe(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 Wzt(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 Oxe(t){var s=t.children,r=t.width,n=t.height,a=t.viewBox,o=t.className,l=t.style,i=t.title,d=t.desc,u=Hzt(t,Vzt),f=a||{width:r,height:n,x:0,y:0},g=Ri("recharts-surface",o);return ut.createElement("svg",Dxe({},ci(u,!0,"svg"),{className:g,width:r,height:n,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height)}),ut.createElement("title",null,i),ut.createElement("desc",null,d),s)}var Gzt=["children","className"];function Rxe(){return Rxe=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 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}var Jo=ut.forwardRef(function(t,s){var r=t.children,n=t.className,a=Kzt(t,Gzt),o=Ri("recharts-layer",n);return ut.createElement("g",Rxe({className:o},ci(a,!0),{ref:s}),r)}),Lg=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:Qzt(t,s,r)}var e7t=Jzt,t7t="\\ud800-\\udfff",s7t="\\u0300-\\u036f",r7t="\\ufe20-\\ufe2f",n7t="\\u20d0-\\u20ff",a7t=s7t+r7t+n7t,i7t="\\ufe0e\\ufe0f",o7t="\\u200d",l7t=RegExp("["+o7t+t7t+a7t+i7t+"]");function c7t(t){return l7t.test(t)}var EGe=c7t;function d7t(t){return t.split("")}var u7t=d7t,PGe="\\ud800-\\udfff",h7t="\\u0300-\\u036f",m7t="\\ufe20-\\ufe2f",p7t="\\u20d0-\\u20ff",f7t=h7t+m7t+p7t,g7t="\\ufe0e\\ufe0f",x7t="["+PGe+"]",Fxe="["+f7t+"]",zxe="\\ud83c[\\udffb-\\udfff]",y7t="(?:"+Fxe+"|"+zxe+")",IGe="[^"+PGe+"]",LGe="(?:\\ud83c[\\udde6-\\uddff]){2}",DGe="[\\ud800-\\udbff][\\udc00-\\udfff]",v7t="\\u200d",OGe=y7t+"?",RGe="["+g7t+"]?",_7t="(?:"+v7t+"(?:"+[IGe,LGe,DGe].join("|")+")"+RGe+OGe+")*",b7t=RGe+OGe+_7t,w7t="(?:"+[IGe+Fxe+"?",Fxe,LGe,DGe,x7t].join("|")+")",j7t=RegExp(zxe+"(?="+zxe+")|"+w7t+b7t,"g");function k7t(t){return t.match(j7t)||[]}var N7t=k7t,S7t=u7t,C7t=EGe,M7t=N7t;function T7t(t){return C7t(t)?M7t(t):S7t(t)}var A7t=T7t,E7t=e7t,P7t=EGe,I7t=A7t,L7t=NGe;function D7t(t){return function(s){s=L7t(s);var r=P7t(s)?I7t(s):void 0,n=r?r[0]:s.charAt(0),a=r?E7t(r,1).join(""):s.slice(1);return n[t]()+a}}var O7t=D7t,R7t=O7t,F7t=R7t("toUpperCase"),z7t=F7t;const Ele=vo(z7t);function Nl(t){return function(){return t}}const FGe=Math.cos,pae=Math.sin,Gg=Math.sqrt,fae=Math.PI,Ple=2*fae,Bxe=Math.PI,$xe=2*Bxe,ik=1e-6,B7t=$xe-ik;function zGe(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return zGe;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;aik)if(!(Math.abs(g*d-u*f)>ik)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let _=n-l,b=a-i,w=d*d+u*u,j=_*_+b*b,N=Math.sqrt(w),S=Math.sqrt(v),A=o*Math.tan((Bxe-Math.acos((w+v-j)/(2*N*S)))/2),I=A/S,L=A/N;Math.abs(I-1)>ik&&this._append`L${s+I*f},${r+I*g}`,this._append`A${o},${o},0,0,${+(g*_>f*b)},${this._x1=s+L*d},${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),d=n*Math.sin(a),u=s+i,f=r+d,g=1^l,v=l?a-o:o-a;this._x1===null?this._append`M${u},${f}`:(Math.abs(this._x1-u)>ik||Math.abs(this._y1-f)>ik)&&this._append`L${u},${f}`,n&&(v<0&&(v=v%$xe+$xe),v>B7t?this._append`A${n},${n},0,1,${g},${s-i},${r-d}A${n},${n},0,1,${g},${this._x1=u},${this._y1=f}`:v>ik&&this._append`A${n},${n},0,${+(v>=Bxe)},${g},${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 Kbe(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 q7t(s)}function Zbe(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function BGe(t){this._context=t}BGe.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 Ile(t){return new BGe(t)}function $Ge(t){return t[0]}function qGe(t){return t[1]}function UGe(t,s){var r=Nl(!0),n=null,a=Ile,o=null,l=Kbe(i);t=typeof t=="function"?t:t===void 0?$Ge:Nl(t),s=typeof s=="function"?s:s===void 0?qGe:Nl(s);function i(d){var u,f=(d=Zbe(d)).length,g,v=!1,_;for(n==null&&(o=a(_=l())),u=0;u<=f;++u)!(u=_;--b)i.point(A[b],I[b]);i.lineEnd(),i.areaEnd()}N&&(A[v]=+t(j,v,g),I[v]=+s(j,v,g),i.point(n?+n(j,v,g):A[v],r?+r(j,v,g):I[v]))}if(S)return i=null,S+""||null}function f(){return UGe().defined(a).curve(l).context(o)}return u.x=function(g){return arguments.length?(t=typeof g=="function"?g:Nl(+g),n=null,u):t},u.x0=function(g){return arguments.length?(t=typeof g=="function"?g:Nl(+g),u):t},u.x1=function(g){return arguments.length?(n=g==null?null:typeof g=="function"?g:Nl(+g),u):n},u.y=function(g){return arguments.length?(s=typeof g=="function"?g:Nl(+g),r=null,u):s},u.y0=function(g){return arguments.length?(s=typeof g=="function"?g:Nl(+g),u):s},u.y1=function(g){return arguments.length?(r=g==null?null:typeof g=="function"?g:Nl(+g),u):r},u.lineX0=u.lineY0=function(){return f().x(t).y(s)},u.lineY1=function(){return f().x(t).y(r)},u.lineX1=function(){return f().x(n).y(s)},u.defined=function(g){return arguments.length?(a=typeof g=="function"?g:Nl(!!g),u):a},u.curve=function(g){return arguments.length?(l=g,o!=null&&(i=l(o)),u):l},u.context=function(g){return arguments.length?(g==null?o=i=null:i=l(o=g),u):o},u}class VGe{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 U7t(t){return new VGe(t,!0)}function V7t(t){return new VGe(t,!1)}const Ybe={draw(t,s){const r=Gg(s/fae);t.moveTo(r,0),t.arc(0,0,r,0,Ple)}},H7t={draw(t,s){const r=Gg(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()}},HGe=Gg(1/3),W7t=HGe*2,G7t={draw(t,s){const r=Gg(s/W7t),n=r*HGe;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},K7t={draw(t,s){const r=Gg(s),n=-r/2;t.rect(n,n,r,r)}},Z7t=.8908130915292852,WGe=pae(fae/10)/pae(7*fae/10),Y7t=pae(Ple/10)*WGe,X7t=-FGe(Ple/10)*WGe,Q7t={draw(t,s){const r=Gg(s*Z7t),n=Y7t*r,a=X7t*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=Ple*o/5,i=FGe(l),d=pae(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},Tme=Gg(3),J7t={draw(t,s){const r=-Gg(s/(Tme*3));t.moveTo(0,r*2),t.lineTo(-Tme*r,-r),t.lineTo(Tme*r,-r),t.closePath()}},Bp=-.5,$p=Gg(3)/2,qxe=1/Gg(12),eBt=(qxe/2+1)*3,tBt={draw(t,s){const r=Gg(s/eBt),n=r/2,a=r*qxe,o=n,l=r*qxe+r,i=-o,d=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,d),t.lineTo(Bp*n-$p*a,$p*n+Bp*a),t.lineTo(Bp*o-$p*l,$p*o+Bp*l),t.lineTo(Bp*i-$p*d,$p*i+Bp*d),t.lineTo(Bp*n+$p*a,Bp*a-$p*n),t.lineTo(Bp*o+$p*l,Bp*l-$p*o),t.lineTo(Bp*i+$p*d,Bp*d-$p*i),t.closePath()}};function sBt(t,s){let r=null,n=Kbe(a);t=typeof t=="function"?t:Nl(t||Ybe),s=typeof s=="function"?s:Nl(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:Nl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Nl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function gae(){}function xae(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 GGe(t){this._context=t}GGe.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:xae(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:xae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function rBt(t){return new GGe(t)}function KGe(t){this._context=t}KGe.prototype={areaStart:gae,areaEnd:gae,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:xae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function nBt(t){return new KGe(t)}function ZGe(t){this._context=t}ZGe.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:xae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function aBt(t){return new ZGe(t)}function YGe(t){this._context=t}YGe.prototype={areaStart:gae,areaEnd:gae,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 iBt(t){return new YGe(t)}function lAe(t){return t<0?-1:1}function cAe(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(lAe(o)+lAe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function dAe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Ame(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 yae(t){this._context=t}yae.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:Ame(this,this._t0,dAe(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,Ame(this,dAe(this,r=cAe(this,t,s)),r);break;default:Ame(this,this._t0,r=cAe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function XGe(t){this._context=new QGe(t)}(XGe.prototype=Object.create(yae.prototype)).point=function(t,s){yae.prototype.point.call(this,s,t)};function QGe(t){this._context=t}QGe.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 oBt(t){return new yae(t)}function lBt(t){return new XGe(t)}function JGe(t){this._context=t}JGe.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=uAe(t),a=uAe(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 dBt(t){return new Lle(t,.5)}function uBt(t){return new Lle(t,0)}function hBt(t){return new Lle(t,1)}function v3(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 mBt(t,s){return t[s]}function pBt(t){const s=[];return s.key=t,s}function fBt(){var t=Nl([]),s=Uxe,r=v3,n=mBt;function a(o){var l=Array.from(t.apply(this,arguments),pBt),i,d=l.length,u=-1,f;for(const g 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 kBt(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 eKe={symbolCircle:Ybe,symbolCross:H7t,symbolDiamond:G7t,symbolSquare:K7t,symbolStar:Q7t,symbolTriangle:J7t,symbolWye:tBt},NBt=Math.PI/180,SBt=function(s){var r="symbol".concat(Ele(s));return eKe[r]||Ybe},CBt=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*NBt;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}},MBt=function(s,r){eKe["symbol".concat(Ele(s))]=r},Xbe=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,d=jBt(s,vBt),u=mAe(mAe({},d),{},{type:n,size:o,sizeType:i}),f=function(){var j=SBt(n),N=sBt().type(j).size(CBt(o,i,n));return N()},g=u.className,v=u.cx,_=u.cy,b=ci(u,!0);return v===+v&&_===+_&&o===+o?ut.createElement("path",Vxe({},b,{className:Ri("recharts-symbols",g),transform:"translate(".concat(v,", ").concat(_,")"),d:f()})):null};Xbe.registerSymbol=MBt;function _3(t){"@babel/helpers - typeof";return _3=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},_3(t)}function Hxe(){return Hxe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var S=_.inactive?u:_.color;return ut.createElement("li",Hxe({className:j,style:g,key:"legend-item-".concat(b)},ON(n.props,_,b)),ut.createElement(Oxe,{width:l,height:l,viewBox:f,style:v},n.renderIcon(_)),ut.createElement("span",{className:"recharts-legend-item-text",style:{color:S}},w?w(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 ut.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(M.PureComponent);JI(Qbe,"displayName","Legend");JI(Qbe,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var FBt=yle;function zBt(){this.__data__=new FBt,this.size=0}var BBt=zBt;function $Bt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var qBt=$Bt;function UBt(t){return this.__data__.get(t)}var VBt=UBt;function HBt(t){return this.__data__.has(t)}var WBt=HBt,GBt=yle,KBt=zbe,ZBt=Bbe,YBt=200;function XBt(t,s){var r=this.__data__;if(r instanceof GBt){var n=r.__data__;if(!KBt||n.lengthi))return!1;var u=o.get(t),f=o.get(s);if(u&&f)return u==s&&f==t;var g=-1,v=!0,_=r&v9t?new f9t:void 0;for(o.set(t,s),o.set(s,t);++g-1&&t%1==0&&t-1&&t%1==0&&t<=j$t}var swe=k$t,N$t=K0,S$t=swe,C$t=Z0,M$t="[object Arguments]",T$t="[object Array]",A$t="[object Boolean]",E$t="[object Date]",P$t="[object Error]",I$t="[object Function]",L$t="[object Map]",D$t="[object Number]",O$t="[object Object]",R$t="[object RegExp]",F$t="[object Set]",z$t="[object String]",B$t="[object WeakMap]",$$t="[object ArrayBuffer]",q$t="[object DataView]",U$t="[object Float32Array]",V$t="[object Float64Array]",H$t="[object Int8Array]",W$t="[object Int16Array]",G$t="[object Int32Array]",K$t="[object Uint8Array]",Z$t="[object Uint8ClampedArray]",Y$t="[object Uint16Array]",X$t="[object Uint32Array]",ql={};ql[U$t]=ql[V$t]=ql[H$t]=ql[W$t]=ql[G$t]=ql[K$t]=ql[Z$t]=ql[Y$t]=ql[X$t]=!0;ql[M$t]=ql[T$t]=ql[$$t]=ql[A$t]=ql[q$t]=ql[E$t]=ql[P$t]=ql[I$t]=ql[L$t]=ql[D$t]=ql[O$t]=ql[R$t]=ql[F$t]=ql[z$t]=ql[B$t]=!1;function Q$t(t){return C$t(t)&&S$t(t.length)&&!!ql[N$t(t)]}var J$t=Q$t;function eqt(t){return function(s){return t(s)}}var uKe=eqt,wae={exports:{}};wae.exports;(function(t,s){var r=vGe,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 d=a&&a.require&&a.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}}();t.exports=i})(wae,wae.exports);var tqt=wae.exports,sqt=J$t,rqt=uKe,_Ae=tqt,bAe=_Ae&&_Ae.isTypedArray,nqt=bAe?rqt(bAe):sqt,hKe=nqt,aqt=l$t,iqt=ewe,oqt=Dm,lqt=dKe,cqt=twe,dqt=hKe,uqt=Object.prototype,hqt=uqt.hasOwnProperty;function mqt(t,s){var r=oqt(t),n=!r&&iqt(t),a=!r&&!n&&lqt(t),o=!r&&!n&&!a&&dqt(t),l=r||n||a||o,i=l?aqt(t.length,String):[],d=i.length;for(var u in t)(s||hqt.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||cqt(u,d)))&&i.push(u);return i}var pqt=mqt,fqt=Object.prototype;function gqt(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||fqt;return t===r}var xqt=gqt;function yqt(t,s){return function(r){return t(s(r))}}var mKe=yqt,vqt=mKe,_qt=vqt(Object.keys,Object),bqt=_qt,wqt=xqt,jqt=bqt,kqt=Object.prototype,Nqt=kqt.hasOwnProperty;function Sqt(t){if(!wqt(t))return jqt(t);var s=[];for(var r in Object(t))Nqt.call(t,r)&&r!="constructor"&&s.push(r);return s}var Cqt=Sqt,Mqt=Rbe,Tqt=swe;function Aqt(t){return t!=null&&Tqt(t.length)&&!Mqt(t)}var RL=Aqt,Eqt=pqt,Pqt=Cqt,Iqt=RL;function Lqt(t){return Iqt(t)?Eqt(t):Pqt(t)}var Dle=Lqt,Dqt=Y9t,Oqt=i$t,Rqt=Dle;function Fqt(t){return Dqt(t,Rqt,Oqt)}var zqt=Fqt,wAe=zqt,Bqt=1,$qt=Object.prototype,qqt=$qt.hasOwnProperty;function Uqt(t,s,r,n,a,o){var l=r&Bqt,i=wAe(t),d=i.length,u=wAe(s),f=u.length;if(d!=f&&!l)return!1;for(var g=d;g--;){var v=i[g];if(!(l?v in s:qqt.call(s,v)))return!1}var _=o.get(t),b=o.get(s);if(_&&b)return _==s&&b==t;var w=!0;o.set(t,s),o.set(s,t);for(var j=l;++g-1}var $Vt=BVt;function qVt(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=rHt){var u=s?null:tHt(t);if(u)return sHt(u);l=!1,a=eHt,d=new XVt}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function vHt(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 _Ht(t){return t.value}function bHt(t,s){if(ut.isValidElement(t))return ut.cloneElement(t,s);if(typeof t=="function")return ut.createElement(t,s);s.ref;var r=yHt(s,dHt);return ut.createElement(Qbe,r)}var FAe=1,T5=function(t){function s(){var r;uHt(this,s);for(var n=arguments.length,a=new Array(n),o=0;oFAe||Math.abs(a.height-this.lastBoundingBox.height)>FAe)&&(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?Uy({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,o=a.layout,l=a.align,i=a.verticalAlign,d=a.margin,u=a.chartWidth,f=a.chartHeight,g,v;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var _=this.getBBoxSnapshot();g={left:((u||0)-_.width)/2}}else g=l==="right"?{right:d&&d.right||0}:{left:d&&d.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(i==="middle"){var b=this.getBBoxSnapshot();v={top:((f||0)-b.height)/2}}else v=i==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return Uy(Uy({},g),v)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,d=a.wrapperStyle,u=a.payloadUniqBy,f=a.payload,g=Uy(Uy({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(d)),d);return ut.createElement("div",{className:"recharts-legend-wrapper",style:g,ref:function(_){n.wrapperNode=_}},bHt(o,Uy(Uy({},this.props),{},{payload:_Ke(f,u,_Ht)})))}}],[{key:"getWithHeight",value:function(n,a){var o=Uy(Uy({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&sn(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(M.PureComponent);Ole(T5,"displayName","Legend");Ole(T5,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var zAe=LL,wHt=ewe,jHt=Dm,BAe=zAe?zAe.isConcatSpreadable:void 0;function kHt(t){return jHt(t)||wHt(t)||!!(BAe&&t&&t[BAe])}var NHt=kHt,SHt=lKe,CHt=NHt;function jKe(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=CHt),a||(a=[]);++o0&&r(i)?s>1?jKe(i,s-1,r,n,a):SHt(a,i):n||(a[a.length]=i)}return a}var kKe=jKe;function MHt(t){return function(s,r,n){for(var a=-1,o=Object(s),l=n(s),i=l.length;i--;){var d=l[t?i:++a];if(r(o[d],d,o)===!1)break}return s}}var THt=MHt,AHt=THt,EHt=AHt(),PHt=EHt,IHt=PHt,LHt=Dle;function DHt(t,s){return t&&IHt(t,s,LHt)}var NKe=DHt,OHt=RL;function RHt(t,s){return function(r,n){if(r==null)return r;if(!OHt(r))return t(r,n);for(var a=r.length,o=s?a:-1,l=Object(r);(s?o--:++os||o&&l&&d&&!i&&!u||n&&l&&d||!r&&d||!a)return 1;if(!n&&!o&&!u&&t=i)return d;var u=r[n];return d*(u=="desc"?-1:1)}}return t.index-s.index}var XHt=YHt,Lme=qbe,QHt=Ube,JHt=uy,eWt=SKe,tWt=WHt,sWt=uKe,rWt=XHt,nWt=NM,aWt=Dm;function iWt(t,s,r){s.length?s=Lme(s,function(o){return aWt(o)?function(l){return QHt(l,o.length===1?o[0]:o)}:o}):s=[nWt];var n=-1;s=Lme(s,sWt(JHt));var a=eWt(t,function(o,l,i){var d=Lme(s,function(u){return u(o)});return{criteria:d,index:++n,value:o}});return tWt(a,function(o,l){return rWt(o,l,r)})}var oWt=iWt;function lWt(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 cWt=lWt,dWt=cWt,qAe=Math.max;function uWt(t,s,r){return s=qAe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=qAe(n.length-s,0),l=Array(o);++a0){if(++s>=bWt)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var NWt=kWt,SWt=_Wt,CWt=NWt,MWt=CWt(SWt),TWt=MWt,AWt=NM,EWt=hWt,PWt=TWt;function IWt(t,s){return PWt(EWt(t,s,AWt),t+"")}var LWt=IWt,DWt=Fbe,OWt=RL,RWt=twe,FWt=q_;function zWt(t,s,r){if(!FWt(r))return!1;var n=typeof s;return(n=="number"?OWt(r)&&RWt(s,r.length):n=="string"&&s in r)?DWt(r[s],t):!1}var Rle=zWt,BWt=kKe,$Wt=oWt,qWt=LWt,VAe=Rle,UWt=qWt(function(t,s){if(t==null)return[];var r=s.length;return r>1&&VAe(t,s[0],s[1])?s=[]:r>2&&VAe(s[0],s[1],s[2])&&(s=[s[0]]),$Wt(t,BWt(s,1),[])}),VWt=UWt;const awe=vo(VWt);function e6(t){"@babel/helpers - typeof";return e6=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},e6(t)}function Jxe(){return Jxe=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(YA,"-left"),sn(r)&&s&&sn(s.x)&&r=s.y),"".concat(YA,"-top"),sn(n)&&s&&sn(s.y)&&nw?Math.max(f,d[n]):Math.max(g,d[n])}function aGt(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 iGt(t){var s=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,a=t.position,o=t.reverseDirection,l=t.tooltipBox,i=t.useTranslate3d,d=t.viewBox,u,f,g;return l.height>0&&l.width>0&&r?(f=GAe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),g=GAe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=aGt({translateX:f,translateY:g,useTranslate3d:i})):u=rGt,{cssProperties:u,cssClasses:nGt({translateX:f,translateY:g,coordinate:r})}}function w3(t){"@babel/helpers - typeof";return w3=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},w3(t)}function KAe(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 ZAe(t){for(var s=1;sYAe||Math.abs(n.height-this.state.lastBoundingBox.height)>YAe)&&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,d=a.animationEasing,u=a.children,f=a.coordinate,g=a.hasPayload,v=a.isAnimationActive,_=a.offset,b=a.position,w=a.reverseDirection,j=a.useTranslate3d,N=a.viewBox,S=a.wrapperStyle,A=iGt({allowEscapeViewBox:l,coordinate:f,offsetTopLeft:_,position:b,reverseDirection:w,tooltipBox:this.state.lastBoundingBox,useTranslate3d:j,viewBox:N}),I=A.cssClasses,L=A.cssProperties,F=ZAe(ZAe({transition:v&&o?"transform ".concat(i,"ms ").concat(d):void 0},L),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&g?"visible":"hidden",position:"absolute",top:0,left:0},S);return ut.createElement("div",{tabIndex:-1,className:I,style:F,ref:function(q){n.wrapperNode=q}},u)}}])}(M.PureComponent),gGt=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},SM={isSsr:gGt()};function j3(t){"@babel/helpers - typeof";return j3=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},j3(t)}function XAe(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 QAe(t){for(var s=1;s0;return ut.createElement(fGt,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:v,active:o,coordinate:f,hasPayload:F,offset:_,position:j,reverseDirection:N,useTranslate3d:S,viewBox:A,wrapperStyle:I},SGt(u,QAe(QAe({},this.props),{},{payload:L})))}}])}(M.PureComponent);iwe(pg,"displayName","Tooltip");iwe(pg,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!SM.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 CGt=dy,MGt=function(){return CGt.Date.now()},TGt=MGt,AGt=/\s/;function EGt(t){for(var s=t.length;s--&&AGt.test(t.charAt(s)););return s}var PGt=EGt,IGt=PGt,LGt=/^\s+/;function DGt(t){return t&&t.slice(0,IGt(t)+1).replace(LGt,"")}var OGt=DGt,RGt=OGt,JAe=q_,FGt=yM,eEe=NaN,zGt=/^[-+]0x[0-9a-f]+$/i,BGt=/^0b[01]+$/i,$Gt=/^0o[0-7]+$/i,qGt=parseInt;function UGt(t){if(typeof t=="number")return t;if(FGt(t))return eEe;if(JAe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=JAe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=RGt(t);var r=BGt.test(t);return r||$Gt.test(t)?qGt(t.slice(2),r?2:8):zGt.test(t)?eEe:+t}var PKe=UGt,VGt=q_,Ome=TGt,tEe=PKe,HGt="Expected a function",WGt=Math.max,GGt=Math.min;function KGt(t,s,r){var n,a,o,l,i,d,u=0,f=!1,g=!1,v=!0;if(typeof t!="function")throw new TypeError(HGt);s=tEe(s)||0,VGt(r)&&(f=!!r.leading,g="maxWait"in r,o=g?WGt(tEe(r.maxWait)||0,s):o,v="trailing"in r?!!r.trailing:v);function _(F){var $=n,q=a;return n=a=void 0,u=F,l=t.apply(q,$),l}function b(F){return u=F,i=setTimeout(N,s),f?_(F):l}function w(F){var $=F-d,q=F-u,H=s-$;return g?GGt(H,o-q):H}function j(F){var $=F-d,q=F-u;return d===void 0||$>=s||$<0||g&&q>=o}function N(){var F=Ome();if(j(F))return S(F);i=setTimeout(N,w(F))}function S(F){return i=void 0,v&&n?_(F):(n=a=void 0,l)}function A(){i!==void 0&&clearTimeout(i),u=0,n=d=a=i=void 0}function I(){return i===void 0?l:S(Ome())}function L(){var F=Ome(),$=j(F);if(n=arguments,a=this,d=F,$){if(i===void 0)return b(d);if(g)return clearTimeout(i),i=setTimeout(N,s),_(d)}return i===void 0&&(i=setTimeout(N,s)),l}return L.cancel=A,L.flush=I,L}var ZGt=KGt,YGt=ZGt,XGt=q_,QGt="Expected a function";function JGt(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(QGt);return XGt(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),YGt(t,s,{leading:n,maxWait:s,trailing:a})}var eKt=JGt;const IKe=vo(eKt);function s6(t){"@babel/helpers - typeof";return s6=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},s6(t)}function sEe(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 Y8(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(te=IKe(te,w,{trailing:!0,leading:!1}));var Y=new ResizeObserver(te),ce=L.current.getBoundingClientRect(),oe=ce.width,le=ce.height;return Q(oe,le),Y.observe(L.current),function(){Y.disconnect()}},[Q,w]);var se=M.useMemo(function(){var te=H.containerWidth,Y=H.containerHeight;if(te<0||Y<0)return null;Lg(Nk(l)||Nk(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),Lg(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ce=Nk(l)?te:l,oe=Nk(d)?Y:d;r&&r>0&&(ce?oe=ce/r:oe&&(ce=oe*r),v&&oe>v&&(oe=v)),Lg(ce>0||oe>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,oe,l,d,f,g,r);var le=!Array.isArray(_)&&T0(_.type).endsWith("Chart");return ut.Children.map(_,function(de){return ut.isValidElement(de)?M.cloneElement(de,Y8({width:ce,height:oe},le?{style:Y8({height:"100%",width:"100%",maxHeight:oe,maxWidth:ce},de.props.style)}:{})):de})},[r,_,d,v,g,f,H,l]);return ut.createElement("div",{id:j?"".concat(j):void 0,className:Ri("recharts-responsive-container",N),style:Y8(Y8({},I),{},{width:l,height:d,minWidth:f,minHeight:g,maxHeight:v}),ref:L},se)}),Fle=function(s){return null};Fle.displayName="Cell";function r6(t){"@babel/helpers - typeof";return r6=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},r6(t)}function nEe(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 nye(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||SM.isSsr)return{width:0,height:0};var n=pKt(r),a=JSON.stringify({text:s,copyStyle:n});if(t4.widthCache[a])return t4.widthCache[a];try{var o=document.getElementById(aEe);o||(o=document.createElement("span"),o.setAttribute("id",aEe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=nye(nye({},mKt),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return t4.widthCache[a]=d,++t4.cacheCount>hKt&&(t4.cacheCount=0,t4.widthCache={}),d}catch{return{width:0,height:0}}},fKt=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function n6(t){"@babel/helpers - typeof";return n6=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},n6(t)}function Sae(t,s){return vKt(t)||yKt(t,s)||xKt(t,s)||gKt()}function gKt(){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 xKt(t,s){if(t){if(typeof t=="string")return iEe(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 iEe(t,s)}}function iEe(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 IKt(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 hEe(t,s){return RKt(t)||OKt(t,s)||DKt(t,s)||LKt()}function LKt(){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 DKt(t,s){if(t){if(typeof t=="string")return mEe(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 mEe(t,s)}}function mEe(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(oe,le){var de=le.word,xe=le.width,be=oe[oe.length-1];if(be&&(a==null||o||be.width+xe+nle.width?oe:le})};if(!f)return _;for(var w="…",j=function(ce){var oe=g.slice(0,ce),le=RKe({breakAll:u,style:d,children:oe+w}).wordsWithComputedWidth,de=v(le),xe=de.length>l||b(de).width>Number(a);return[xe,de]},N=0,S=g.length-1,A=0,I;N<=S&&A<=g.length-1;){var L=Math.floor((N+S)/2),F=L-1,$=j(F),q=hEe($,2),H=q[0],U=q[1],Q=j(L),se=hEe(Q,1),te=se[0];if(!H&&!te&&(N=L+1),H&&te&&(S=L-1),!H&&te){I=U;break}A++}return I||_},pEe=function(s){var r=Gi(s)?[]:s.toString().split(OKe);return[{words:r}]},zKt=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!SM.isSsr){var d,u,f=RKe({breakAll:l,children:a,style:o});if(f){var g=f.wordsWithComputedWidth,v=f.spaceWidth;d=g,u=v}else return pEe(a);return FKt({breakAll:l,children:a,maxLines:i,style:o},d,u,r,n)}return pEe(a)},fEe="#808080",RN=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,d=s.capHeight,u=d===void 0?"0.71em":d,f=s.scaleToFit,g=f===void 0?!1:f,v=s.textAnchor,_=v===void 0?"start":v,b=s.verticalAnchor,w=b===void 0?"end":b,j=s.fill,N=j===void 0?fEe:j,S=uEe(s,EKt),A=M.useMemo(function(){return zKt({breakAll:S.breakAll,children:S.children,maxLines:S.maxLines,scaleToFit:g,style:S.style,width:S.width})},[S.breakAll,S.children,S.maxLines,g,S.style,S.width]),I=S.dx,L=S.dy,F=S.angle,$=S.className,q=S.breakAll,H=uEe(S,PKt);if(!Od(n)||!Od(o))return null;var U=n+(sn(I)?I:0),Q=o+(sn(L)?L:0),se;switch(w){case"start":se=Rme("calc(".concat(u,")"));break;case"middle":se=Rme("calc(".concat((A.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:se=Rme("calc(".concat(A.length-1," * -").concat(i,")"));break}var te=[];if(g){var Y=A[0].width,ce=S.width;te.push("scale(".concat((sn(ce)?ce/Y:1)/Y,")"))}return F&&te.push("rotate(".concat(F,", ").concat(U,", ").concat(Q,")")),te.length&&(H.transform=te.join(" ")),ut.createElement("text",aye({},ci(H,!0),{x:U,y:Q,className:Ri("recharts-text",$),textAnchor:_,fill:N.includes("url")?fEe:N}),A.map(function(oe,le){var de=oe.words.join(q?"":" ");return ut.createElement("tspan",{x:U,dy:le===0?se:i,key:"".concat(de,"-").concat(le)},de)}))};function l_(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function BKt(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function owe(t){let s,r,n;t.length!==2?(s=l_,r=(i,d)=>l_(t(i),d),n=(i,d)=>t(i)-d):(s=t===l_||t===BKt?t:$Kt,r=t,n=t);function a(i,d,u=0,f=i.length){if(u>>1;r(i[g],d)<0?u=g+1:f=g}while(u>>1;r(i[g],d)<=0?u=g+1:f=g}while(uu&&n(i[g-1],d)>-n(i[g],d)?g-1:g}return{left:a,center:l,right:o}}function $Kt(){return 0}function FKe(t){return t===null?NaN:+t}function*qKt(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const UKt=owe(l_),FL=UKt.right;owe(FKe).center;class gEe extends Map{constructor(s,r=WKt){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(xEe(this,s))}has(s){return super.has(xEe(this,s))}set(s,r){return super.set(VKt(this,s),r)}delete(s){return super.delete(HKt(this,s))}}function xEe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function VKt({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function HKt({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function WKt(t){return t!==null&&typeof t=="object"?t.valueOf():t}function GKt(t=l_){if(t===l_)return zKe;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 zKe(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const KKt=Math.sqrt(50),ZKt=Math.sqrt(10),YKt=Math.sqrt(2);function Cae(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>=KKt?10:o>=ZKt?5:o>=YKt?2:1;let i,d,u;return a<0?(u=Math.pow(10,-a)/l,i=Math.round(t*u),d=Math.round(s*u),i/us&&--d,u=-u):(u=Math.pow(10,a)*l,i=Math.round(t/u),d=Math.round(s/u),i*us&&--d),d0))return[];if(t===s)return[t];const n=s=a))return[];const i=o-a+1,d=new Array(i);if(n)if(l<0)for(let u=0;u=n)&&(r=n);return r}function vEe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function BKe(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?zKe:GKt(a);n>r;){if(n-r>600){const d=n-r+1,u=s-r+1,f=Math.log(d),g=.5*Math.exp(2*f/3),v=.5*Math.sqrt(f*g*(d-g)/d)*(u-d/2<0?-1:1),_=Math.max(r,Math.floor(s-u*g/d+v)),b=Math.min(n,Math.floor(s+(d-u)*g/d+v));BKe(t,s,_,b,a)}const o=t[s];let l=r,i=n;for(XA(t,r,s),a(t[n],o)>0&&XA(t,r,n);l0;)--i}a(t[r],o)===0?XA(t,r,i):(++i,XA(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function XA(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function XKt(t,s,r){if(t=Float64Array.from(qKt(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return vEe(t);if(s>=1)return yEe(t);var n,a=(n-1)*s,o=Math.floor(a),l=yEe(BKe(t,o).subarray(0,o+1)),i=vEe(t.subarray(o+1));return l+(i-l)*(a-o)}}function QKt(t,s,r=FKe){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 JKt(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?Q8(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?Q8(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=tZt.exec(t))?new bm(s[1],s[2],s[3],1):(s=sZt.exec(t))?new bm(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=rZt.exec(t))?Q8(s[1],s[2],s[3],s[4]):(s=nZt.exec(t))?Q8(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=aZt.exec(t))?SEe(s[1],s[2]/100,s[3]/100,1):(s=iZt.exec(t))?SEe(s[1],s[2]/100,s[3]/100,s[4]):_Ee.hasOwnProperty(t)?jEe(_Ee[t]):t==="transparent"?new bm(NaN,NaN,NaN,0):null}function jEe(t){return new bm(t>>16&255,t>>8&255,t&255,1)}function Q8(t,s,r,n){return n<=0&&(t=s=r=NaN),new bm(t,s,r,n)}function cZt(t){return t instanceof zL||(t=l6(t)),t?(t=t.rgb(),new bm(t.r,t.g,t.b,t.opacity)):new bm}function dye(t,s,r,n){return arguments.length===1?cZt(t):new bm(t,s,r,n??1)}function bm(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}cwe(bm,dye,qKe(zL,{brighter(t){return t=t==null?Mae:Math.pow(Mae,t),new bm(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?i6:Math.pow(i6,t),new bm(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new bm(dN(this.r),dN(this.g),dN(this.b),Tae(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:kEe,formatHex:kEe,formatHex8:dZt,formatRgb:NEe,toString:NEe}));function kEe(){return`#${Sk(this.r)}${Sk(this.g)}${Sk(this.b)}`}function dZt(){return`#${Sk(this.r)}${Sk(this.g)}${Sk(this.b)}${Sk((isNaN(this.opacity)?1:this.opacity)*255)}`}function NEe(){const t=Tae(this.opacity);return`${t===1?"rgb(":"rgba("}${dN(this.r)}, ${dN(this.g)}, ${dN(this.b)}${t===1?")":`, ${t})`}`}function Tae(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function dN(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Sk(t){return t=dN(t),(t<16?"0":"")+t.toString(16)}function SEe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new bg(t,s,r,n)}function UKe(t){if(t instanceof bg)return new bg(t.h,t.s,t.l,t.opacity);if(t instanceof zL||(t=l6(t)),!t)return new bg;if(t instanceof bg)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,d=(o+a)/2;return i?(s===o?l=(r-n)/i+(r0&&d<1?0:l,new bg(l,i,d,t.opacity)}function uZt(t,s,r,n){return arguments.length===1?UKe(t):new bg(t,s,r,n??1)}function bg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}cwe(bg,uZt,qKe(zL,{brighter(t){return t=t==null?Mae:Math.pow(Mae,t),new bg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?i6:Math.pow(i6,t),new bg(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 bm(Fme(t>=240?t-240:t+120,a,n),Fme(t,a,n),Fme(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new bg(CEe(this.h),J8(this.s),J8(this.l),Tae(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=Tae(this.opacity);return`${t===1?"hsl(":"hsla("}${CEe(this.h)}, ${J8(this.s)*100}%, ${J8(this.l)*100}%${t===1?")":`, ${t})`}`}}));function CEe(t){return t=(t||0)%360,t<0?t+360:t}function J8(t){return Math.max(0,Math.min(1,t||0))}function Fme(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 dwe=t=>()=>t;function hZt(t,s){return function(r){return t+r*s}}function mZt(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 pZt(t){return(t=+t)==1?VKe:function(s,r){return r-s?mZt(s,r,t):dwe(isNaN(s)?r:s)}}function VKe(t,s){var r=s-t;return r?hZt(t,r):dwe(isNaN(t)?s:t)}const MEe=function t(s){var r=pZt(s);function n(a,o){var l=r((a=dye(a)).r,(o=dye(o)).r),i=r(a.g,o.g),d=r(a.b,o.b),u=VKe(a.opacity,o.opacity);return function(f){return a.r=l(f),a.g=i(f),a.b=d(f),a.opacity=u(f),a+""}}return n.gamma=t,n}(1);function fZt(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,d.push({i:l,x:Aae(n,a)})),r=zme.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function SZt(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?CZt:SZt,d=u=null,g}function g(v){return v==null||isNaN(v=+v)?o:(d||(d=i(t.map(n),s,r)))(n(l(v)))}return g.invert=function(v){return l(a((u||(u=i(s,t.map(n),Aae)))(v)))},g.domain=function(v){return arguments.length?(t=Array.from(v,Eae),f()):t.slice()},g.range=function(v){return arguments.length?(s=Array.from(v),f()):s.slice()},g.rangeRound=function(v){return s=Array.from(v),r=uwe,f()},g.clamp=function(v){return arguments.length?(l=v?!0:Ah,f()):l!==Ah},g.interpolate=function(v){return arguments.length?(r=v,f()):r},g.unknown=function(v){return arguments.length?(o=v,g):o},function(v,_){return n=v,a=_,f()}}function hwe(){return zle()(Ah,Ah)}function MZt(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Pae(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 k3(t){return t=Pae(Math.abs(t)),t?t[1]:NaN}function TZt(t,s){return function(r,n){for(var a=r.length,o=[],l=0,i=t[0],d=0;a>0&&i>0&&(d+i+1>n&&(i=Math.max(1,n-d)),o.push(r.substring(a-=i,a+i)),!((d+=i+1)>n));)i=t[l=(l+1)%t.length];return o.reverse().join(s)}}function AZt(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var EZt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function c6(t){if(!(s=EZt.exec(t)))throw new Error("invalid format: "+t);var s;return new mwe({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]})}c6.prototype=mwe.prototype;function mwe(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+""}mwe.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 PZt(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 HKe;function IZt(t,s){var r=Pae(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(HKe=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")+Pae(t,Math.max(0,s+o-1))[0]}function AEe(t,s){var r=Pae(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 EEe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:MZt,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)=>AEe(t*100,s),r:AEe,s:IZt,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function PEe(t){return t}var IEe=Array.prototype.map,LEe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function LZt(t){var s=t.grouping===void 0||t.thousands===void 0?PEe:TZt(IEe.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?PEe:AZt(IEe.call(t.numerals,String)),l=t.percent===void 0?"%":t.percent+"",i=t.minus===void 0?"−":t.minus+"",d=t.nan===void 0?"NaN":t.nan+"";function u(g){g=c6(g);var v=g.fill,_=g.align,b=g.sign,w=g.symbol,j=g.zero,N=g.width,S=g.comma,A=g.precision,I=g.trim,L=g.type;L==="n"?(S=!0,L="g"):EEe[L]||(A===void 0&&(A=12),I=!0,L="g"),(j||v==="0"&&_==="=")&&(j=!0,v="0",_="=");var F=w==="$"?r:w==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():"",$=w==="$"?n:/[%p]/.test(L)?l:"",q=EEe[L],H=/[defgprs%]/.test(L);A=A===void 0?6:/[gprs]/.test(L)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function U(Q){var se=F,te=$,Y,ce,oe;if(L==="c")te=q(Q)+te,Q="";else{Q=+Q;var le=Q<0||1/Q<0;if(Q=isNaN(Q)?d:q(Math.abs(Q),A),I&&(Q=PZt(Q)),le&&+Q==0&&b!=="+"&&(le=!1),se=(le?b==="("?b:i:b==="-"||b==="("?"":b)+se,te=(L==="s"?LEe[8+HKe/3]:"")+te+(le&&b==="("?")":""),H){for(Y=-1,ce=Q.length;++Yoe||oe>57){te=(oe===46?a+Q.slice(Y+1):Q.slice(Y))+te,Q=Q.slice(0,Y);break}}}S&&!j&&(Q=s(Q,1/0));var de=se.length+Q.length+te.length,xe=de>1)+se+Q+te+xe.slice(de);break;default:Q=xe+se+Q+te;break}return o(Q)}return U.toString=function(){return g+""},U}function f(g,v){var _=u((g=c6(g),g.type="f",g)),b=Math.max(-8,Math.min(8,Math.floor(k3(v)/3)))*3,w=Math.pow(10,-b),j=LEe[8+b/3];return function(N){return _(w*N)+j}}return{format:u,formatPrefix:f}}var eR,pwe,WKe;DZt({thousands:",",grouping:[3],currency:["$",""]});function DZt(t){return eR=LZt(t),pwe=eR.format,WKe=eR.formatPrefix,eR}function OZt(t){return Math.max(0,-k3(Math.abs(t)))}function RZt(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(k3(s)/3)))*3-k3(Math.abs(t)))}function FZt(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,k3(s)-k3(t))+1}function GKe(t,s,r,n){var a=lye(t,s,r),o;switch(n=c6(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=RZt(a,l))&&(n.precision=o),WKe(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=FZt(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=OZt(a))&&(n.precision=o-(n.type==="%")*2);break}}return pwe(n)}function U_(t){var s=t.domain;return t.ticks=function(r){var n=s();return iye(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return GKe(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],d,u,f=10;for(i0;){if(u=oye(l,i,r),u===d)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;d=u}return t},t}function Iae(){var t=hwe();return t.copy=function(){return BL(t,Iae())},Nf.apply(t,arguments),U_(t)}function KKe(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,Eae),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return KKe(t).unknown(s)},t=arguments.length?Array.from(t,Eae):[0,1],U_(r)}function ZKe(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 UZt(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 REe(t){return(s,r)=>-t(-s,r)}function fwe(t){const s=t(DEe,OEe),r=s.domain;let n=10,a,o;function l(){return a=UZt(n),o=qZt(n),r()[0]<0?(a=REe(a),o=REe(o),t(zZt,BZt)):t(DEe,OEe),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 d=r();let u=d[0],f=d[d.length-1];const g=f0){for(;v<=_;++v)for(b=1;bf)break;N.push(w)}}else for(;v<=_;++v)for(b=n-1;b>=1;--b)if(w=v>0?b/o(-v):b*o(v),!(wf)break;N.push(w)}N.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=c6(d)).precision==null&&(d.trim=!0),d=pwe(d)),i===1/0)return d;const u=Math.max(1,n*i/s.ticks().length);return f=>{let g=f/o(Math.round(a(f)));return g*nr(ZKe(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function YKe(){const t=fwe(zle()).domain([1,10]);return t.copy=()=>BL(t,YKe()).base(t.base()),Nf.apply(t,arguments),t}function FEe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function zEe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function gwe(t){var s=1,r=t(FEe(s),zEe(s));return r.constant=function(n){return arguments.length?t(FEe(s=+n),zEe(s)):s},U_(r)}function XKe(){var t=gwe(zle());return t.copy=function(){return BL(t,XKe()).constant(t.constant())},Nf.apply(t,arguments)}function BEe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function VZt(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function HZt(t){return t<0?-t*t:t*t}function xwe(t){var s=t(Ah,Ah),r=1;function n(){return r===1?t(Ah,Ah):r===.5?t(VZt,HZt):t(BEe(r),BEe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},U_(s)}function ywe(){var t=xwe(zle());return t.copy=function(){return BL(t,ywe()).exponent(t.exponent())},Nf.apply(t,arguments),t}function WZt(){return ywe.apply(null,arguments).exponent(.5)}function $Ee(t){return Math.sign(t)*t*t}function GZt(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function QKe(){var t=hwe(),s=[0,1],r=!1,n;function a(o){var l=GZt(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert($Ee(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,Eae)).map($Ee)),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 QKe(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Nf.apply(a,arguments),U_(a)}function JKe(){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(d){return arguments.length&&(o=d),l},l.thresholds=function(){return n.slice()},l.copy=function(){return eZe().domain([t,s]).range(a).unknown(o)},Nf.apply(U_(l),arguments)}function tZe(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[FL(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 tZe().domain(t).range(s).unknown(r)},Nf.apply(a,arguments)}const Bme=new Date,$me=new Date;function Ud(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 d=[];if(o=a.ceil(o),i=i==null?1:Math.floor(i),!(o0))return d;let u;do d.push(u=new Date(+o)),s(o,i),t(o);while(uUd(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)=>(Bme.setTime(+o),$me.setTime(+l),t(Bme),t($me),Math.floor(r(Bme,$me))),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 Lae=Ud(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);Lae.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ud(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):Lae);Lae.range;const d0=1e3,sf=d0*60,u0=sf*60,B0=u0*24,vwe=B0*7,qEe=B0*30,qme=B0*365,Ck=Ud(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*d0)},(t,s)=>(s-t)/d0,t=>t.getUTCSeconds());Ck.range;const _we=Ud(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*d0)},(t,s)=>{t.setTime(+t+s*sf)},(t,s)=>(s-t)/sf,t=>t.getMinutes());_we.range;const bwe=Ud(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*sf)},(t,s)=>(s-t)/sf,t=>t.getUTCMinutes());bwe.range;const wwe=Ud(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*d0-t.getMinutes()*sf)},(t,s)=>{t.setTime(+t+s*u0)},(t,s)=>(s-t)/u0,t=>t.getHours());wwe.range;const jwe=Ud(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*u0)},(t,s)=>(s-t)/u0,t=>t.getUTCHours());jwe.range;const $L=Ud(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*sf)/B0,t=>t.getDate()-1);$L.range;const Ble=Ud(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/B0,t=>t.getUTCDate()-1);Ble.range;const sZe=Ud(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/B0,t=>Math.floor(t/B0));sZe.range;function JN(t){return Ud(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())*sf)/vwe)}const $le=JN(0),Dae=JN(1),KZt=JN(2),ZZt=JN(3),N3=JN(4),YZt=JN(5),XZt=JN(6);$le.range;Dae.range;KZt.range;ZZt.range;N3.range;YZt.range;XZt.range;function eS(t){return Ud(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)/vwe)}const qle=eS(0),Oae=eS(1),QZt=eS(2),JZt=eS(3),S3=eS(4),eYt=eS(5),tYt=eS(6);qle.range;Oae.range;QZt.range;JZt.range;S3.range;eYt.range;tYt.range;const kwe=Ud(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());kwe.range;const Nwe=Ud(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());Nwe.range;const $0=Ud(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());$0.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ud(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)});$0.range;const q0=Ud(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());q0.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ud(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)});q0.range;function rZe(t,s,r,n,a,o){const l=[[Ck,1,d0],[Ck,5,5*d0],[Ck,15,15*d0],[Ck,30,30*d0],[o,1,sf],[o,5,5*sf],[o,15,15*sf],[o,30,30*sf],[a,1,u0],[a,3,3*u0],[a,6,6*u0],[a,12,12*u0],[n,1,B0],[n,2,2*B0],[r,1,vwe],[s,1,qEe],[s,3,3*qEe],[t,1,qme]];function i(u,f,g){const v=fj).right(l,v);if(_===l.length)return t.every(lye(u/qme,f/qme,g));if(_===0)return Lae.every(Math.max(lye(u,f,g),1));const[b,w]=l[v/l[_-1][2]53)return null;"w"in Le||(Le.w=1),"Z"in Le?(fe=Vme(QA(Le.y,0,1)),Qe=fe.getUTCDay(),fe=Qe>4||Qe===0?Oae.ceil(fe):Oae(fe),fe=Ble.offset(fe,(Le.V-1)*7),Le.y=fe.getUTCFullYear(),Le.m=fe.getUTCMonth(),Le.d=fe.getUTCDate()+(Le.w+6)%7):(fe=Ume(QA(Le.y,0,1)),Qe=fe.getDay(),fe=Qe>4||Qe===0?Dae.ceil(fe):Dae(fe),fe=$L.offset(fe,(Le.V-1)*7),Le.y=fe.getFullYear(),Le.m=fe.getMonth(),Le.d=fe.getDate()+(Le.w+6)%7)}else("W"in Le||"U"in Le)&&("w"in Le||(Le.w="u"in Le?Le.u%7:"W"in Le?1:0),Qe="Z"in Le?Vme(QA(Le.y,0,1)).getUTCDay():Ume(QA(Le.y,0,1)).getDay(),Le.m=0,Le.d="W"in Le?(Le.w+6)%7+Le.W*7-(Qe+5)%7:Le.w+Le.U*7-(Qe+6)%7);return"Z"in Le?(Le.H+=Le.Z/100|0,Le.M+=Le.Z%100,Vme(Le)):Ume(Le)}}function q(Ie,Ve,dt,Le){for(var Rt=0,fe=Ve.length,Qe=dt.length,at,rt;Rt=Qe)return-1;if(at=Ve.charCodeAt(Rt++),at===37){if(at=Ve.charAt(Rt++),rt=L[at in UEe?Ve.charAt(Rt++):at],!rt||(Le=rt(Ie,dt,Le))<0)return-1}else if(at!=dt.charCodeAt(Le++))return-1}return Le}function H(Ie,Ve,dt){var Le=u.exec(Ve.slice(dt));return Le?(Ie.p=f.get(Le[0].toLowerCase()),dt+Le[0].length):-1}function U(Ie,Ve,dt){var Le=_.exec(Ve.slice(dt));return Le?(Ie.w=b.get(Le[0].toLowerCase()),dt+Le[0].length):-1}function Q(Ie,Ve,dt){var Le=g.exec(Ve.slice(dt));return Le?(Ie.w=v.get(Le[0].toLowerCase()),dt+Le[0].length):-1}function se(Ie,Ve,dt){var Le=N.exec(Ve.slice(dt));return Le?(Ie.m=S.get(Le[0].toLowerCase()),dt+Le[0].length):-1}function te(Ie,Ve,dt){var Le=w.exec(Ve.slice(dt));return Le?(Ie.m=j.get(Le[0].toLowerCase()),dt+Le[0].length):-1}function Y(Ie,Ve,dt){return q(Ie,s,Ve,dt)}function ce(Ie,Ve,dt){return q(Ie,r,Ve,dt)}function oe(Ie,Ve,dt){return q(Ie,n,Ve,dt)}function le(Ie){return l[Ie.getDay()]}function de(Ie){return o[Ie.getDay()]}function xe(Ie){return d[Ie.getMonth()]}function be(Ie){return i[Ie.getMonth()]}function ye(Ie){return a[+(Ie.getHours()>=12)]}function ve(Ie){return 1+~~(Ie.getMonth()/3)}function ke(Ie){return l[Ie.getUTCDay()]}function Ge(Ie){return o[Ie.getUTCDay()]}function Ne(Ie){return d[Ie.getUTCMonth()]}function Ae(Ie){return i[Ie.getUTCMonth()]}function Pe(Ie){return a[+(Ie.getUTCHours()>=12)]}function Fe(Ie){return 1+~~(Ie.getUTCMonth()/3)}return{format:function(Ie){var Ve=F(Ie+="",A);return Ve.toString=function(){return Ie},Ve},parse:function(Ie){var Ve=$(Ie+="",!1);return Ve.toString=function(){return Ie},Ve},utcFormat:function(Ie){var Ve=F(Ie+="",I);return Ve.toString=function(){return Ie},Ve},utcParse:function(Ie){var Ve=$(Ie+="",!0);return Ve.toString=function(){return Ie},Ve}}}var UEe={"-":"",_:" ",0:"0"},fu=/^\s*\d+/,oYt=/^%/,lYt=/[\\^$*+?|[\]().{}]/g;function Io(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function dYt(t,s,r){var n=fu.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function uYt(t,s,r){var n=fu.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function hYt(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function mYt(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function pYt(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function VEe(t,s,r){var n=fu.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function HEe(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function fYt(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 gYt(t,s,r){var n=fu.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function xYt(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function WEe(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function yYt(t,s,r){var n=fu.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function GEe(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function vYt(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function _Yt(t,s,r){var n=fu.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function bYt(t,s,r){var n=fu.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function wYt(t,s,r){var n=fu.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function jYt(t,s,r){var n=oYt.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function kYt(t,s,r){var n=fu.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function NYt(t,s,r){var n=fu.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function KEe(t,s){return Io(t.getDate(),s,2)}function SYt(t,s){return Io(t.getHours(),s,2)}function CYt(t,s){return Io(t.getHours()%12||12,s,2)}function MYt(t,s){return Io(1+$L.count($0(t),t),s,3)}function nZe(t,s){return Io(t.getMilliseconds(),s,3)}function TYt(t,s){return nZe(t,s)+"000"}function AYt(t,s){return Io(t.getMonth()+1,s,2)}function EYt(t,s){return Io(t.getMinutes(),s,2)}function PYt(t,s){return Io(t.getSeconds(),s,2)}function IYt(t){var s=t.getDay();return s===0?7:s}function LYt(t,s){return Io($le.count($0(t)-1,t),s,2)}function aZe(t){var s=t.getDay();return s>=4||s===0?N3(t):N3.ceil(t)}function DYt(t,s){return t=aZe(t),Io(N3.count($0(t),t)+($0(t).getDay()===4),s,2)}function OYt(t){return t.getDay()}function RYt(t,s){return Io(Dae.count($0(t)-1,t),s,2)}function FYt(t,s){return Io(t.getFullYear()%100,s,2)}function zYt(t,s){return t=aZe(t),Io(t.getFullYear()%100,s,2)}function BYt(t,s){return Io(t.getFullYear()%1e4,s,4)}function $Yt(t,s){var r=t.getDay();return t=r>=4||r===0?N3(t):N3.ceil(t),Io(t.getFullYear()%1e4,s,4)}function qYt(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Io(s/60|0,"0",2)+Io(s%60,"0",2)}function ZEe(t,s){return Io(t.getUTCDate(),s,2)}function UYt(t,s){return Io(t.getUTCHours(),s,2)}function VYt(t,s){return Io(t.getUTCHours()%12||12,s,2)}function HYt(t,s){return Io(1+Ble.count(q0(t),t),s,3)}function iZe(t,s){return Io(t.getUTCMilliseconds(),s,3)}function WYt(t,s){return iZe(t,s)+"000"}function GYt(t,s){return Io(t.getUTCMonth()+1,s,2)}function KYt(t,s){return Io(t.getUTCMinutes(),s,2)}function ZYt(t,s){return Io(t.getUTCSeconds(),s,2)}function YYt(t){var s=t.getUTCDay();return s===0?7:s}function XYt(t,s){return Io(qle.count(q0(t)-1,t),s,2)}function oZe(t){var s=t.getUTCDay();return s>=4||s===0?S3(t):S3.ceil(t)}function QYt(t,s){return t=oZe(t),Io(S3.count(q0(t),t)+(q0(t).getUTCDay()===4),s,2)}function JYt(t){return t.getUTCDay()}function eXt(t,s){return Io(Oae.count(q0(t)-1,t),s,2)}function tXt(t,s){return Io(t.getUTCFullYear()%100,s,2)}function sXt(t,s){return t=oZe(t),Io(t.getUTCFullYear()%100,s,2)}function rXt(t,s){return Io(t.getUTCFullYear()%1e4,s,4)}function nXt(t,s){var r=t.getUTCDay();return t=r>=4||r===0?S3(t):S3.ceil(t),Io(t.getUTCFullYear()%1e4,s,4)}function aXt(){return"+0000"}function YEe(){return"%"}function XEe(t){return+t}function QEe(t){return Math.floor(+t/1e3)}var s4,lZe,cZe;iXt({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 iXt(t){return s4=iYt(t),lZe=s4.format,s4.parse,cZe=s4.utcFormat,s4.utcParse,s4}function oXt(t){return new Date(t)}function lXt(t){return t instanceof Date?+t:+new Date(+t)}function Swe(t,s,r,n,a,o,l,i,d,u){var f=hwe(),g=f.invert,v=f.domain,_=u(".%L"),b=u(":%S"),w=u("%I:%M"),j=u("%I %p"),N=u("%a %d"),S=u("%b %d"),A=u("%B"),I=u("%Y");function L(F){return(d(F)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>XKt(t,o/n))},r.copy=function(){return mZe(s).domain(t)},Y0.apply(r,arguments)}function Vle(){var t=0,s=.5,r=1,n=1,a,o,l,i,d,u=Ah,f,g=!1,v;function _(w){return isNaN(w=+w)?v:(w=.5+((w=+f(w))-o)*(n*ws}var xZe=fXt,gXt=Hle,xXt=xZe,yXt=NM;function vXt(t){return t&&t.length?gXt(t,yXt,xXt):void 0}var _Xt=vXt;const Wle=vo(_Xt);function bXt(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};Yn.decimalPlaces=Yn.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*Vl;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};Yn.dividedBy=Yn.div=function(t){return A0(this,new this.constructor(t))};Yn.dividedToIntegerBy=Yn.idiv=function(t){var s=this,r=s.constructor;return pl(A0(s,new r(t),0,1),r.precision)};Yn.equals=Yn.eq=function(t){return!this.cmp(t)};Yn.exponent=function(){return wd(this)};Yn.greaterThan=Yn.gt=function(t){return this.cmp(t)>0};Yn.greaterThanOrEqualTo=Yn.gte=function(t){return this.cmp(t)>=0};Yn.isInteger=Yn.isint=function(){return this.e>this.d.length-2};Yn.isNegative=Yn.isneg=function(){return this.s<0};Yn.isPositive=Yn.ispos=function(){return this.s>0};Yn.isZero=function(){return this.s===0};Yn.lessThan=Yn.lt=function(t){return this.cmp(t)<0};Yn.lessThanOrEqualTo=Yn.lte=function(t){return this.cmp(t)<1};Yn.logarithm=Yn.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(ap))throw Error(bf+"NaN");if(r.s<1)throw Error(bf+(r.s?"NaN":"-Infinity"));return r.eq(ap)?new n(0):(hc=!1,s=A0(d6(r,o),d6(t,o),o),hc=!0,pl(s,a))};Yn.minus=Yn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?wZe(s,t):_Ze(s,(t.s=-t.s,t))};Yn.modulo=Yn.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(bf+"NaN");return r.s?(hc=!1,s=A0(r,t,0,1).times(t),hc=!0,r.minus(s)):pl(new n(r),a)};Yn.naturalExponential=Yn.exp=function(){return bZe(this)};Yn.naturalLogarithm=Yn.ln=function(){return d6(this)};Yn.negated=Yn.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Yn.plus=Yn.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?_Ze(s,t):wZe(s,(t.s=-t.s,t))};Yn.precision=Yn.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(uN+t);if(s=wd(a)+1,n=a.d.length-1,r=n*Vl+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};Yn.squareRoot=Yn.sqrt=function(){var t,s,r,n,a,o,l,i=this,d=i.constructor;if(i.s<1){if(!i.s)return new d(0);throw Error(bf+"NaN")}for(t=wd(i),hc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=Dx(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=TM((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 d(s)):n=new d(a.toString()),r=d.precision,a=l=r+3;;)if(o=n,n=o.plus(A0(i,o,l+2)).times(.5),Dx(o.d).slice(0,l)===(s=Dx(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(pl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return hc=!0,pl(n,r)};Yn.times=Yn.mul=function(t){var s,r,n,a,o,l,i,d,u,f=this,g=f.constructor,v=f.d,_=(t=new g(t)).d;if(!f.s||!t.s)return new g(0);for(t.s*=f.s,r=f.e+t.e,d=v.length,u=_.length,d=0;){for(s=0,a=d+n;a>n;)i=o[a]+_[n]*v[a-n-1]+s,o[a--]=i%Qd|0,s=i/Qd|0;o[a]=(o[a]+s)%Qd|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,hc?pl(t,g.precision):t};Yn.toDecimalPlaces=Yn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(ry(t,0,MM),s===void 0?s=n.rounding:ry(s,0,8),pl(r,t+wd(r)+1,s))};Yn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=FN(n,!0):(ry(t,0,MM),s===void 0?s=a.rounding:ry(s,0,8),n=pl(new a(n),t+1,s),r=FN(n,!0,t+1)),r};Yn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?FN(a):(ry(t,0,MM),s===void 0?s=o.rounding:ry(s,0,8),n=pl(new o(a),t+wd(a)+1,s),r=FN(n.abs(),!1,t+wd(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Yn.toInteger=Yn.toint=function(){var t=this,s=t.constructor;return pl(new s(t),wd(t)+1,s.rounding)};Yn.toNumber=function(){return+this};Yn.toPower=Yn.pow=function(t){var s,r,n,a,o,l,i=this,d=i.constructor,u=12,f=+(t=new d(t));if(!t.s)return new d(ap);if(i=new d(i),!i.s){if(t.s<1)throw Error(bf+"Infinity");return i}if(i.eq(ap))return i;if(n=d.precision,t.eq(ap))return pl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=f<0?-f:f)<=vZe){for(a=new d(ap),s=Math.ceil(n/Vl+4),hc=!1;r%2&&(a=a.times(i),tPe(a.d,s)),r=TM(r/2),r!==0;)i=i.times(i),tPe(i.d,s);return hc=!0,t.s<0?new d(ap).div(a):pl(a,n)}}else if(o<0)throw Error(bf+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,hc=!1,a=t.times(d6(i,n+u)),hc=!0,a=bZe(a),a.s=o,a};Yn.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=wd(a),n=FN(a,r<=o.toExpNeg||r>=o.toExpPos)):(ry(t,1,MM),s===void 0?s=o.rounding:ry(s,0,8),a=pl(new o(a),t,s),r=wd(a),n=FN(a,t<=r||r<=o.toExpNeg,t)),n};Yn.toSignificantDigits=Yn.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(ry(t,1,MM),s===void 0?s=n.rounding:ry(s,0,8)),pl(new n(r),t,s)};Yn.toString=Yn.valueOf=Yn.val=Yn.toJSON=Yn[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=wd(t),r=t.constructor;return FN(t,s<=r.toExpNeg||s>=r.toExpPos)};function _Ze(t,s){var r,n,a,o,l,i,d,u,f=t.constructor,g=f.precision;if(!t.s||!s.s)return s.s||(s=new f(t)),hc?pl(s,g):s;if(d=t.d,u=s.d,l=t.e,a=s.e,d=d.slice(),o=l-a,o){for(o<0?(n=d,o=-o,i=u.length):(n=u,a=l,i=d.length),l=Math.ceil(g/Vl),i=l>i?l+1:i+1,o>i&&(o=i,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(i=d.length,o=u.length,i-o<0&&(o=i,n=u,u=d,d=n),r=0;o;)r=(d[--o]=d[o]+u[o]+r)/Qd|0,d[o]%=Qd;for(r&&(d.unshift(r),++a),i=d.length;d[--i]==0;)d.pop();return s.d=d,s.e=a,hc?pl(s,g):s}function ry(t,s,r){if(t!==~~t||tr)throw Error(uN+t)}function Dx(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=d=0;ia[i]?1:-1;break}return d}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,d,u,f,g,v,_,b,w,j,N,S,A,I,L,F,$,q,H=n.constructor,U=n.s==a.s?1:-1,Q=n.d,se=a.d;if(!n.s)return new H(n);if(!a.s)throw Error(bf+"Division by zero");for(d=n.e-a.e,$=se.length,L=Q.length,_=new H(U),b=_.d=[],u=0;se[u]==(Q[u]||0);)++u;if(se[u]>(Q[u]||0)&&--d,o==null?S=o=H.precision:l?S=o+(wd(n)-wd(a))+1:S=o,S<0)return new H(0);if(S=S/Vl+2|0,u=0,$==1)for(f=0,se=se[0],S++;(u1&&(se=t(se,f),Q=t(Q,f),$=se.length,L=Q.length),I=$,w=Q.slice(0,$),j=w.length;j<$;)w[j++]=0;q=se.slice(),q.unshift(0),F=se[0],se[1]>=Qd/2&&++F;do f=0,i=s(se,w,$,j),i<0?(N=w[0],$!=j&&(N=N*Qd+(w[1]||0)),f=N/F|0,f>1?(f>=Qd&&(f=Qd-1),g=t(se,f),v=g.length,j=w.length,i=s(g,w,v,j),i==1&&(f--,r(g,$16)throw Error(Twe+wd(t));if(!t.s)return new f(ap);for(hc=!1,i=g,l=new f(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(lk(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new f(ap),f.precision=i;;){if(a=pl(a.times(t),i),r=r.times(++d),l=o.plus(A0(a,r,i)),Dx(l.d).slice(0,i)===Dx(o.d).slice(0,i)){for(;u--;)o=pl(o.times(o),i);return f.precision=g,s==null?(hc=!0,pl(o,g)):o}o=l}}function wd(t){for(var s=t.e*Vl,r=t.d[0];r>=10;r/=10)s++;return s}function Hme(t,s,r){if(s>t.LN10.sd())throw hc=!0,r&&(t.precision=r),Error(bf+"LN10 precision limit exceeded");return pl(new t(t.LN10),s)}function i1(t){for(var s="";t--;)s+="0";return s}function d6(t,s){var r,n,a,o,l,i,d,u,f,g=1,v=10,_=t,b=_.d,w=_.constructor,j=w.precision;if(_.s<1)throw Error(bf+(_.s?"NaN":"-Infinity"));if(_.eq(ap))return new w(0);if(s==null?(hc=!1,u=j):u=s,_.eq(10))return s==null&&(hc=!0),Hme(w,u);if(u+=v,w.precision=u,r=Dx(b),n=r.charAt(0),o=wd(_),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)_=_.times(t),r=Dx(_.d),n=r.charAt(0),g++;o=wd(_),n>1?(_=new w("0."+r),o++):_=new w(n+"."+r.slice(1))}else return d=Hme(w,u+2,j).times(o+""),_=d6(new w(n+"."+r.slice(1)),u-v).plus(d),w.precision=j,s==null?(hc=!0,pl(_,j)):_;for(i=l=_=A0(_.minus(ap),_.plus(ap),u),f=pl(_.times(_),u),a=3;;){if(l=pl(l.times(f),u),d=i.plus(A0(l,new w(a),u)),Dx(d.d).slice(0,u)===Dx(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(Hme(w,u+2,j).times(o+""))),i=A0(i,new w(g),u),w.precision=j,s==null?(hc=!0,pl(i,j)):i;i=d,a+=2}}function ePe(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=TM(r/Vl),t.d=[],n=(r+1)%Vl,r<0&&(n+=Vl),nRae||t.e<-Rae))throw Error(Twe+r)}else t.s=0,t.e=0,t.d=[0];return t}function pl(t,s,r){var n,a,o,l,i,d,u,f,g=t.d;for(l=1,o=g[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=Vl,a=s,u=g[f=0];else{if(f=Math.ceil((n+1)/Vl),o=g.length,f>=o)return t;for(u=o=g[f],l=1;o>=10;o/=10)l++;n%=Vl,a=n-Vl+l}if(r!==void 0&&(o=lk(10,l-a-1),i=u/o%10|0,d=s<0||g[f+1]!==void 0||u%o,d=r<4?(i||d)&&(r==0||r==(t.s<0?3:2)):i>5||i==5&&(r==4||d||r==6&&(n>0?a>0?u/lk(10,l-a):0:g[f-1])%10&1||r==(t.s<0?8:7))),s<1||!g[0])return d?(o=wd(t),g.length=1,s=s-o-1,g[0]=lk(10,(Vl-s%Vl)%Vl),t.e=TM(-s/Vl)||0):(g.length=1,g[0]=t.e=t.s=0),t;if(n==0?(g.length=f,o=1,f--):(g.length=f+1,o=lk(10,Vl-n),g[f]=a>0?(u/lk(10,l-a)%lk(10,a)|0)*o:0),d)for(;;)if(f==0){(g[0]+=o)==Qd&&(g[0]=1,++t.e);break}else{if(g[f]+=o,g[f]!=Qd)break;g[f--]=0,o=1}for(n=g.length;g[--n]===0;)g.pop();if(hc&&(t.e>Rae||t.e<-Rae))throw Error(Twe+wd(t));return t}function wZe(t,s){var r,n,a,o,l,i,d,u,f,g,v=t.constructor,_=v.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new v(t),hc?pl(s,_):s;if(d=t.d,g=s.d,n=s.e,u=t.e,d=d.slice(),l=u-n,l){for(f=l<0,f?(r=d,l=-l,i=g.length):(r=g,n=u,i=d.length),a=Math.max(Math.ceil(_/Vl),i)+2,l>a&&(l=a,r.length=1),r.reverse(),a=l;a--;)r.push(0);r.reverse()}else{for(a=d.length,i=g.length,f=a0;--a)d[i++]=0;for(a=g.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+i1(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+i1(-a-1)+o,r&&(n=r-l)>0&&(o+=i1(n))):a>=l?(o+=i1(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+i1(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=i1(n))),t.s<0?"-"+o:o}function tPe(t,s){if(t.length>s)return t.length=s,!0}function jZe(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(uN+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 ePe(l,o.toString())}else if(typeof o!="string")throw Error(uN+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,qXt.test(o))ePe(l,o);else throw Error(uN+o)}if(a.prototype=Yn,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=jZe,a.config=a.set=UXt,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(uN+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(uN+r+": "+n);return this}var Awe=jZe($Xt);ap=new Awe(1);const il=Awe;function VXt(t){return KXt(t)||GXt(t)||WXt(t)||HXt()}function HXt(){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 WXt(t,s){if(t){if(typeof t=="string")return mye(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 mye(t,s)}}function GXt(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function KXt(t){if(Array.isArray(t))return mye(t)}function mye(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,sPe(function(){for(var i=arguments.length,d=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(d){a=!0,o=d}finally{try{!n&&l.return!=null&&l.return()}finally{if(a)throw o}}return r}}function cQt(t){if(Array.isArray(t))return t}function MZe(t){var s=u6(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function TZe(t,s,r){if(t.lte(0))return new il(0);var n=Yle.getDigitCount(t.toNumber()),a=new il(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new il(Math.ceil(o.div(l).toNumber())).add(r).mul(l),d=i.mul(a);return s?d:new il(Math.ceil(d))}function dQt(t,s,r){var n=1,a=new il(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new il(10).pow(Yle.getDigitCount(t)-1),a=new il(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new il(Math.floor(t)))}else t===0?a=new il(Math.floor((s-1)/2)):r||(a=new il(Math.floor(t)));var l=Math.floor((s-1)/2),i=QXt(XXt(function(d){return a.add(new il(d-l).mul(n)).toNumber()}),pye);return i(0,s)}function AZe(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 il(0),tickMin:new il(0),tickMax:new il(0)};var o=TZe(new il(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new il(0):(l=new il(t).add(s).div(2),l=l.sub(new il(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),d=Math.ceil(new il(s).sub(l).div(o).toNumber()),u=i+d+1;return u>r?AZe(t,s,r,n,a+1):(u0?d+(r-u):d,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new il(i).mul(o)),tickMax:l.add(new il(d).mul(o))})}function uQt(t){var s=u6(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=MZe([r,n]),d=u6(i,2),u=d[0],f=d[1];if(u===-1/0||f===1/0){var g=f===1/0?[u].concat(gye(pye(0,a-1).map(function(){return 1/0}))):[].concat(gye(pye(0,a-1).map(function(){return-1/0})),[f]);return r>n?fye(g):g}if(u===f)return dQt(u,a,o);var v=AZe(u,f,l,o),_=v.step,b=v.tickMin,w=v.tickMax,j=Yle.rangeStep(b,w.add(new il(.1).mul(_)),_);return r>n?fye(j):j}function hQt(t,s){var r=u6(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=MZe([n,a]),i=u6(l,2),d=i[0],u=i[1];if(d===-1/0||u===1/0)return[n,a];if(d===u)return[d];var f=Math.max(s,2),g=TZe(new il(u).sub(d).div(f-1),o,0),v=[].concat(gye(Yle.rangeStep(new il(d),new il(u).sub(new il(.99).mul(g)),g)),[u]);return n>a?fye(v):v}var mQt=SZe(uQt),pQt=SZe(hQt),fQt="Invariant failed";function zN(t,s){throw new Error(fQt)}var gQt=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function C3(t){"@babel/helpers - typeof";return C3=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},C3(t)}function Fae(){return Fae=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 jQt(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 kQt(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function NQt(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 d=o.range,u=0;u0?a[u-1].coordinate:a[i-1].coordinate,g=a[u].coordinate,v=u>=i-1?a[0].coordinate:a[u+1].coordinate,_=void 0;if(Mh(g-f)!==Mh(v-g)){var b=[];if(Mh(v-g)===Mh(d[1]-d[0])){_=v;var w=g+d[1]-d[0];b[0]=Math.min(w,(w+f)/2),b[1]=Math.max(w,(w+f)/2)}else{_=f;var j=v+d[1]-d[0];b[0]=Math.min(g,(j+g)/2),b[1]=Math.max(g,(j+g)/2)}var N=[Math.min(g,(_+g)/2),Math.max(g,(_+g)/2)];if(s>N[0]&&s<=N[1]||s>=b[0]&&s<=b[1]){l=a[u].index;break}}else{var S=Math.min(f,v),A=Math.max(f,v);if(s>(S+g)/2&&s<=(A+g)/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},Ewe=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?Dc(Dc({},s.type.defaultProps),s.props):s.props,l=o.stroke,i=o.fill,d;switch(a){case"Line":d=l;break;case"Area":case"Radar":d=l&&l!=="none"?l:i;break;default:d=i;break}return d},qQt=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),d=0,u=i.length;d=0});if(N&&N.length){var S=N[0].type.defaultProps,A=S!==void 0?Dc(Dc({},S),N[0].props):N[0].props,I=A.barSize,L=A[j];l[L]||(l[L]=[]);var F=Gi(I)?r:I;l[L].push({item:N[0],stackList:N.slice(1),barSize:Gi(F)?void 0:Th(F,n,0)})}}return l},UQt=function(s){var r=s.barGap,n=s.barCategoryGap,a=s.bandSize,o=s.sizeList,l=o===void 0?[]:o,i=s.maxBarSize,d=l.length;if(d<1)return null;var u=Th(r,a,0,!0),f,g=[];if(l[0].barSize===+l[0].barSize){var v=!1,_=a/d,b=l.reduce(function(I,L){return I+L.barSize||0},0);b+=(d-1)*u,b>=a&&(b-=(d-1)*u,u=0),b>=a&&_>0&&(v=!0,_*=.9,b=d*_);var w=(a-b)/2>>0,j={offset:w-u,size:0};f=l.reduce(function(I,L){var F={item:L.item,position:{offset:j.offset+j.size+u,size:v?_:L.barSize}},$=[].concat(aPe(I),[F]);return j=$[$.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:j})}),$},g)}else{var N=Th(n,a,0,!0);a-2*N-(d-1)*u<=0&&(u=0);var S=(a-2*N-(d-1)*u)/d;S>1&&(S>>=0);var A=i===+i?Math.min(S,i):S;f=l.reduce(function(I,L,F){var $=[].concat(aPe(I),[{item:L.item,position:{offset:N+(S+u)*F+(S-A)/2,size:A}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:$[$.length-1].position})}),$},g)}return f},VQt=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),u=LZe({children:o,legendWidth:d});if(u){var f=a||{},g=f.width,v=f.height,_=u.align,b=u.verticalAlign,w=u.layout;if((w==="vertical"||w==="horizontal"&&b==="middle")&&_!=="center"&&sn(s[_]))return Dc(Dc({},s),{},E5({},_,s[_]+(g||0)));if((w==="horizontal"||w==="vertical"&&_==="center")&&b!=="middle"&&sn(s[b]))return Dc(Dc({},s),{},E5({},b,s[b]+(v||0)))}return s},HQt=function(s,r,n){return Gi(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},DZe=function(s,r,n,a,o){var l=r.props.children,i=hf(l,Xle).filter(function(u){return HQt(a,o,u.props.direction)});if(i&&i.length){var d=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,f){var g=Gu(f,n);if(Gi(g))return u;var v=Array.isArray(g)?[Gle(g),Wle(g)]:[g,g],_=d.reduce(function(b,w){var j=Gu(f,w,0),N=v[0]-Math.abs(Array.isArray(j)?j[0]:j),S=v[1]+Math.abs(Array.isArray(j)?j[1]:j);return[Math.min(N,b[0]),Math.max(S,b[1])]},[1/0,-1/0]);return[Math.min(_[0],u[0]),Math.max(_[1],u[1])]},[1/0,-1/0])}return null},WQt=function(s,r,n,a,o){var l=r.map(function(i){return DZe(s,i,n,o,a)}).filter(function(i){return!Gi(i)});return l&&l.length?l.reduce(function(i,d){return[Math.min(i[0],d[0]),Math.max(i[1],d[1])]},[1/0,-1/0]):null},OZe=function(s,r,n,a,o){var l=r.map(function(d){var u=d.props.dataKey;return n==="number"&&u&&DZe(s,d,u,a)||ZP(s,u,n,o)});if(n==="number")return l.reduce(function(d,u){return[Math.min(d[0],u[0]),Math.max(d[1],u[1])]},[1/0,-1/0]);var i={};return l.reduce(function(d,u){for(var f=0,g=u.length;f=2?Mh(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var f=(s.ticks||s.niceTicks).map(function(g){var v=o?o.indexOf(g):g;return{coordinate:a(v)+u,value:g,offset:u}});return f.filter(function(g){return!DL(g.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(g,v){return{coordinate:a(g)+u,value:g,index:v,offset:u}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(g){return{coordinate:a(g)+u,value:g,offset:u}}):a.domain().map(function(g,v){return{coordinate:a(g)+u,value:o?o[g]:g,index:v,offset:u}})},Wme=new WeakMap,tR=function(s,r){if(typeof r!="function")return s;Wme.has(s)||Wme.set(s,new WeakMap);var n=Wme.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},zZe=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:a6(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:Iae(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:KP(),realScaleType:"point"}:o==="category"?{scale:a6(),realScaleType:"band"}:{scale:Iae(),realScaleType:"linear"};if(DN(a)){var d="scale".concat(Ele(a));return{scale:(JEe[d]||KP)(),realScaleType:JEe[d]?d:"point"}}return gi(a)?{scale:a}:{scale:KP(),realScaleType:"point"}},oPe=1e-4,BZe=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])-oPe,l=Math.max(a[0],a[1])+oPe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},GQt=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+d,o=s[i][n][1]):(s[i][n][0]=l,s[i][n][1]=l+d,l=s[i][n][1])}},YQt=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)}},XQt={sign:ZQt,expand:gBt,none:v3,silhouette:xBt,wiggle:yBt,positive:YQt},QQt=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=XQt[n],l=fBt().keys(a).value(function(i,d){return+Gu(i,d,0)}).order(Uxe).offset(o);return l(s)},JQt=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,d={},u=i.reduce(function(g,v){var _,b=(_=v.type)!==null&&_!==void 0&&_.defaultProps?Dc(Dc({},v.type.defaultProps),v.props):v.props,w=b.stackId,j=b.hide;if(j)return g;var N=b[n],S=g[N]||{hasStack:!1,stackGroups:{}};if(Od(w)){var A=S.stackGroups[w]||{numericAxisId:n,cateAxisId:a,items:[]};A.items.push(v),S.hasStack=!0,S.stackGroups[w]=A}else S.stackGroups[OL("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[v]};return Dc(Dc({},g),{},E5({},N,S))},d),f={};return Object.keys(u).reduce(function(g,v){var _=u[v];if(_.hasStack){var b={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(w,j){var N=_.stackGroups[j];return Dc(Dc({},w),{},E5({},j,{numericAxisId:n,cateAxisId:a,items:N.items,stackedData:QQt(s,N.items,o)}))},b)}return Dc(Dc({},g),{},E5({},v,_))},f)},$Ze=function(s,r){var n=r.realScaleType,a=r.type,o=r.tickCount,l=r.originalDomain,i=r.allowDecimals,d=n||r.scale;if(d!=="auto"&&d!=="linear")return null;if(o&&a==="number"&&l&&(l[0]==="auto"||l[1]==="auto")){var u=s.domain();if(!u.length)return null;var f=mQt(u,o,i);return s.domain([Gle(f),Wle(f)]),{niceTicks:f}}if(o&&a==="number"){var g=s.domain(),v=pQt(g,o,i);return{niceTicks:v}}return null},lPe=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 d=Gu(l,r.dataKey,r.domain[i]);return Gi(d)?null:r.scale(d)-o/2+a},eJt=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]},tJt=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?Dc(Dc({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(Od(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},sJt=function(s){return s.reduce(function(r,n){return[Gle(n.concat([r[0]]).filter(sn)),Wle(n.concat([r[1]]).filter(sn))]},[1/0,-1/0])},qZe=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,d=i.reduce(function(u,f){var g=sJt(f.slice(r,n+1));return[Math.min(u[0],g[0]),Math.max(u[1],g[1])]},[1/0,-1/0]);return[Math.min(d[0],a[0]),Math.max(d[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},cPe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,dPe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,_ye=function(s,r,n){if(gi(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(sn(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(cPe.test(s[0])){var o=+cPe.exec(s[0])[1];a[0]=r[0]-o}else gi(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(sn(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(dPe.test(s[1])){var l=+dPe.exec(s[1])[1];a[1]=r[1]+l}else gi(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},Bae=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=awe(r,function(g){return g.coordinate}),l=1/0,i=1,d=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},uJt=function(s,r,n,a,o){var l=s.width,i=s.height,d=s.startAngle,u=s.endAngle,f=Th(s.cx,l,l/2),g=Th(s.cy,i,i/2),v=HZe(l,i,n),_=Th(s.innerRadius,v,0),b=Th(s.outerRadius,v,v*.8),w=Object.keys(r);return w.reduce(function(j,N){var S=r[N],A=S.domain,I=S.reversed,L;if(Gi(S.range))a==="angleAxis"?L=[d,u]:a==="radiusAxis"&&(L=[_,b]),I&&(L=[L[1],L[0]]);else{L=S.range;var F=L,$=aJt(F,2);d=$[0],u=$[1]}var q=zZe(S,o),H=q.realScaleType,U=q.scale;U.domain(A).range(L),BZe(U);var Q=$Ze(U,Yy(Yy({},S),{},{realScaleType:H})),se=Yy(Yy(Yy({},S),Q),{},{range:L,radius:b,realScaleType:H,scale:U,cx:f,cy:g,innerRadius:_,outerRadius:b,startAngle:d,endAngle:u});return Yy(Yy({},j),{},VZe({},N,se))},{})},hJt=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))},mJt=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=hJt({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var d=(n-o)/i,u=Math.acos(d);return a>l&&(u=2*Math.PI-u),{radius:i,angle:dJt(u),angleInRadian:u}},pJt=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}},fJt=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},pPe=function(s,r){var n=s.x,a=s.y,o=mJt({x:n,y:a},r),l=o.radius,i=o.angle,d=r.innerRadius,u=r.outerRadius;if(lu)return!1;if(l===0)return!0;var f=pJt(r),g=f.startAngle,v=f.endAngle,_=i,b;if(g<=v){for(;_>v;)_-=360;for(;_=g&&_<=v}else{for(;_>g;)_-=360;for(;_=v&&_<=g}return b?Yy(Yy({},r),{},{radius:l,angle:fJt(_,r)}):null},WZe=function(s){return!M.isValidElement(s)&&!gi(s)&&typeof s!="boolean"?s.className:""};function f6(t){"@babel/helpers - typeof";return f6=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},f6(t)}var gJt=["offset"];function xJt(t){return bJt(t)||_Jt(t)||vJt(t)||yJt()}function yJt(){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 vJt(t,s){if(t){if(typeof t=="string")return bye(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 bye(t,s)}}function _Jt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function bJt(t){if(Array.isArray(t))return bye(t)}function bye(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 jJt(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 fPe(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 Cd(t){for(var s=1;s=0?1:-1,A,I;a==="insideStart"?(A=_+S*l,I=w):a==="insideEnd"?(A=b-S*l,I=!w):a==="end"&&(A=b+S*l,I=w),I=N<=0?I:!I;var L=Tl(u,f,j,A),F=Tl(u,f,j,A+(I?1:-1)*359),$="M".concat(L.x,",").concat(L.y,` A`).concat(j,",").concat(j,",0,1,").concat(I?0:1,`, `).concat(F.x,",").concat(F.y),q=Gi(s.id)?OL("recharts-radial-line-"):s.id;return ut.createElement("text",g6({},n,{dominantBaseline:"central",className:Ri("recharts-radial-bar-label",i)}),ut.createElement("defs",null,ut.createElement("path",{id:q,d:$})),ut.createElement("textPath",{xlinkHref:"#".concat(q)},r))},AJt=function(s){var r=s.viewBox,n=s.offset,a=s.position,o=r,l=o.cx,i=o.cy,d=o.innerRadius,u=o.outerRadius,f=o.startAngle,g=o.endAngle,v=(f+g)/2;if(a==="outside"){var _=Tl(l,i,u+n,v),b=_.x,w=_.y;return{x:b,y:w,textAnchor:b>=l?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"end"};var j=(d+u)/2,N=Tl(l,i,j,v),S=N.x,A=N.y;return{x:S,y:A,textAnchor:"middle",verticalAnchor:"middle"}},EJt=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,o=s.position,l=r,i=l.x,d=l.y,u=l.width,f=l.height,g=f>=0?1:-1,v=g*a,_=g>0?"end":"start",b=g>0?"start":"end",w=u>=0?1:-1,j=w*a,N=w>0?"end":"start",S=w>0?"start":"end";if(o==="top"){var A={x:i+u/2,y:d-g*a,textAnchor:"middle",verticalAnchor:_};return Cd(Cd({},A),n?{height:Math.max(d-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:d+f+v,textAnchor:"middle",verticalAnchor:b};return Cd(Cd({},I),n?{height:Math.max(n.y+n.height-(d+f),0),width:u}:{})}if(o==="left"){var L={x:i-j,y:d+f/2,textAnchor:N,verticalAnchor:"middle"};return Cd(Cd({},L),n?{width:Math.max(L.x-n.x,0),height:f}:{})}if(o==="right"){var F={x:i+u+j,y:d+f/2,textAnchor:S,verticalAnchor:"middle"};return Cd(Cd({},F),n?{width:Math.max(n.x+n.width-F.x,0),height:f}:{})}var $=n?{width:u,height:f}:{};return o==="insideLeft"?Cd({x:i+j,y:d+f/2,textAnchor:S,verticalAnchor:"middle"},$):o==="insideRight"?Cd({x:i+u-j,y:d+f/2,textAnchor:N,verticalAnchor:"middle"},$):o==="insideTop"?Cd({x:i+u/2,y:d+v,textAnchor:"middle",verticalAnchor:b},$):o==="insideBottom"?Cd({x:i+u/2,y:d+f-v,textAnchor:"middle",verticalAnchor:_},$):o==="insideTopLeft"?Cd({x:i+j,y:d+v,textAnchor:S,verticalAnchor:b},$):o==="insideTopRight"?Cd({x:i+u-j,y:d+v,textAnchor:N,verticalAnchor:b},$):o==="insideBottomLeft"?Cd({x:i+j,y:d+f-v,textAnchor:S,verticalAnchor:_},$):o==="insideBottomRight"?Cd({x:i+u-j,y:d+f-v,textAnchor:N,verticalAnchor:_},$):vM(o)&&(sn(o.x)||Nk(o.x))&&(sn(o.y)||Nk(o.y))?Cd({x:i+Th(o.x,u),y:d+Th(o.y,f),textAnchor:"end",verticalAnchor:"end"},$):Cd({x:i+u/2,y:d+f/2,textAnchor:"middle",verticalAnchor:"middle"},$)},PJt=function(s){return"cx"in s&&sn(s.cx)};function ru(t){var s=t.offset,r=s===void 0?5:s,n=wJt(t,gJt),a=Cd({offset:r},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,u=a.content,f=a.className,g=f===void 0?"":f,v=a.textBreakAll;if(!o||Gi(i)&&Gi(d)&&!M.isValidElement(u)&&!gi(u))return null;if(M.isValidElement(u))return M.cloneElement(u,a);var _;if(gi(u)){if(_=M.createElement(u,a),M.isValidElement(_))return _}else _=CJt(a);var b=PJt(o),w=ci(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return TJt(a,_,w);var j=b?AJt(a):EJt(a);return ut.createElement(RN,g6({className:Ri("recharts-label",g)},w,j,{breakAll:v}),_)}ru.displayName="Label";var GZe=function(s){var r=s.cx,n=s.cy,a=s.angle,o=s.startAngle,l=s.endAngle,i=s.r,d=s.radius,u=s.innerRadius,f=s.outerRadius,g=s.x,v=s.y,_=s.top,b=s.left,w=s.width,j=s.height,N=s.clockWise,S=s.labelViewBox;if(S)return S;if(sn(w)&&sn(j)){if(sn(g)&&sn(v))return{x:g,y:v,width:w,height:j};if(sn(_)&&sn(b))return{x:_,y:b,width:w,height:j}}return sn(g)&&sn(v)?{x:g,y:v,width:0,height:0}:sn(r)&&sn(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:f||d||i||0,clockWise:N}:s.viewBox?s.viewBox:{}},IJt=function(s,r){return s?s===!0?ut.createElement(ru,{key:"label-implicit",viewBox:r}):Od(s)?ut.createElement(ru,{key:"label-implicit",viewBox:r,value:s}):M.isValidElement(s)?s.type===ru?M.cloneElement(s,{key:"label-implicit",viewBox:r}):ut.createElement(ru,{key:"label-implicit",content:s,viewBox:r}):gi(s)?ut.createElement(ru,{key:"label-implicit",content:s,viewBox:r}):vM(s)?ut.createElement(ru,g6({viewBox:r},s,{key:"label-implicit"})):null:null},LJt=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=GZe(s),l=hf(a,ru).map(function(d,u){return M.cloneElement(d,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=IJt(s.label,r||o);return[i].concat(xJt(l))};ru.parseViewBox=GZe;ru.renderCallByParent=LJt;function DJt(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var OJt=DJt;const RJt=vo(OJt);function x6(t){"@babel/helpers - typeof";return x6=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},x6(t)}var FJt=["valueAccessor"],zJt=["data","dataKey","clockWise","id","textBreakAll"];function BJt(t){return VJt(t)||UJt(t)||qJt(t)||$Jt()}function $Jt(){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 qJt(t,s){if(t){if(typeof t=="string")return wye(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 wye(t,s)}}function UJt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function VJt(t){if(Array.isArray(t))return wye(t)}function wye(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 KJt(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 ZJt=function(s){return Array.isArray(s.value)?RJt(s.value):s.value};function c_(t){var s=t.valueAccessor,r=s===void 0?ZJt:s,n=yPe(t,FJt),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,u=yPe(n,zJt);return!a||!a.length?null:ut.createElement(Jo,{className:"recharts-label-list"},a.map(function(f,g){var v=Gi(o)?r(f,g):Gu(f&&f.payload,o),_=Gi(i)?{}:{id:"".concat(i,"-").concat(g)};return ut.createElement(ru,qae({},ci(f,!0),u,_,{parentViewBox:f.parentViewBox,value:v,textBreakAll:d,viewBox:ru.parseViewBox(Gi(l)?f:xPe(xPe({},f),{},{clockWise:l})),key:"label-".concat(g),index:g}))}))}c_.displayName="LabelList";function YJt(t,s){return t?t===!0?ut.createElement(c_,{key:"labelList-implicit",data:s}):ut.isValidElement(t)||gi(t)?ut.createElement(c_,{key:"labelList-implicit",data:s,content:t}):vM(t)?ut.createElement(c_,qae({data:s},t,{key:"labelList-implicit"})):null:null}function XJt(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=hf(n,c_).map(function(l,i){return M.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=YJt(t.label,s);return[o].concat(BJt(a))}c_.renderCallByParent=XJt;function y6(t){"@babel/helpers - typeof";return y6=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},y6(t)}function jye(){return jye=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>u),`, `).concat(g.x,",").concat(g.y,` `);if(a>0){var _=Tl(r,n,a,l),b=Tl(r,n,a,u);v+="L ".concat(b.x,",").concat(b.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(d)>180),",").concat(+(l<=u),`, `).concat(_.x,",").concat(_.y," Z")}else v+="L ".concat(r,",").concat(n," Z");return v},ses=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,o=s.outerRadius,l=s.cornerRadius,i=s.forceCornerRadius,d=s.cornerIsExternal,u=s.startAngle,f=s.endAngle,g=Mh(f-u),v=sR({cx:r,cy:n,radius:o,angle:u,sign:g,cornerRadius:l,cornerIsExternal:d}),_=v.circleTangency,b=v.lineTangency,w=v.theta,j=sR({cx:r,cy:n,radius:o,angle:f,sign:-g,cornerRadius:l,cornerIsExternal:d}),N=j.circleTangency,S=j.lineTangency,A=j.theta,I=d?Math.abs(u-f):Math.abs(u-f)-w-A;if(I<0)return i?"M ".concat(b.x,",").concat(b.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 `):KZe({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:f});var L="M ".concat(b.x,",").concat(b.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(I>180),",").concat(+(g<0),",").concat(N.x,",").concat(N.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(S.x,",").concat(S.y,` `);if(a>0){var F=sR({cx:r,cy:n,radius:a,angle:u,sign:g,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),$=F.circleTangency,q=F.lineTangency,H=F.theta,U=sR({cx:r,cy:n,radius:a,angle:f,sign:-g,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),Q=U.circleTangency,se=U.lineTangency,te=U.theta,Y=d?Math.abs(u-f):Math.abs(u-f)-H-te;if(Y<0&&l===0)return"".concat(L,"L").concat(r,",").concat(n,"Z");L+="L".concat(se.x,",").concat(se.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(Q.x,",").concat(Q.y,` A`).concat(a,",").concat(a,",0,").concat(+(Y>180),",").concat(+(g>0),",").concat($.x,",").concat($.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(q.x,",").concat(q.y,"Z")}else L+="L".concat(r,",").concat(n,"Z");return L},res={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},ZZe=function(s){var r=_Pe(_Pe({},res),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,d=r.forceCornerRadius,u=r.cornerIsExternal,f=r.startAngle,g=r.endAngle,v=r.className;if(l0&&Math.abs(f-g)<360?j=ses({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(w,b/2),forceCornerRadius:d,cornerIsExternal:u,startAngle:f,endAngle:g}):j=KZe({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:f,endAngle:g}),ut.createElement("path",jye({},ci(r,!0),{className:_,d:j,role:"img"}))};function v6(t){"@babel/helpers - typeof";return v6=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},v6(t)}function kye(){return kye=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 wes(t,s){return tS(t.getTime(),s.getTime())}function jes(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function kes(t,s){return t===s}function MPe(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,d=0;(l=o.next())&&!l.done;){for(var u=s.entries(),f=!1,g=0;(i=u.next())&&!i.done;){if(a[g]){g++;continue}var v=l.value,_=i.value;if(r.equals(v[0],_[0],d,g,t,s,r)&&r.equals(v[1],_[1],v[0],_[0],t,s,r)){f=a[g]=!0;break}g++}if(!f)return!1;d++}return!0}var Nes=tS;function Ses(t,s,r){var n=CPe(t),a=n.length;if(CPe(s).length!==a)return!1;for(;a-- >0;)if(!JZe(t,s,r,n[a]))return!1;return!0}function rE(t,s,r){var n=NPe(t),a=n.length;if(NPe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!JZe(t,s,r,o)||(l=SPe(t,o),i=SPe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function Ces(t,s){return tS(t.valueOf(),s.valueOf())}function Mes(t,s){return t.source===s.source&&t.flags===s.flags}function TPe(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 d=s.values(),u=!1,f=0;(i=d.next())&&!i.done;){if(!a[f]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){u=a[f]=!0;break}f++}if(!u)return!1}return!0}function Tes(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 Aes(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 JZe(t,s,r,n){return(n===_es||n===ves||n===yes)&&(t.$$typeof||s.$$typeof)?!0:xes(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var Ees="[object Arguments]",Pes="[object Boolean]",Ies="[object Date]",Les="[object Error]",Des="[object Map]",Oes="[object Number]",Res="[object Object]",Fes="[object RegExp]",zes="[object Set]",Bes="[object String]",$es="[object URL]",qes=Array.isArray,APe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,EPe=Object.assign,Ues=Object.prototype.toString.call.bind(Object.prototype.toString);function Ves(t){var s=t.areArraysEqual,r=t.areDatesEqual,n=t.areErrorsEqual,a=t.areFunctionsEqual,o=t.areMapsEqual,l=t.areNumbersEqual,i=t.areObjectsEqual,d=t.arePrimitiveWrappersEqual,u=t.areRegExpsEqual,f=t.areSetsEqual,g=t.areTypedArraysEqual,v=t.areUrlsEqual;return function(b,w,j){if(b===w)return!0;if(b==null||w==null)return!1;var N=typeof b;if(N!==typeof w)return!1;if(N!=="object")return N==="number"?l(b,w,j):N==="function"?a(b,w,j):!1;var S=b.constructor;if(S!==w.constructor)return!1;if(S===Object)return i(b,w,j);if(qes(b))return s(b,w,j);if(APe!=null&&APe(b))return g(b,w,j);if(S===Date)return r(b,w,j);if(S===RegExp)return u(b,w,j);if(S===Map)return o(b,w,j);if(S===Set)return f(b,w,j);var A=Ues(b);return A===Ies?r(b,w,j):A===Fes?u(b,w,j):A===Des?o(b,w,j):A===zes?f(b,w,j):A===Res?typeof b.then!="function"&&typeof w.then!="function"&&i(b,w,j):A===$es?v(b,w,j):A===Les?n(b,w,j):A===Ees?i(b,w,j):A===Pes||A===Oes||A===Bes?d(b,w,j):!1}}function Hes(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?rE:bes,areDatesEqual:wes,areErrorsEqual:jes,areFunctionsEqual:kes,areMapsEqual:n?kPe(MPe,rE):MPe,areNumbersEqual:Nes,areObjectsEqual:n?rE:Ses,arePrimitiveWrappersEqual:Ces,areRegExpsEqual:Mes,areSetsEqual:n?kPe(TPe,rE):TPe,areTypedArraysEqual:n?rE:Tes,areUrlsEqual:Aes};if(r&&(a=EPe({},a,r(a))),s){var o=nR(a.areArraysEqual),l=nR(a.areMapsEqual),i=nR(a.areObjectsEqual),d=nR(a.areSetsEqual);a=EPe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function Wes(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function Ges(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(d,u){var f=n(),g=f.cache,v=g===void 0?s?new WeakMap:void 0:g,_=f.meta;return r(d,u,{cache:v,equals:a,meta:_,strict:o})};if(s)return function(d,u){return r(d,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(d,u){return r(d,u,l)}}var Kes=H_();H_({strict:!0});H_({circular:!0});H_({circular:!0,strict:!0});H_({createInternalComparator:function(){return tS}});H_({strict:!0,createInternalComparator:function(){return tS}});H_({circular:!0,createInternalComparator:function(){return tS}});H_({circular:!0,createInternalComparator:function(){return tS},strict:!0});function H_(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=Hes(t),d=Ves(i),u=n?n(d):Wes(d);return Ges({circular:r,comparator:d,createState:a,equals:u,strict:l})}function Zes(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function PPe(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):Zes(a)};requestAnimationFrame(n)}function Sye(t){"@babel/helpers - typeof";return Sye=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},Sye(t)}function Yes(t){return ets(t)||Jes(t)||Qes(t)||Xes()}function Xes(){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 Qes(t,s){if(t){if(typeof t=="string")return IPe(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 IPe(t,s)}}function IPe(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},w=function(N){for(var S=N>1?1:N,A=S,I=0;I<8;++I){var L=g(A)-S,F=_(A);if(Math.abs(L-S)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,d=function(f,g,v){var _=-(f-g)*n,b=v*o,w=v+(_-b)*i/1e3,j=v*i/1e3+f;return Math.abs(j-g)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 Ets(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 Gme(t){return Dts(t)||Lts(t)||Its(t)||Pts()}function Pts(){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 Its(t,s){if(t){if(typeof t=="string")return Eye(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 Eye(t,s)}}function Lts(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Dts(t){if(Array.isArray(t))return Eye(t)}function Eye(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 Hae(t){return Hae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Hae(t)}var U0=function(t){Bts(r,t);var s=$ts(r);function r(n,a){var o;Ots(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,d=l.attributeName,u=l.from,f=l.to,g=l.steps,v=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(Lye(o)),o.changeStyle=o.changeStyle.bind(Lye(o)),!i||_<=0)return o.state={style:{}},typeof v=="function"&&(o.state={style:f}),Iye(o);if(g&&g.length)o.state={style:g[0].style};else if(u){if(typeof v=="function")return o.state={style:u},Iye(o);o.state={style:d?jE({},d,u):u}}else o.state={style:{}};return o}return Fts(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,d=o.attributeName,u=o.shouldReAnimate,f=o.to,g=o.from,v=this.state.style;if(i){if(!l){var _={style:d?jE({},d,f):f};this.state&&v&&(d&&v[d]!==f||!d&&v!==f)&&this.setState(_);return}if(!(Kes(a.to,f)&&a.canBegin&&a.isActive)){var b=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var w=b||u?g:a.to;if(this.state&&v){var j={style:d?jE({},d,w):w};(d&&v[d]!==w||!d&&v!==w)&&this.setState(j)}this.runAnimation(tg(tg({},this.props),{},{from:w,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,d=a.duration,u=a.easing,f=a.begin,g=a.onAnimationEnd,v=a.onAnimationStart,_=Mts(l,i,xts(u),d,this.changeStyle),b=function(){o.stopJSAnimation=_()};this.manager.start([v,f,b,d,g])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,u=l[0],f=u.style,g=u.duration,v=g===void 0?0:g,_=function(w,j,N){if(N===0)return w;var S=j.duration,A=j.easing,I=A===void 0?"ease":A,L=j.style,F=j.properties,$=j.onAnimationEnd,q=N>0?l[N-1]:j,H=F||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(Gme(w),[o.runJSAnimation.bind(o,{from:q.style,to:L,duration:S,easing:I}),S]);var U=OPe(H,S,I),Q=tg(tg(tg({},q.style),L),{},{transition:U});return[].concat(Gme(w),[Q,S,$]).filter(ats)};return this.manager.start([d].concat(Gme(l.reduce(_,[f,Math.max(v,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=tts());var o=a.begin,l=a.duration,i=a.attributeName,d=a.to,u=a.easing,f=a.onAnimationStart,g=a.onAnimationEnd,v=a.steps,_=a.children,b=this.manager;if(this.unSubscribe=b.subscribe(this.handleStyleChange),typeof u=="function"||typeof _=="function"||u==="spring"){this.runJSAnimation(a);return}if(v.length>1){this.runStepAnimation(a);return}var w=i?jE({},i,d):d,j=OPe(Object.keys(w),l,u);b.start([f,o,tg(tg({},w),{},{transition:j}),l,g])}},{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 d=Ats(a,Tts),u=M.Children.count(o),f=this.state.style;if(typeof o=="function")return o(f);if(!i||u===0||l<=0)return o;var g=function(_){var b=_.props,w=b.style,j=w===void 0?{}:w,N=b.className,S=M.cloneElement(_,tg(tg({},d),{},{style:tg(tg({},j),f),className:N}));return S};return u===1?g(M.Children.only(o)):ut.createElement("div",null,M.Children.map(o,function(v){return g(v)}))}}]),r}(M.PureComponent);U0.displayName="Animate";U0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};U0.propTypes={from:Bo.oneOfType([Bo.object,Bo.string]),to:Bo.oneOfType([Bo.object,Bo.string]),attributeName:Bo.string,duration:Bo.number,begin:Bo.number,easing:Bo.oneOfType([Bo.string,Bo.func]),steps:Bo.arrayOf(Bo.shape({duration:Bo.number.isRequired,style:Bo.object.isRequired,easing:Bo.oneOfType([Bo.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Bo.func]),properties:Bo.arrayOf("string"),onAnimationEnd:Bo.func})),children:Bo.oneOfType([Bo.node,Bo.func]),isActive:Bo.bool,canBegin:Bo.bool,onAnimationEnd:Bo.func,shouldReAnimate:Bo.bool,onAnimationStart:Bo.func,onAnimationReStart:Bo.func};function w6(t){"@babel/helpers - typeof";return w6=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},w6(t)}function Wae(){return Wae=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,d=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,f;if(l>0&&o instanceof Array){for(var g=[0,0,0,0],v=0,_=4;v<_;v++)g[v]=o[v]>l?l:o[v];f="M".concat(s,",").concat(r+i*g[0]),g[0]>0&&(f+="A ".concat(g[0],",").concat(g[0],",0,0,").concat(u,",").concat(s+d*g[0],",").concat(r)),f+="L ".concat(s+n-d*g[1],",").concat(r),g[1]>0&&(f+="A ".concat(g[1],",").concat(g[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*g[1])),f+="L ".concat(s+n,",").concat(r+a-i*g[2]),g[2]>0&&(f+="A ".concat(g[2],",").concat(g[2],",0,0,").concat(u,`, `).concat(s+n-d*g[2],",").concat(r+a)),f+="L ".concat(s+d*g[3],",").concat(r+a),g[3]>0&&(f+="A ".concat(g[3],",").concat(g[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*g[3])),f+="Z"}else if(l>0&&o===+o&&o>0){var b=Math.min(l,o);f="M ".concat(s,",").concat(r+i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+d*b,",").concat(r,` L `).concat(s+n-d*b,",").concat(r,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n,",").concat(r+i*b,` L `).concat(s+n,",").concat(r+a-i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n-d*b,",").concat(r+a,` L `).concat(s+d*b,",").concat(r+a,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s,",").concat(r+a-i*b," Z")}else f="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return f},Xts=function(s,r){if(!s||!r)return!1;var n=s.x,a=s.y,o=r.x,l=r.y,i=r.width,d=r.height;if(Math.abs(i)>0&&Math.abs(d)>0){var u=Math.min(o,o+i),f=Math.max(o,o+i),g=Math.min(l,l+d),v=Math.max(l,l+d);return n>=u&&n<=f&&a>=g&&a<=v}return!1},Qts={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Pwe=function(s){var r=VPe(VPe({},Qts),s),n=M.useRef(),a=M.useState(-1),o=Uts(a,2),l=o[0],i=o[1];M.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var I=n.current.getTotalLength();I&&i(I)}catch{}},[]);var d=r.x,u=r.y,f=r.width,g=r.height,v=r.radius,_=r.className,b=r.animationEasing,w=r.animationDuration,j=r.animationBegin,N=r.isAnimationActive,S=r.isUpdateAnimationActive;if(d!==+d||u!==+u||f!==+f||g!==+g||f===0||g===0)return null;var A=Ri("recharts-rectangle",_);return S?ut.createElement(U0,{canBegin:l>0,from:{width:f,height:g,x:d,y:u},to:{width:f,height:g,x:d,y:u},duration:w,animationEasing:b,isActive:S},function(I){var L=I.width,F=I.height,$=I.x,q=I.y;return ut.createElement(U0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,isActive:N,easing:b},ut.createElement("path",Wae({},ci(r,!0),{className:A,d:HPe($,q,L,F,v),ref:n})))}):ut.createElement("path",Wae({},ci(r,!0),{className:A,d:HPe(d,u,f,g,v)}))},Jts=["points","className","baseLinePoints","connectNulls"];function E4(){return E4=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 tss(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 WPe(t){return ass(t)||nss(t)||rss(t)||sss()}function sss(){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 rss(t,s){if(t){if(typeof t=="string")return Dye(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 Dye(t,s)}}function nss(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ass(t){if(Array.isArray(t))return Dye(t)}function Dye(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){GPe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),GPe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},XP=function(s,r){var n=iss(s);r&&(n=[n.reduce(function(o,l){return[].concat(WPe(o),WPe(l))},[])]);var a=n.map(function(o){return o.reduce(function(l,i,d){return"".concat(l).concat(d===0?"M":"L").concat(i.x,",").concat(i.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},oss=function(s,r,n){var a=XP(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(XP(r.reverse(),n).slice(1))},lss=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=ess(s,Jts);if(!r||!r.length)return null;var i=Ri("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",u=oss(r,a,o);return ut.createElement("g",{className:i},ut.createElement("path",E4({},ci(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),d?ut.createElement("path",E4({},ci(l,!0),{fill:"none",d:XP(r,o)})):null,d?ut.createElement("path",E4({},ci(l,!0),{fill:"none",d:XP(a,o)})):null)}var f=XP(r,o);return ut.createElement("path",E4({},ci(l,!0),{fill:f.slice(-1)==="Z"?l.fill:"none",className:i,d:f}))};function Oye(){return Oye=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 fss(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 gss=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},xss=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,d=s.left,u=d===void 0?0:d,f=s.width,g=f===void 0?0:f,v=s.height,_=v===void 0?0:v,b=s.className,w=pss(s,css),j=dss({x:n,y:o,top:i,left:u,width:g,height:_},w);return!sn(n)||!sn(o)||!sn(g)||!sn(_)||!sn(i)||!sn(u)?null:ut.createElement("path",Rye({},ci(j,!0),{className:Ri("recharts-cross",b),d:gss(n,o,g,_,i,u)}))},yss=Hle,vss=xZe,_ss=uy;function bss(t,s){return t&&t.length?yss(t,_ss(s),vss):void 0}var wss=bss;const jss=vo(wss);var kss=Hle,Nss=uy,Sss=yZe;function Css(t,s){return t&&t.length?kss(t,Nss(s),Sss):void 0}var Mss=Css;const Tss=vo(Mss);var Ass=["cx","cy","angle","ticks","axisLine"],Ess=["ticks","tick","angle","tickFormatter","stroke"];function T3(t){"@babel/helpers - typeof";return T3=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},T3(t)}function QP(){return QP=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 Pss(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 Iss(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function XPe(t,s){for(var r=0;reIe?l=a==="outer"?"start":"end":o<-eIe?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,d=n.axisLineType,u=Ub(Ub({},ci(this.props,!1)),{},{fill:"none"},ci(i,!1));if(d==="circle")return ut.createElement(Iwe,pk({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var f=this.props.ticks,g=f.map(function(v){return Tl(a,o,l,v.coordinate)});return ut.createElement(lss,pk({className:"recharts-polar-angle-axis-line"},u,{points:g}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,d=a.tickFormatter,u=a.stroke,f=ci(this.props,!1),g=ci(l,!1),v=Ub(Ub({},f),{},{fill:"none"},ci(i,!1)),_=o.map(function(b,w){var j=n.getTickLineCoord(b),N=n.getTickTextAnchor(b),S=Ub(Ub(Ub({textAnchor:N},f),{},{stroke:"none",fill:u},g),{},{index:w,payload:b,x:j.x2,y:j.y2});return ut.createElement(Jo,pk({className:Ri("recharts-polar-angle-axis-tick",WZe(l)),key:"tick-".concat(b.coordinate)},ON(n.props,b,w)),i&&ut.createElement("line",pk({className:"recharts-polar-angle-axis-tick-line"},v,j)),l&&s.renderTickItem(l,S,d?d(b.value,w):b.value))});return ut.createElement(Jo,{className:"recharts-polar-angle-axis-ticks"},_)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:ut.createElement(Jo,{className:Ri("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return ut.isValidElement(n)?l=ut.cloneElement(n,a):gi(n)?l=n(a):l=ut.createElement(RN,pk({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(M.PureComponent);ece(tce,"displayName","PolarAngleAxis");ece(tce,"axisType","angleAxis");ece(tce,"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 Kss=mKe,Zss=Kss(Object.getPrototypeOf,Object),Yss=Zss,Xss=K0,Qss=Yss,Jss=Z0,ers="[object Object]",trs=Function.prototype,srs=Object.prototype,dYe=trs.toString,rrs=srs.hasOwnProperty,nrs=dYe.call(Object);function ars(t){if(!Jss(t)||Xss(t)!=ers)return!1;var s=Qss(t);if(s===null)return!0;var r=rrs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&dYe.call(r)==nrs}var irs=ars;const ors=vo(irs);var lrs=K0,crs=Z0,drs="[object Boolean]";function urs(t){return t===!0||t===!1||crs(t)&&lrs(t)==drs}var hrs=urs;const mrs=vo(hrs);function k6(t){"@babel/helpers - typeof";return k6=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},k6(t)}function Zae(){return Zae=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:v,x:d,y:u},to:{upperWidth:f,lowerWidth:g,height:v,x:d,y:u},duration:w,animationEasing:b,isActive:N},function(A){var I=A.upperWidth,L=A.lowerWidth,F=A.height,$=A.x,q=A.y;return ut.createElement(U0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,easing:b},ut.createElement("path",Zae({},ci(r,!0),{className:S,d:nIe($,q,I,L,F),ref:n})))}):ut.createElement("g",null,ut.createElement("path",Zae({},ci(r,!0),{className:S,d:nIe(d,u,f,g,v)})))},krs=["option","shapeType","propTransformer","activeClassName","isActive"];function N6(t){"@babel/helpers - typeof";return N6=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},N6(t)}function Nrs(t,s){if(t==null)return{};var r=Srs(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 Srs(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 aIe(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 Yae(t){for(var s=1;s0?yp(A,"paddingAngle",0):0;if(L){var $=a1(L.endAngle-L.startAngle,A.endAngle-A.startAngle),q=kl(kl({},A),{},{startAngle:S+F,endAngle:S+$(w)+F});j.push(q),S=q.endAngle}else{var H=A.endAngle,U=A.startAngle,Q=a1(0,H-U),se=Q(w),te=kl(kl({},A),{},{startAngle:S+F,endAngle:S+se+F});j.push(te),S=te.endAngle}}),ut.createElement(Jo,null,n.renderSectorsStatically(j))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!Kle(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,d=a.label,u=a.cx,f=a.cy,g=a.innerRadius,v=a.outerRadius,_=a.isAnimationActive,b=this.state.isAnimationFinished;if(o||!l||!l.length||!sn(u)||!sn(f)||!sn(g)||!sn(v))return null;var w=Ri("recharts-pie",i);return ut.createElement(Jo,{tabIndex:this.props.rootTabIndex,className:w,ref:function(N){n.pieRef=N}},this.renderSectors(),d&&this.renderLabels(l),ru.renderCallByParent(this.props,null,!1),(!_||b)&&c_.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?S:S-1)*d,I=j-S*_-A,L=a.reduce(function(q,H){var U=Gu(H,N,0);return q+(sn(U)?U:0)},0),F;if(L>0){var $;F=a.map(function(q,H){var U=Gu(q,N,0),Q=Gu(q,f,H),se=(sn(U)?U:0)/L,te;H?te=$.endAngle+Mh(w)*d*(U!==0?1:0):te=l;var Y=te+Mh(w)*((U!==0?_:0)+se*I),ce=(te+Y)/2,oe=(b.innerRadius+b.outerRadius)/2,le=[{name:Q,value:U,payload:q,dataKey:N,type:v}],de=Tl(b.cx,b.cy,oe,ce);return $=kl(kl(kl({percent:se,cornerRadius:o,name:Q,tooltipPayload:le,midAngle:ce,middleRadius:oe,tooltipPosition:de},q),b),{},{value:Gu(q,N),startAngle:te,endAngle:Y,payload:q,paddingAngle:Mh(w)*d}),$})}return kl(kl({},b),{},{sectors:F,data:a})});var Grs=Math.ceil,Krs=Math.max;function Zrs(t,s,r,n){for(var a=-1,o=Krs(Grs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var Yrs=Zrs,Xrs=PKe,cIe=1/0,Qrs=17976931348623157e292;function Jrs(t){if(!t)return t===0?t:0;if(t=Xrs(t),t===cIe||t===-cIe){var s=t<0?-1:1;return s*Qrs}return t===t?t:0}var pYe=Jrs,ens=Yrs,tns=Rle,Kme=pYe;function sns(t){return function(s,r,n){return n&&typeof n!="number"&&tns(s,r,n)&&(r=n=void 0),s=Kme(s),r===void 0?(r=s,s=0):r=Kme(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),Zm(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()}),Zm(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Zm(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Zm(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Zm(n,"handleSlideDragStart",function(a){var o=pIe(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 gns(s,t),hns(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,d=i.gap,u=i.data,f=u.length-1,g=Math.min(a,o),v=Math.max(a,o),_=s.getIndexInRange(l,g),b=s.getIndexInRange(l,v);return{startIndex:_-_%d,endIndex:b===f?f:b-b%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,d=Gu(o[n],i,n);return gi(l)?l(d,n):d}},{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,d=this.props,u=d.x,f=d.width,g=d.travellerWidth,v=d.startIndex,_=d.endIndex,b=d.onChange,w=n.pageX-o;w>0?w=Math.min(w,u+f-g-i,u+f-g-l):w<0&&(w=Math.max(w,u-l,u-i));var j=this.getIndex({startX:l+w,endX:i+w});(j.startIndex!==v||j.endIndex!==_)&&b&&b(j),this.setState({startX:l+w,endX:i+w,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=pIe(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,d=a.startX,u=this.state[l],f=this.props,g=f.x,v=f.width,_=f.travellerWidth,b=f.onChange,w=f.gap,j=f.data,N={startX:this.state.startX,endX:this.state.endX},S=n.pageX-o;S>0?S=Math.min(S,g+v-_-u):S<0&&(S=Math.max(S,g-u)),N[l]=u+S;var A=this.getIndex(N),I=A.startIndex,L=A.endIndex,F=function(){var q=j.length-1;return l==="startX"&&(i>d?I%w===0:L%w===0)||id?L%w===0:I%w===0)||i>d&&L===q};this.setState(Zm(Zm({},l,u+S),"brushMoveStartX",n.pageX),function(){b&&F()&&b(A)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,d=l.startX,u=l.endX,f=this.state[a],g=i.indexOf(f);if(g!==-1){var v=g+n;if(!(v===-1||v>=i.length)){var _=i[v];a==="startX"&&_>=u||a==="endX"&&_<=d||this.setState(Zm({},a,_),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,d=n.fill,u=n.stroke;return ut.createElement("rect",{stroke:u,fill:d,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,d=n.data,u=n.children,f=n.padding,g=M.Children.only(u);return g?ut.cloneElement(g,{x:a,y:o,width:l,height:i,margin:f,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,d=this.props,u=d.y,f=d.travellerWidth,g=d.height,v=d.traveller,_=d.ariaLabel,b=d.data,w=d.startIndex,j=d.endIndex,N=Math.max(n,this.props.x),S=Zme(Zme({},ci(this.props,!1)),{},{x:N,y:u,width:f,height:g}),A=_||"Min value: ".concat((o=b[w])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=b[j])===null||l===void 0?void 0:l.name);return ut.createElement(Jo,{tabIndex:0,role:"slider","aria-label":A,"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(v,S))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,d=o.stroke,u=o.travellerWidth,f=Math.min(n,a)+u,g=Math.max(Math.abs(a-n)-u,0);return ut.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:d,fillOpacity:.2,x:f,y:l,width:g,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,d=n.travellerWidth,u=n.stroke,f=this.state,g=f.startX,v=f.endX,_=5,b={pointerEvents:"none",fill:u};return ut.createElement(Jo,{className:"recharts-brush-texts"},ut.createElement(RN,Jae({textAnchor:"end",verticalAnchor:"middle",x:Math.min(g,v)-_,y:l+i/2},b),this.getTextOfTick(a)),ut.createElement(RN,Jae({textAnchor:"start",verticalAnchor:"middle",x:Math.max(g,v)+d+_,y:l+i/2},b),this.getTextOfTick(o)))}},{key:"render",value:function(){var n=this.props,a=n.data,o=n.className,l=n.children,i=n.x,d=n.y,u=n.width,f=n.height,g=n.alwaysShowText,v=this.state,_=v.startX,b=v.endX,w=v.isTextActive,j=v.isSlideMoving,N=v.isTravellerMoving,S=v.isTravellerFocused;if(!a||!a.length||!sn(i)||!sn(d)||!sn(u)||!sn(f)||u<=0||f<=0)return null;var A=Ri("recharts-brush",o),I=ut.Children.count(l)===1,L=dns("userSelect","none");return ut.createElement(Jo,{className:A,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:L},this.renderBackground(),I&&this.renderPanorama(),this.renderSlide(_,b),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(b,"endX"),(w||j||N||S||g)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,d=n.stroke,u=Math.floor(o+i/2)-1;return ut.createElement(ut.Fragment,null,ut.createElement("rect",{x:a,y:o,width:l,height:i,fill:d,stroke:"none"}),ut.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),ut.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 ut.isValidElement(n)?o=ut.cloneElement(n,a):gi(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,d=n.travellerWidth,u=n.updateId,f=n.startIndex,g=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return Zme({prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?yns({data:o,width:l,x:i,travellerWidth:d,startIndex:f,endIndex:g}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||d!==a.prevTravellerWidth)){a.scale.range([i,i+l-d]);var v=a.scale.domain().map(function(_){return a.scale(_)});return{prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:v}}return null}},{key:"getIndexInRange",value:function(n,a){for(var o=n.length,l=0,i=o-1;i-l>1;){var d=Math.floor((l+i)/2);n[d]>a?i=d:l=d}return a>=n[i]?i:l}}])}(M.PureComponent);Zm(I3,"displayName","Brush");Zm(I3,"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 vns=nwe;function _ns(t,s){var r;return vns(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var bns=_ns,wns=aKe,jns=uy,kns=bns,Nns=Dm,Sns=Rle;function Cns(t,s,r){var n=Nns(t)?wns:kns;return r&&Sns(t,s,r)&&(s=void 0),n(t,jns(s))}var Mns=Cns;const Tns=vo(Mns);var Zx=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},fIe=CKe;function Ans(t,s,r){s=="__proto__"&&fIe?fIe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Ens=Ans,Pns=Ens,Ins=NKe,Lns=uy;function Dns(t,s){var r={};return s=Lns(s),Ins(t,function(n,a,o){Pns(r,a,s(n,a,o))}),r}var Ons=Dns;const Rns=vo(Ons);function Fns(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 tas(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 sas(t,s){var r=t.x,n=t.y,a=eas(t,Yns),o="".concat(r),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),u="".concat(s.height||a.height),f=parseInt(u,10),g="".concat(s.width||a.width),v=parseInt(g,10);return nE(nE(nE(nE(nE({},s),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:f,width:v,name:s.name,radius:s.radius})}function xIe(t){return ut.createElement(uYe,qye({shapeType:"rectangle",propTransformer:sas,activeClassName:"recharts-active-bar"},t))}var ras=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=sn(n)||Tzt(n);return o?s(n,a):(o||zN(),r)}},nas=["value","background"],vYe;function L3(t){"@babel/helpers - typeof";return L3=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},L3(t)}function aas(t,s){if(t==null)return{};var r=ias(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 ias(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 tie(){return tie=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ce)0&&Math.abs(Y)0&&(te=Math.min((Ge||0)-(Y[Ne-1]||0),te))}),Number.isFinite(te)){var ce=te/se,oe=w.layout==="vertical"?n.height:n.width;if(w.padding==="gap"&&($=ce*oe/2),w.padding==="no-gap"){var le=Th(s.barCategoryGap,ce*oe),de=ce*oe/2;$=de-le-(de-le)/oe*le}}}a==="xAxis"?q=[n.left+(A.left||0)+($||0),n.left+n.width-(A.right||0)-($||0)]:a==="yAxis"?q=d==="horizontal"?[n.top+n.height-(A.bottom||0),n.top+(A.top||0)]:[n.top+(A.top||0)+($||0),n.top+n.height-(A.bottom||0)-($||0)]:q=w.range,L&&(q=[q[1],q[0]]);var xe=zZe(w,o,v),be=xe.scale,ye=xe.realScaleType;be.domain(N).range(q),BZe(be);var ve=$Ze(be,fg(fg({},w),{},{realScaleType:ye}));a==="xAxis"?(Q=j==="top"&&!I||j==="bottom"&&I,H=n.left,U=g[F]-Q*w.height):a==="yAxis"&&(Q=j==="left"&&!I||j==="right"&&I,H=g[F]-Q*w.width,U=n.top);var ke=fg(fg(fg({},w),ve),{},{realScaleType:ye,x:H,y:U,scale:be,width:a==="xAxis"?n.width:w.width,height:a==="yAxis"?n.height:w.height});return ke.bandSize=Bae(ke,ve),!w.hide&&a==="xAxis"?g[F]+=(Q?-1:1)*ke.height:w.hide||(g[F]+=(Q?-1:1)*ke.width),fg(fg({},_),{},nce({},b,ke))},{})},jYe=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)}},yas=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return jYe({x:r,y:n},{x:a,y:o})},kYe=function(){function t(s){pas(this,t),this.scale=s}return fas(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 d=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+d}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)}}])}();nce(kYe,"EPS",1e-4);var Lwe=function(s){var r=Object.keys(s).reduce(function(n,a){return fg(fg({},n),{},nce({},a,kYe.create(s[a])))},{});return fg(fg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Rns(a,function(d,u){return r[u].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return yYe(a,function(o,l){return r[l].isInRange(o)})}})};function vas(t){return(t%180+180)%180}var _as=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=vas(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var Nas=kas,Sas=pYe;function Cas(t){var s=Sas(t),r=s%1;return s===s?r?s-r:s:0}var Mas=Cas,Tas=vKe,Aas=uy,Eas=Mas,Pas=Math.max;function Ias(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Eas(r);return a<0&&(a=Pas(n+a,0)),Tas(t,Aas(s),a)}var Las=Ias,Das=Nas,Oas=Las,Ras=Das(Oas),Fas=Ras;const zas=vo(Fas);var Bas=DFt(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("")}),Dwe=M.createContext(void 0),Owe=M.createContext(void 0),NYe=M.createContext(void 0),SYe=M.createContext({}),CYe=M.createContext(void 0),MYe=M.createContext(0),TYe=M.createContext(0),wIe=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,o=r.offset,l=s.clipPathId,i=s.children,d=s.width,u=s.height,f=Bas(o);return ut.createElement(Dwe.Provider,{value:n},ut.createElement(Owe.Provider,{value:a},ut.createElement(SYe.Provider,{value:o},ut.createElement(NYe.Provider,{value:f},ut.createElement(CYe.Provider,{value:l},ut.createElement(MYe.Provider,{value:u},ut.createElement(TYe.Provider,{value:d},i)))))))},$as=function(){return M.useContext(CYe)},AYe=function(s){var r=M.useContext(Dwe);r==null&&zN();var n=r[s];return n==null&&zN(),n},qas=function(){var s=M.useContext(Dwe);return m1(s)},Uas=function(){var s=M.useContext(Owe),r=zas(s,function(n){return yYe(n.domain,Number.isFinite)});return r||m1(s)},EYe=function(s){var r=M.useContext(Owe);r==null&&zN();var n=r[s];return n==null&&zN(),n},Vas=function(){var s=M.useContext(NYe);return s},Has=function(){return M.useContext(SYe)},Rwe=function(){return M.useContext(TYe)},Fwe=function(){return M.useContext(MYe)};function D3(t){"@babel/helpers - typeof";return D3=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},D3(t)}function Was(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Gas(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 Mis(t,s){return FYe(t,s+1)}function Tis(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,d=0,u=1,f=l,g=function(){var b=n==null?void 0:n[d];if(b===void 0)return{v:FYe(n,u)};var w=d,j,N=function(){return j===void 0&&(j=r(b,w)),j},S=b.coordinate,A=d===0||iie(t,S,N,f,i);A||(d=0,f=l,u+=1),A&&(f=S+t*(N()/2+a),d+=u)},v;u<=o.length;)if(v=g(),v)return v.v;return[]}function A6(t){"@babel/helpers - typeof";return A6=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},A6(t)}function AIe(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 Vu(t){for(var s=1;s0?_.coordinate-j*t:_.coordinate})}else o[v]=_=Vu(Vu({},_),{},{tickCoord:_.coordinate});var N=iie(t,_.tickCoord,w,i,d);N&&(d=_.tickCoord-t*(w()/2+a),o[v]=Vu(Vu({},_),{},{isShow:!0}))},f=l-1;f>=0;f--)u(f);return o}function Lis(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,d=s.start,u=s.end;if(o){var f=n[i-1],g=r(f,i-1),v=t*(f.coordinate+t*g/2-u);l[i-1]=f=Vu(Vu({},f),{},{tickCoord:v>0?f.coordinate-v*t:f.coordinate});var _=iie(t,f.tickCoord,function(){return g},d,u);_&&(u=f.tickCoord-t*(g/2+a),l[i-1]=Vu(Vu({},f),{},{isShow:!0}))}for(var b=o?i-1:i,w=function(S){var A=l[S],I,L=function(){return I===void 0&&(I=r(A,S)),I};if(S===0){var F=t*(A.coordinate-t*L()/2-d);l[S]=A=Vu(Vu({},A),{},{tickCoord:F<0?A.coordinate-F*t:A.coordinate})}else l[S]=A=Vu(Vu({},A),{},{tickCoord:A.coordinate});var $=iie(t,A.tickCoord,L,d,u);$&&(d=A.tickCoord+t*(L()/2+a),l[S]=Vu(Vu({},A),{},{isShow:!0}))},j=0;j=2?Mh(a[1].coordinate-a[0].coordinate):1,N=Cis(o,j,_);return d==="equidistantPreserveStart"?Tis(j,N,w,a,l):(d==="preserveStart"||d==="preserveStartEnd"?v=Lis(j,N,w,a,l,d==="preserveStartEnd"):v=Iis(j,N,w,a,l),v.filter(function(S){return S.isShow}))}var Dis=["viewBox"],Ois=["viewBox"],Ris=["ticks"];function F3(t){"@babel/helpers - typeof";return F3=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},F3(t)}function I4(){return I4=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 Fis(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 zis(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function PIe(t,s){for(var r=0;r0?d(this.props):d(_)),l<=0||i<=0||!b||!b.length?null:ut.createElement(Jo,{className:Ri("recharts-cartesian-axis",u),ref:function(j){n.layerReference=j}},o&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),ru.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Ri(a.className,"recharts-cartesian-axis-tick-value");return ut.isValidElement(n)?l=ut.cloneElement(n,Sd(Sd({},a),{},{className:i})):gi(n)?l=n(Sd(Sd({},a),{},{className:i})):l=ut.createElement(RN,I4({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(M.Component);qwe(AM,"displayName","CartesianAxis");qwe(AM,"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 Wis=["x1","y1","x2","y2","key"],Gis=["offset"];function BN(t){"@babel/helpers - typeof";return BN=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},BN(t)}function IIe(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 Wu(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Xis(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 Qis=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,d=s.ry;return ut.createElement("rect",{x:a,y:o,ry:d,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function $Ye(t,s){var r;if(ut.isValidElement(t))r=ut.cloneElement(t,s);else if(gi(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,d=LIe(s,Wis),u=ci(d,!1);u.offset;var f=LIe(u,Gis);r=ut.createElement("line",Mk({},f,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function Jis(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,d){var u=Wu(Wu({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(d),index:d});return $Ye(a,u)});return ut.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function eos(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,d){var u=Wu(Wu({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(d),index:d});return $Ye(a,u)});return ut.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function tos(t){var s=t.horizontalFill,r=t.fillOpacity,n=t.x,a=t.y,o=t.width,l=t.height,i=t.horizontalPoints,d=t.horizontal,u=d===void 0?!0:d;if(!u||!s||!s.length)return null;var f=i.map(function(v){return Math.round(v+a-a)}).sort(function(v,_){return v-_});a!==f[0]&&f.unshift(0);var g=f.map(function(v,_){var b=!f[_+1],w=b?a+l-v:f[_+1]-v;if(w<=0)return null;var j=_%s.length;return ut.createElement("rect",{key:"react-".concat(_),y:v,x:n,height:w,width:o,stroke:"none",fill:s[j],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ut.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},g)}function sos(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,d=t.height,u=t.verticalPoints;if(!r||!n||!n.length)return null;var f=u.map(function(v){return Math.round(v+o-o)}).sort(function(v,_){return v-_});o!==f[0]&&f.unshift(0);var g=f.map(function(v,_){var b=!f[_+1],w=b?o+i-v:f[_+1]-v;if(w<=0)return null;var j=_%n.length;return ut.createElement("rect",{key:"react-".concat(_),x:v,y:l,width:w,height:d,stroke:"none",fill:n[j],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ut.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},g)}var ros=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return FZe($we(Wu(Wu(Wu({},AM.defaultProps),n),{},{ticks:h0(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},nos=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return FZe($we(Wu(Wu(Wu({},AM.defaultProps),n),{},{ticks:h0(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},r4={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function qYe(t){var s,r,n,a,o,l,i=Rwe(),d=Fwe(),u=Has(),f=Wu(Wu({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:r4.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:r4.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:r4.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:r4.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:r4.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:r4.verticalFill,x:sn(t.x)?t.x:u.left,y:sn(t.y)?t.y:u.top,width:sn(t.width)?t.width:u.width,height:sn(t.height)?t.height:u.height}),g=f.x,v=f.y,_=f.width,b=f.height,w=f.syncWithTicks,j=f.horizontalValues,N=f.verticalValues,S=qas(),A=Uas();if(!sn(_)||_<=0||!sn(b)||b<=0||!sn(g)||g!==+g||!sn(v)||v!==+v)return null;var I=f.verticalCoordinatesGenerator||ros,L=f.horizontalCoordinatesGenerator||nos,F=f.horizontalPoints,$=f.verticalPoints;if((!F||!F.length)&&gi(L)){var q=j&&j.length,H=L({yAxis:A?Wu(Wu({},A),{},{ticks:q?j:A.ticks}):void 0,width:i,height:d,offset:u},q?!0:w);Lg(Array.isArray(H),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(BN(H),"]")),Array.isArray(H)&&(F=H)}if((!$||!$.length)&&gi(I)){var U=N&&N.length,Q=I({xAxis:S?Wu(Wu({},S),{},{ticks:U?N:S.ticks}):void 0,width:i,height:d,offset:u},U?!0:w);Lg(Array.isArray(Q),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(BN(Q),"]")),Array.isArray(Q)&&($=Q)}return ut.createElement("g",{className:"recharts-cartesian-grid"},ut.createElement(Qis,{fill:f.fill,fillOpacity:f.fillOpacity,x:f.x,y:f.y,width:f.width,height:f.height,ry:f.ry}),ut.createElement(Jis,Mk({},f,{offset:u,horizontalPoints:F,xAxis:S,yAxis:A})),ut.createElement(eos,Mk({},f,{offset:u,verticalPoints:$,xAxis:S,yAxis:A})),ut.createElement(tos,Mk({},f,{horizontalPoints:F})),ut.createElement(sos,Mk({},f,{verticalPoints:$})))}qYe.displayName="CartesianGrid";function z3(t){"@babel/helpers - typeof";return z3=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},z3(t)}function aos(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function ios(t,s){for(var r=0;rt.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 Wos(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 Gos(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Kos(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&sn(a)&&sn(o)?s.slice(a,o+1):[]};function sXe(t){return t==="number"?[0,"auto"]:void 0}var a0e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=uce(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,u){var f,g=(f=u.props.data)!==null&&f!==void 0?f:r;g&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(g=g.slice(s.dataStartIndex,s.dataEndIndex+1));var v;if(l.dataKey&&!l.allowDuplicatedCategory){var _=g===void 0?i:g;v=Pxe(_,l.dataKey,a)}else v=g&&g[n]||i[n];return v?[].concat(q3(d),[UZe(u,v)]):d},[])},BIe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=ils(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,u=s.tooltipTicks,f=$Qt(l,i,u,d);if(f>=0&&u){var g=u[f]&&u[f].value,v=a0e(s,r,f,g),_=ols(n,i,f,o);return{activeTooltipIndex:f,activeLabel:g,activePayload:v,activeCoordinate:_}}return null},lls=function(s,r){var n=r.axes,a=r.graphicalItems,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,f=s.layout,g=s.children,v=s.stackOffset,_=RZe(f,o);return n.reduce(function(b,w){var j,N=w.type.defaultProps!==void 0?fr(fr({},w.type.defaultProps),w.props):w.props,S=N.type,A=N.dataKey,I=N.allowDataOverflow,L=N.allowDuplicatedCategory,F=N.scale,$=N.ticks,q=N.includeHidden,H=N[l];if(b[H])return b;var U=uce(s.data,{graphicalItems:a.filter(function(ve){var ke,Ge=l in ve.props?ve.props[l]:(ke=ve.type.defaultProps)===null||ke===void 0?void 0:ke[l];return Ge===H}),dataStartIndex:d,dataEndIndex:u}),Q=U.length,se,te,Y;Los(N.domain,I,S)&&(se=_ye(N.domain,null,I),_&&(S==="number"||F!=="auto")&&(Y=ZP(U,A,"category")));var ce=sXe(S);if(!se||se.length===0){var oe,le=(oe=N.domain)!==null&&oe!==void 0?oe:ce;if(A){if(se=ZP(U,A,S),S==="category"&&_){var de=Ezt(se);L&&de?(te=se,se=Qae(0,Q)):L||(se=uPe(le,se,w).reduce(function(ve,ke){return ve.indexOf(ke)>=0?ve:[].concat(q3(ve),[ke])},[]))}else if(S==="category")L?se=se.filter(function(ve){return ve!==""&&!Gi(ve)}):se=uPe(le,se,w).reduce(function(ve,ke){return ve.indexOf(ke)>=0||ke===""||Gi(ke)?ve:[].concat(q3(ve),[ke])},[]);else if(S==="number"){var xe=WQt(U,a.filter(function(ve){var ke,Ge,Ne=l in ve.props?ve.props[l]:(ke=ve.type.defaultProps)===null||ke===void 0?void 0:ke[l],Ae="hide"in ve.props?ve.props.hide:(Ge=ve.type.defaultProps)===null||Ge===void 0?void 0:Ge.hide;return Ne===H&&(q||!Ae)}),A,o,f);xe&&(se=xe)}_&&(S==="number"||F!=="auto")&&(Y=ZP(U,A,"category"))}else _?se=Qae(0,Q):i&&i[H]&&i[H].hasStack&&S==="number"?se=v==="expand"?[0,1]:qZe(i[H].stackGroups,d,u):se=OZe(U,a.filter(function(ve){var ke=l in ve.props?ve.props[l]:ve.type.defaultProps[l],Ge="hide"in ve.props?ve.props.hide:ve.type.defaultProps.hide;return ke===H&&(q||!Ge)}),S,f,!0);if(S==="number")se=s0e(g,se,H,o,$),le&&(se=_ye(le,se,I));else if(S==="category"&&le){var be=le,ye=se.every(function(ve){return be.indexOf(ve)>=0});ye&&(se=be)}}return fr(fr({},b),{},Ja({},H,fr(fr({},N),{},{axisType:o,domain:se,categoricalDomain:Y,duplicateDomain:te,originalDomain:(j=N.domain)!==null&&j!==void 0?j:ce,isCategorical:_,layout:f})))},{})},cls=function(s,r){var n=r.graphicalItems,a=r.Axis,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,f=s.layout,g=s.children,v=uce(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),_=v.length,b=RZe(f,o),w=-1;return n.reduce(function(j,N){var S=N.type.defaultProps!==void 0?fr(fr({},N.type.defaultProps),N.props):N.props,A=S[l],I=sXe("number");if(!j[A]){w++;var L;return b?L=Qae(0,_):i&&i[A]&&i[A].hasStack?(L=qZe(i[A].stackGroups,d,u),L=s0e(g,L,A,o)):(L=_ye(I,OZe(v,n.filter(function(F){var $,q,H=l in F.props?F.props[l]:($=F.type.defaultProps)===null||$===void 0?void 0:$[l],U="hide"in F.props?F.props.hide:(q=F.type.defaultProps)===null||q===void 0?void 0:q.hide;return H===A&&!U}),"number",f),a.defaultProps.allowDataOverflow),L=s0e(g,L,A,o)),fr(fr({},j),{},Ja({},A,fr(fr({axisType:o},a.defaultProps),{},{hide:!0,orientation:yp(nls,"".concat(o,".").concat(w%2),null),domain:L,originalDomain:I,isCategorical:b,layout:f})))}return j},{})},dls=function(s,r){var n=r.axisType,a=n===void 0?"xAxis":n,o=r.AxisComp,l=r.graphicalItems,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,f=s.children,g="".concat(a,"Id"),v=hf(f,o),_={};return v&&v.length?_=lls(s,{axes:v,graphicalItems:l,axisType:a,axisIdKey:g,stackGroups:i,dataStartIndex:d,dataEndIndex:u}):l&&l.length&&(_=cls(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:g,stackGroups:i,dataStartIndex:d,dataEndIndex:u})),_},uls=function(s){var r=m1(s),n=h0(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:awe(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Bae(r,n)}},$Ie=function(s){var r=s.children,n=s.defaultShowTooltip,a=Qm(r,I3),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}},hls=function(s){return!s||!s.length?!1:s.some(function(r){var n=T0(r&&r.type);return n&&n.indexOf("Bar")>=0})},qIe=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"}},mls=function(s,r){var n=s.props,a=s.graphicalItems,o=s.xAxisMap,l=o===void 0?{}:o,i=s.yAxisMap,d=i===void 0?{}:i,u=n.width,f=n.height,g=n.children,v=n.margin||{},_=Qm(g,I3),b=Qm(g,T5),w=Object.keys(d).reduce(function(L,F){var $=d[F],q=$.orientation;return!$.mirror&&!$.hide?fr(fr({},L),{},Ja({},q,L[q]+$.width)):L},{left:v.left||0,right:v.right||0}),j=Object.keys(l).reduce(function(L,F){var $=l[F],q=$.orientation;return!$.mirror&&!$.hide?fr(fr({},L),{},Ja({},q,yp(L,"".concat(q))+$.height)):L},{top:v.top||0,bottom:v.bottom||0}),N=fr(fr({},j),w),S=N.bottom;_&&(N.bottom+=_.props.height||I3.defaultProps.height),b&&r&&(N=VQt(N,a,n,r));var A=u-N.left-N.right,I=f-N.top-N.bottom;return fr(fr({brushBottom:S},N),{},{width:Math.max(A,0),height:Math.max(I,0)})},pls=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},rXe=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,d=s.axisComponents,u=s.legendContent,f=s.formatAxisMap,g=s.defaultProps,v=function(N,S){var A=S.graphicalItems,I=S.stackGroups,L=S.offset,F=S.updateId,$=S.dataStartIndex,q=S.dataEndIndex,H=N.barSize,U=N.layout,Q=N.barGap,se=N.barCategoryGap,te=N.maxBarSize,Y=qIe(U),ce=Y.numericAxisName,oe=Y.cateAxisName,le=hls(A),de=[];return A.forEach(function(xe,be){var ye=uce(N.data,{graphicalItems:[xe],dataStartIndex:$,dataEndIndex:q}),ve=xe.type.defaultProps!==void 0?fr(fr({},xe.type.defaultProps),xe.props):xe.props,ke=ve.dataKey,Ge=ve.maxBarSize,Ne=ve["".concat(ce,"Id")],Ae=ve["".concat(oe,"Id")],Pe={},Fe=d.reduce(function(ct,We){var Ze=S["".concat(We.axisType,"Map")],ht=ve["".concat(We.axisType,"Id")];Ze&&Ze[ht]||We.axisType==="zAxis"||zN();var Ke=Ze[ht];return fr(fr({},ct),{},Ja(Ja({},We.axisType,Ke),"".concat(We.axisType,"Ticks"),h0(Ke)))},Pe),Ie=Fe[oe],Ve=Fe["".concat(oe,"Ticks")],dt=I&&I[Ne]&&I[Ne].hasStack&&tJt(xe,I[Ne].stackGroups),Le=T0(xe.type).indexOf("Bar")>=0,Rt=Bae(Ie,Ve),fe=[],Qe=le&&qQt({barSize:H,stackGroups:I,totalSize:pls(Fe,oe)});if(Le){var at,rt,je=Gi(Ge)?te:Ge,mt=(at=(rt=Bae(Ie,Ve,!0))!==null&&rt!==void 0?rt:je)!==null&&at!==void 0?at:0;fe=UQt({barGap:Q,barCategoryGap:se,bandSize:mt!==Rt?mt:Rt,sizeList:Qe[Ae],maxBarSize:je}),mt!==Rt&&(fe=fe.map(function(ct){return fr(fr({},ct),{},{position:fr(fr({},ct.position),{},{offset:ct.position.offset-mt/2})})}))}var He=xe&&xe.type&&xe.type.getComposedData;He&&de.push({props:fr(fr({},He(fr(fr({},Fe),{},{displayedData:ye,props:N,dataKey:ke,item:xe,bandSize:Rt,barPosition:fe,offset:L,stackedData:dt,layout:U,dataStartIndex:$,dataEndIndex:q}))),{},Ja(Ja(Ja({key:xe.key||"item-".concat(be)},ce,Fe[ce]),oe,Fe[oe]),"animationId",F)),childIndex:Uzt(xe,N.children),item:xe})}),de},_=function(N,S){var A=N.props,I=N.dataStartIndex,L=N.dataEndIndex,F=N.updateId;if(!aAe({props:A}))return null;var $=A.children,q=A.layout,H=A.stackOffset,U=A.data,Q=A.reverseStackOrder,se=qIe(q),te=se.numericAxisName,Y=se.cateAxisName,ce=hf($,n),oe=JQt(U,ce,"".concat(te,"Id"),"".concat(Y,"Id"),H,Q),le=d.reduce(function(ve,ke){var Ge="".concat(ke.axisType,"Map");return fr(fr({},ve),{},Ja({},Ge,dls(A,fr(fr({},ke),{},{graphicalItems:ce,stackGroups:ke.axisType===te&&oe,dataStartIndex:I,dataEndIndex:L}))))},{}),de=mls(fr(fr({},le),{},{props:A,graphicalItems:ce}),S==null?void 0:S.legendBBox);Object.keys(le).forEach(function(ve){le[ve]=f(A,le[ve],de,ve.replace("Map",""),r)});var xe=le["".concat(Y,"Map")],be=uls(xe),ye=v(A,fr(fr({},le),{},{dataStartIndex:I,dataEndIndex:L,updateId:F,graphicalItems:ce,stackGroups:oe,offset:de}));return fr(fr({formattedGraphicalItems:ye,graphicalItems:ce,offset:de,stackGroups:oe},be),le)},b=function(j){function N(S){var A,I,L;return Gos(this,N),L=Yos(this,N,[S]),Ja(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Ja(L,"accessibilityManager",new Ios),Ja(L,"handleLegendBBoxUpdate",function(F){if(F){var $=L.state,q=$.dataStartIndex,H=$.dataEndIndex,U=$.updateId;L.setState(fr({legendBBox:F},_({props:L.props,dataStartIndex:q,dataEndIndex:H,updateId:U},fr(fr({},L.state),{},{legendBBox:F}))))}}),Ja(L,"handleReceiveSyncEvent",function(F,$,q){if(L.props.syncId===F){if(q===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent($)}}),Ja(L,"handleBrushChange",function(F){var $=F.startIndex,q=F.endIndex;if($!==L.state.dataStartIndex||q!==L.state.dataEndIndex){var H=L.state.updateId;L.setState(function(){return fr({dataStartIndex:$,dataEndIndex:q},_({props:L.props,dataStartIndex:$,dataEndIndex:q,updateId:H},L.state))}),L.triggerSyncEvent({dataStartIndex:$,dataEndIndex:q})}}),Ja(L,"handleMouseEnter",function(F){var $=L.getMouseInfo(F);if($){var q=fr(fr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var H=L.props.onMouseEnter;gi(H)&&H(q,F)}}),Ja(L,"triggeredAfterMouseMove",function(F){var $=L.getMouseInfo(F),q=$?fr(fr({},$),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(q),L.triggerSyncEvent(q);var H=L.props.onMouseMove;gi(H)&&H(q,F)}),Ja(L,"handleItemMouseEnter",function(F){L.setState(function(){return{isTooltipActive:!0,activeItem:F,activePayload:F.tooltipPayload,activeCoordinate:F.tooltipPosition||{x:F.cx,y:F.cy}}})}),Ja(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),Ja(L,"handleMouseMove",function(F){F.persist(),L.throttleTriggeredAfterMouseMove(F)}),Ja(L,"handleMouseLeave",function(F){L.throttleTriggeredAfterMouseMove.cancel();var $={isTooltipActive:!1};L.setState($),L.triggerSyncEvent($);var q=L.props.onMouseLeave;gi(q)&&q($,F)}),Ja(L,"handleOuterEvent",function(F){var $=qzt(F),q=yp(L.props,"".concat($));if($&&gi(q)){var H,U;/.*touch.*/i.test($)?U=L.getMouseInfo(F.changedTouches[0]):U=L.getMouseInfo(F),q((H=U)!==null&&H!==void 0?H:{},F)}}),Ja(L,"handleClick",function(F){var $=L.getMouseInfo(F);if($){var q=fr(fr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var H=L.props.onClick;gi(H)&&H(q,F)}}),Ja(L,"handleMouseDown",function(F){var $=L.props.onMouseDown;if(gi($)){var q=L.getMouseInfo(F);$(q,F)}}),Ja(L,"handleMouseUp",function(F){var $=L.props.onMouseUp;if(gi($)){var q=L.getMouseInfo(F);$(q,F)}}),Ja(L,"handleTouchMove",function(F){F.changedTouches!=null&&F.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(F.changedTouches[0])}),Ja(L,"handleTouchStart",function(F){F.changedTouches!=null&&F.changedTouches.length>0&&L.handleMouseDown(F.changedTouches[0])}),Ja(L,"handleTouchEnd",function(F){F.changedTouches!=null&&F.changedTouches.length>0&&L.handleMouseUp(F.changedTouches[0])}),Ja(L,"handleDoubleClick",function(F){var $=L.props.onDoubleClick;if(gi($)){var q=L.getMouseInfo(F);$(q,F)}}),Ja(L,"handleContextMenu",function(F){var $=L.props.onContextMenu;if(gi($)){var q=L.getMouseInfo(F);$(q,F)}}),Ja(L,"triggerSyncEvent",function(F){L.props.syncId!==void 0&&Xme.emit(Qme,L.props.syncId,F,L.eventEmitterSymbol)}),Ja(L,"applySyncEvent",function(F){var $=L.props,q=$.layout,H=$.syncMethod,U=L.state.updateId,Q=F.dataStartIndex,se=F.dataEndIndex;if(F.dataStartIndex!==void 0||F.dataEndIndex!==void 0)L.setState(fr({dataStartIndex:Q,dataEndIndex:se},_({props:L.props,dataStartIndex:Q,dataEndIndex:se,updateId:U},L.state)));else if(F.activeTooltipIndex!==void 0){var te=F.chartX,Y=F.chartY,ce=F.activeTooltipIndex,oe=L.state,le=oe.offset,de=oe.tooltipTicks;if(!le)return;if(typeof H=="function")ce=H(de,F);else if(H==="value"){ce=-1;for(var xe=0;xe=0){var dt,Le;if(te.dataKey&&!te.allowDuplicatedCategory){var Rt=typeof te.dataKey=="function"?Ve:"payload.".concat(te.dataKey.toString());dt=Pxe(xe,Rt,ce),Le=be&&ye&&Pxe(ye,Rt,ce)}else dt=xe==null?void 0:xe[Y],Le=be&&ye&&ye[Y];if(Ae||Ne){var fe=F.props.activeIndex!==void 0?F.props.activeIndex:Y;return[M.cloneElement(F,fr(fr(fr({},H.props),Fe),{},{activeIndex:fe})),null,null]}if(!Gi(dt))return[Ie].concat(q3(L.renderActivePoints({item:H,activePoint:dt,basePoint:Le,childIndex:Y,isRange:be})))}else{var Qe,at=(Qe=L.getItemByXY(L.state.activeCoordinate))!==null&&Qe!==void 0?Qe:{graphicalItem:Ie},rt=at.graphicalItem,je=rt.item,mt=je===void 0?F:je,He=rt.childIndex,ct=fr(fr(fr({},H.props),Fe),{},{activeIndex:He});return[M.cloneElement(mt,ct),null,null]}return be?[Ie,null,null]:[Ie,null]}),Ja(L,"renderCustomized",function(F,$,q){return M.cloneElement(F,fr(fr({key:"recharts-customized-".concat(q)},L.props),L.state))}),Ja(L,"renderMap",{CartesianGrid:{handler:iR,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:iR},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:iR},YAxis:{handler:iR},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((A=S.id)!==null&&A!==void 0?A:OL("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=IKe(L.triggeredAfterMouseMove,(I=S.throttleDelay)!==null&&I!==void 0?I:1e3/60),L.state={},L}return Jos(N,j),Zos(N,[{key:"componentDidMount",value:function(){var A,I;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A: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 A=this.props,I=A.children,L=A.data,F=A.height,$=A.layout,q=Qm(I,pg);if(q){var H=q.props.defaultIndex;if(!(typeof H!="number"||H<0||H>this.state.tooltipTicks.length-1)){var U=this.state.tooltipTicks[H]&&this.state.tooltipTicks[H].value,Q=a0e(this.state,L,H,U),se=this.state.tooltipTicks[H].coordinate,te=(this.state.offset.top+F)/2,Y=$==="horizontal",ce=Y?{x:se,y:te}:{y:se,x:te},oe=this.state.formattedGraphicalItems.find(function(de){var xe=de.item;return xe.type.name==="Scatter"});oe&&(ce=fr(fr({},ce),oe.props.points[H].tooltipPosition),Q=oe.props.points[H].tooltipPayload);var le={activeTooltipIndex:H,isTooltipActive:!0,activeLabel:U,activePayload:Q,activeCoordinate:ce};this.setState(le),this.renderCursor(q),this.accessibilityManager.setIndex(H)}}}},{key:"getSnapshotBeforeUpdate",value:function(A,I){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==I.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==A.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==A.margin){var L,F;this.accessibilityManager.setDetails({offset:{left:(L=this.props.margin.left)!==null&&L!==void 0?L:0,top:(F=this.props.margin.top)!==null&&F!==void 0?F:0}})}return null}},{key:"componentDidUpdate",value:function(A){Lxe([Qm(A.children,pg)],[Qm(this.props.children,pg)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var A=Qm(this.props.children,pg);if(A&&typeof A.props.shared=="boolean"){var I=A.props.shared?"axis":"item";return i.indexOf(I)>=0?I:o}return o}},{key:"getMouseInfo",value:function(A){if(!this.container)return null;var I=this.container,L=I.getBoundingClientRect(),F=fKt(L),$={chartX:Math.round(A.pageX-F.left),chartY:Math.round(A.pageY-F.top)},q=L.width/I.offsetWidth||1,H=this.inRange($.chartX,$.chartY,q);if(!H)return null;var U=this.state,Q=U.xAxisMap,se=U.yAxisMap,te=this.getTooltipEventType(),Y=BIe(this.state,this.props.data,this.props.layout,H);if(te!=="axis"&&Q&&se){var ce=m1(Q).scale,oe=m1(se).scale,le=ce&&ce.invert?ce.invert($.chartX):null,de=oe&&oe.invert?oe.invert($.chartY):null;return fr(fr({},$),{},{xValue:le,yValue:de},Y)}return Y?fr(fr({},$),Y):null}},{key:"inRange",value:function(A,I){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,F=this.props.layout,$=A/L,q=I/L;if(F==="horizontal"||F==="vertical"){var H=this.state.offset,U=$>=H.left&&$<=H.left+H.width&&q>=H.top&&q<=H.top+H.height;return U?{x:$,y:q}:null}var Q=this.state,se=Q.angleAxisMap,te=Q.radiusAxisMap;if(se&&te){var Y=m1(se);return pPe({x:$,y:q},Y)}return null}},{key:"parseEventsOfWrapper",value:function(){var A=this.props.children,I=this.getTooltipEventType(),L=Qm(A,pg),F={};L&&I==="axis"&&(L.props.trigger==="click"?F={onClick:this.handleClick}:F={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 $=mae(this.props,this.handleOuterEvent);return fr(fr({},$),F)}},{key:"addListener",value:function(){Xme.on(Qme,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Xme.removeListener(Qme,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(A,I,L){for(var F=this.state.formattedGraphicalItems,$=0,q=F.length;$");return t}const iXe=M.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=M.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(nXe.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:It("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...a,children:[e.jsx(yls,{id:i,config:n}),e.jsx(rye,{children:r})]})})});iXe.displayName="Chart";const yls=({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(xls).map(([n,a])=>` ${a} [data-chart=${t}] { ${r.map(([o,l])=>{var d;const i=((d=l.theme)==null?void 0:d[n])||l.color;return i?` --color-${o}: ${i};`:null}).join(` `)} } `).join(` `)}}):null},oXe=M.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:d,formatter:u,color:f,nameKey:g,labelKey:v},_)=>{const{config:b}=aXe(),w=M.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[N]=s,S=`${v||N.dataKey||N.name||"value"}`,A=i0e(b,N,S),I=!v&&typeof l=="string"?((L=b[l])==null?void 0:L.label)||l:A==null?void 0:A.label;return i?e.jsx("div",{className:It("font-medium",d),children:i(I,s)}):I?e.jsx("div",{className:It("font-medium",d),children:I}):null},[l,i,s,a,d,b,v]);if(!t||!(s!=null&&s.length))return null;const j=s.length===1&&n!=="dot";return e.jsxs("div",{ref:_,className:It("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[j?null:w,e.jsx("div",{className:"grid gap-1.5",children:s.map((N,S)=>{const A=`${g||N.name||N.dataKey||"value"}`,I=i0e(b,N,A),L=f||N.payload.fill||N.color;return e.jsx("div",{className:It("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:u&&(N==null?void 0:N.value)!==void 0&&N.name?u(N.value,N.name,N,S,N.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:It("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":j&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:It("flex flex-1 justify-between leading-none",j?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[j?w:null,e.jsx("span",{className:"text-muted-foreground",children:(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)})})]})});oXe.displayName="ChartTooltip";const vls=M.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=aXe();return r!=null&&r.length?e.jsx("div",{ref:o,className:It("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const d=`${a||i.dataKey||"value"}`,u=i0e(l,i,d);return e.jsxs("div",{className:It("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[u!=null&&u.icon&&!s?e.jsx(u.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),u==null?void 0:u.label]},i.value)})}):null});vls.displayName="ChartLegend";function i0e(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 oR=["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 Uwe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(De,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):e.jsxs("div",{className:"grid gap-6",children:[r&&e.jsxs(De,{className:"overflow-hidden",children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Oe,{className:"overflow-hidden",children:e.jsx(iXe,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(rye,{width:"100%",height:"100%",children:e.jsxs(fls,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(qYe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(cce,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(dce,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(pg,{content:e.jsx(oXe,{})}),e.jsx(sS,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(rye,{width:"100%",height:"100%",children:e.jsxs(gls,{children:[e.jsx(X0,{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(Fle,{fill:oR[o%oR.length]},`cell-${o}`))}),e.jsx(pg,{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:oR[o%oR.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function _ls(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=U1e(s,n,new Date);if(vge(a))return js(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(vge(n))return js(n,"yyyy-MM-dd")}catch{}return null}const bls=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function wls({open:t,onOpenChange:s}){const[r,n]=M.useState([]),[a,o]=M.useState(!1),[l,i]=M.useState(0),{data:d}=gL(),{data:u}=Vg(),f=Roe(),g=()=>{const N=bls.join(","),S=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),A=`${N} ${S}`,I=new Blob([A],{type:"text/csv"}),L=URL.createObjectURL(I),F=document.createElement("a");F.href=L,F.download="transaction-import-template.csv",F.click(),URL.revokeObjectURL(L)},v=N=>{const S=N.split(` `).filter(I=>I.trim());if(S.length<2)return[];const A=S[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return S.slice(1).map((I,L)=>{var le,de,xe,be;const F=[];let $="",q=!1;for(const ye of I)ye==='"'?q=!q:ye===","&&!q?(F.push($.trim()),$=""):$+=ye;F.push($.trim());const H=ye=>{var ke;const ve=A.indexOf(ye);return ve>=0?(ke=F[ve])==null?void 0:ke.replace(/^["']|["']$/g,"").trim():""},U=(le=H("transaction_type"))==null?void 0:le.toLowerCase(),Q=(de=H("sale_price"))==null?void 0:de.replace(/[$,]/g,""),se=(xe=H("commission_amount"))==null?void 0:xe.replace(/[$,]/g,""),te=(be=H("is_win"))==null?void 0:be.toLowerCase(),Y=H("close_date"),ce=_ls(Y);let oe;return H("property_address")?["buyer","seller"].includes(U)?ce?(!Q||isNaN(Number(Q)))&&(oe="Invalid sale price"):oe=`Invalid date format: "${Y}" - use MM/DD/YYYY or YYYY-MM-DD`:oe='Transaction type must be "buyer" or "seller"':oe="Missing property address",{property_address:H("property_address"),city:H("city"),state:H("state"),zip:H("zip"),transaction_type:U==="seller"?"seller":"buyer",close_date:ce||"",sale_price:Number(Q)||0,commission_amount:se?Number(se):null,lead_source_name:H("lead_source"),client_type_name:H("client_type"),is_win:["yes","true","1"].includes(te),notes:H("notes"),error:oe}})},_=N=>{var I;const S=(I=N.target.files)==null?void 0:I[0];if(!S)return;const A=new FileReader;A.onload=L=>{var q;const F=(q=L.target)==null?void 0:q.result,$=v(F);n($)},A.readAsText(S)},b=async()=>{const N=r.filter(I=>!I.error);if(N.length===0){ge.error("No valid transactions to import");return}o(!0),i(0);let S=0,A=0;for(let I=0;Iq.name.toLowerCase()===L.lead_source_name.toLowerCase()),$=u==null?void 0:u.find(q=>q.name.toLowerCase()===L.client_type_name.toLowerCase());await f.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:(F==null?void 0:F.id)||null,client_type_id:($==null?void 0:$.id)||null,contact_id:null,notes:L.notes||null,is_win:L.is_win}),S++}catch(F){A++,console.error("Failed to import transaction:",F)}i(Math.round((I+1)/N.length*100))}o(!1),S>0&&ge.success(`Imported ${S} transaction${S>1?"s":""}`),A>0&&ge.error(`Failed to import ${A} transaction${A>1?"s":""}`),n([]),s(!1)},w=r.filter(N=>!N.error).length,j=r.filter(N=>N.error).length;return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Import Transactions"}),e.jsx(Kr,{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(Z,{variant:"outline",onClick:g,children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(Re,{id:"csv-file",type:"file",accept:".csv",onChange:_})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(nt,{variant:"outline",children:[r.length," rows found"]}),w>0&&e.jsxs(nt,{className:"bg-green-500 text-white",children:[e.jsx(ma,{className:"h-3 w-3 mr-1"}),w," valid"]}),j>0&&e.jsxs(nt,{variant:"destructive",children:[e.jsx(Yo,{className:"h-3 w-3 mr-1"}),j," errors"]})]}),e.jsx(Fi,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((N,S)=>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(nt,{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(gbe,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(xbe,{className:"text-xs",children:N.error})})]},S)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{onClick:b,disabled:w===0||a,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Import ",w," Transaction",w!==1?"s":""]})]})]})]})})}const jls=O_({transactions_goal:AP().min(0).optional(),volume_goal:AP().min(0).optional(),gci_goal:AP().min(0).optional()});function kls({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=mkt(),{data:o}=Foe(),l=(o==null?void 0:o.show_commission)??!0,i=Soe({resolver:Coe(jls),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});M.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 d=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(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[r," Goals"]}),e.jsx(Kr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(Moe,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[e.jsx(yc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Transactions Goal"}),e.jsx(lc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 24",...u,value:u.value??"",onChange:f=>u.onChange(f.target.value?Number(f.target.value):void 0)})}),e.jsx(Kse,{children:"Total number of deals you want to close"}),e.jsx(Nh,{})]})}),e.jsx(yc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"Volume Goal ($)"}),e.jsx(lc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 5000000",...u,value:u.value??"",onChange:f=>u.onChange(f.target.value?Number(f.target.value):void 0)})}),e.jsx(Kse,{children:"Total sales volume you want to achieve"}),e.jsx(Nh,{})]})}),l&&e.jsx(yc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(ic,{children:[e.jsx(oc,{children:"GCI Goal ($)"}),e.jsx(lc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 150000",...u,value:u.value??"",onChange:f=>u.onChange(f.target.value?Number(f.target.value):void 0)})}),e.jsx(Kse,{children:"Gross commission income target"}),e.jsx(Nh,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function Vwe({transactions:t,isLoading:s}){const r=M.useRef(null),n=M.useRef(null),a=M.useRef([]),o=M.useRef(null),{isAdmin:l}=Qs(),[i,d]=M.useState(""),[u,f]=M.useState(!0),[g,v]=M.useState(0),[_,b]=M.useState(!1),w=t.filter(N=>N.latitude!=null&&N.longitude!=null),j=t.filter(N=>N.latitude==null||N.longitude==null);return M.useEffect(()=>{(async()=>{f(!0);try{const{data:S}=await K.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&d(S.value)}catch(S){console.error("Error fetching mapbox token:",S)}f(!1)})()},[]),M.useEffect(()=>{if(!i||j.length===0||_)return;(async()=>{var A;b(!0);let S=0;for(const I of j){const L=[I.property_address,I.city,I.state,I.zip].filter(Boolean).join(", ");if(L)try{const $=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${i}&limit=1`)).json();if((A=$.features)!=null&&A[0]){const[q,H]=$.features[0].center;await K.from("scorecard_transactions").update({latitude:H,longitude:q}).eq("id",I.id),I.latitude=H,I.longitude=q,S++}}catch(F){console.error("Geocode error:",F)}}v(S),b(!1)})()},[i,t]),M.useEffect(()=>{if(!r.current||!i||n.current)return;Fc.accessToken=i;const N=t.filter(I=>I.latitude!=null&&I.longitude!=null);let S=[-98.5795,39.8283],A=4;if(N.length>0){const I=N.reduce((F,$)=>F+$.longitude,0)/N.length,L=N.reduce((F,$)=>F+$.latitude,0)/N.length;S=[I,L],A=N.length===1?12:10}return n.current=new Fc.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:A,center:S}),n.current.addControl(new Fc.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.remove(),n.current=null}},[i]),M.useEffect(()=>{var S;if(!n.current||!i)return;a.current.forEach(A=>A.remove()),a.current=[],(S=o.current)==null||S.remove();const N=t.filter(A=>A.latitude!=null&&A.longitude!=null);if(N.forEach(A=>{var H;const I=A.transaction_type==="buyer",L=I?"#3B82F6":"#10B981",F=document.createElement("div");F.className="cursor-pointer",F.innerHTML=`
${I?'':''}
`;const $=new Fc.Popup({offset:25,closeButton:!0}).setHTML(`
${A.property_address}
${A.city?`
${A.city}${A.state?", "+A.state:""} ${A.zip||""}
`:""}
${I?"Buyer":"Seller"} $${Number(A.sale_price).toLocaleString()}
Closed: ${new Date(A.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(H=A.lead_source)!=null&&H.name?" · "+A.lead_source.name:""}
${A.contact?`
Client: ${A.contact.first_name} ${A.contact.last_name||""}
`:""}
`),q=new Fc.Marker(F).setLngLat([A.longitude,A.latitude]).setPopup($).addTo(n.current);a.current.push(q)}),N.length>1){const A=new Fc.LngLatBounds;N.forEach(I=>A.extend([I.longitude,I.latitude])),n.current.fitBounds(A,{padding:60,maxZoom:13})}else N.length===1&&n.current.flyTo({center:[N[0].longitude,N[0].latitude],zoom:12})},[t,i,_]),u||s?e.jsx(De,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[50vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Pi,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[w.length," of ",t.length," mapped",_&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Yo,{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 lXe=()=>{const{data:t}=Ug();return Tt({queryKey:["team-scorecard-members",t==null?void 0:t.teamId],queryFn:async()=>{const{data:s,error:r}=await K.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 K.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"})},Nls=t=>{const{data:s}=Ug(),{data:r}=lXe();return Tt({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 K.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 Sls(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 Cls(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function Mls({year:t}){var v;const{data:s,isLoading:r}=lXe(),{data:n,isLoading:a}=Nls(t),o=Or(),l=r||a,{aggregate:i,memberStats:d,topPerformer:u,agentNameMap:f,teamChartStats:g}=M.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const _=s.map(U=>Sls(U,n));_.sort((U,Q)=>Q.totalVolume-U.totalVolume);const b={};s.forEach(U=>{b[U.id]=U.name||U.email});const w=n.length,j=n.reduce((U,Q)=>U+Number(Q.sale_price),0),N=n.reduce((U,Q)=>U+(Number(Q.commission_amount)||0),0),S=n.filter(U=>U.transaction_type==="buyer").length,A=n.filter(U=>U.transaction_type==="seller").length,I={};n.forEach(U=>{var se;const Q=((se=U.lead_source)==null?void 0:se.name)||"Unknown";I[Q]=(I[Q]||0)+1});const L=Object.entries(I).sort((U,Q)=>Q[1]-U[1])[0],F={};n.forEach(U=>{const Q=new Date(U.close_date).toLocaleString("default",{month:"short"});F[Q]=(F[Q]||0)+1});const q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(U=>({month:U,count:F[U]||0})),H=Object.entries(I).map(([U,Q])=>({name:U,count:Q})).sort((U,Q)=>Q.count-U.count);return{aggregate:{totalTxns:w,buyerCount:S,sellerCount:A,totalVolume:j,avgPrice:w>0?j/w:0,totalGCI:N,topSource:L?{name:L[0],count:L[1]}:null,memberCount:s.length},memberStats:_,topPerformer:_[0]||null,agentNameMap:b,teamChartStats:{transactionsByMonth:q,leadSourceBreakdown:H}}},[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(_=>e.jsx(gs,{className:"h-24"},_))}),e.jsx(gs,{className:"h-64"})]}):!i||d.length===0?e.jsx(De,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-2",children:[e.jsx(xr,{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(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xr,{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(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Hn,{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(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Uc,{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:Sl(i.totalVolume,!0)})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vc,{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:Sl(i.avgPrice,!0)})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Uc,{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:Sl(i.totalGCI,!0)})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(dc,{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:((v=i.topSource)==null?void 0:v.name)||"-"}),i.topSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.topSource.count," deals"]})]})})]}),u&&u.totalTransactions>0&&e.jsx(De,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Oe,{className:"pt-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-primary/10",children:e.jsx(so,{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:Sl(u.totalVolume,!0)})]})]})}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Member Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:d.map((_,b)=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[b===0&&_.totalTransactions>0&&e.jsx(so,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:_.member.avatar_url||void 0}),e.jsx(pn,{className:"text-xs",children:Cls(_.member.name,_.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:_.member.name||_.member.email}),_.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:_.member.email})]})]})}),e.jsx(lt,{className:"text-center font-semibold",children:_.totalTransactions}),e.jsxs(lt,{className:"text-center text-sm",children:[_.buyerCount," / ",_.sellerCount]}),e.jsx(lt,{className:"text-right font-medium",children:Sl(_.totalVolume,!0)}),e.jsx(lt,{className:"text-right text-sm",children:Sl(_.averagePrice,!0)}),e.jsx(lt,{className:"text-right font-medium",children:Sl(_.totalGCI,!0)}),e.jsx(lt,{className:"text-right",children:e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${_.member.id}`),children:e.jsx(Na,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(Ia,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsxs(Ts,{value:"transactions",children:[e.jsx(Fh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(Ts,{value:"charts",children:[e.jsx(ol,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(Ts,{value:"map",children:[e.jsx(Pi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(Vs,{value:"transactions",children:e.jsx(Dbe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:f,readOnly:!0})}),e.jsx(Vs,{value:"charts",children:g&&e.jsx(Uwe,{stats:g,year:t})}),e.jsx(Vs,{value:"map",children:e.jsx(Vwe,{transactions:n||[],isLoading:a})})]})]})}const cXe=new Date().getFullYear(),UIe=Array.from({length:10},(t,s)=>cXe-s);function Tls(){var H;const[t,s]=M.useState(cXe),[r,n]=M.useState(!1),[a,o]=M.useState(!1),[l,i]=M.useState(!1),[d,u]=M.useState(!1),[f,g]=M.useState("my"),{data:v}=Ug(),_=(v==null?void 0:v.role)==="team_leader",{data:b,isLoading:w}=x_e(t),{yearStats:j,lifetimeStats:N,showCommission:S}=fqe(t),{data:A,isLoading:I}=pqe(t),{data:L}=Foe(),F=pkt(),$=()=>{if(!b||b.length===0)return;const U=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...S?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],Q=b.map(oe=>{var le,de;return[oe.property_address,oe.city||"",oe.state||"",oe.zip||"",oe.transaction_type,oe.close_date,oe.sale_price,...S?[oe.commission_amount||""]:[],((le=oe.lead_source)==null?void 0:le.name)||"",((de=oe.client_type)==null?void 0:de.name)||"",oe.contact?`${oe.contact.first_name} ${oe.contact.last_name||""}`.trim():"",oe.is_win?"Yes":"No",oe.notes||""]}),se=[U,...Q].map(oe=>oe.map(le=>`"${String(le).replace(/"/g,'""')}"`).join(",")).join(` `),te=new Blob([se],{type:"text/csv"}),Y=URL.createObjectURL(te),ce=document.createElement("a");ce.href=Y,ce.download=`transactions-${t}.csv`,ce.click(),URL.revokeObjectURL(Y)},q=!b||b.length===0;return e.jsxs(Ms,{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"})]}),_&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(Z,{variant:f==="my"?"default":"ghost",size:"sm",onClick:()=>g("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(Z,{variant:f==="team"?"default":"ghost",size:"sm",onClick:()=>g("team"),className:"h-8",children:[e.jsx(xr,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),f==="team"&&_?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(tr,{value:String(t),onValueChange:U=>s(Number(U)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(rr,{})}),e.jsx(er,{children:UIe.map(U=>e.jsx(At,{value:String(U),children:U},U))})]})]}),e.jsx(Mls,{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(tr,{value:String(t),onValueChange:U=>s(Number(U)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(rr,{})}),e.jsx(er,{children:UIe.map(U=>e.jsx(At,{value:String(U),children:U},U))})]}),e.jsx(Z,{variant:"outline",size:"icon",onClick:()=>u(!d),children:e.jsx(Pl,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsx(Vt,{className:"text-lg",children:"Settings"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_e,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(qr,{checked:(L==null?void 0:L.show_commission)??!0,onCheckedChange:U=>F.mutate({show_commission:U})})]})})]}),q&&!w?e.jsx(De,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ol,{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(Z,{onClick:()=>n(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(Z,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(xi,{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(Z,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(Ei,{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(Z,{onClick:()=>n(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(Z,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Mm,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(Z,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(Z,{variant:"outline",onClick:$,disabled:q,children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(Z,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(Ei,{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(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Hn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:j.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.totalTransactions," lifetime"]})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[j.buyerCount,"/",j.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Uc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Sl(j.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Sl(N.totalVolume,!0)," lifetime"]})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vc,{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:Sl(j.averagePrice,!0)})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(dc,{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:((H=j.topLeadSource)==null?void 0:H.name)||"-"}),j.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.topLeadSource.count," deals"]})]})}),S&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Uc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Sl(j.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Sl(N.totalCommission,!0)," lifetime"]})]})}),S&&j.totalNetToAgent>0&&j.totalNetToAgent!==j.totalCommission&&e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-teal-600 dark:text-teal-400 mb-1",children:[e.jsx(Uc,{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:Sl(j.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Sl(N.totalNetToAgent,!0)," lifetime"]})]})})]}),A&&e.jsx(yGe,{goals:A,stats:j,year:t,showCommission:S}),e.jsxs(Ia,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"transactions",children:"Transactions"}),e.jsx(Ts,{value:"charts",children:"Charts"}),e.jsxs(Ts,{value:"map",children:[e.jsx(Pi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(Vs,{value:"transactions",children:e.jsx(Dbe,{transactions:b||[],showCommission:S,isLoading:w})}),e.jsx(Vs,{value:"charts",children:e.jsx(Uwe,{stats:j,year:t})}),e.jsx(Vs,{value:"map",children:e.jsx(Vwe,{transactions:b||[],isLoading:w})})]})]})]})]}),e.jsx(xGe,{open:r,onOpenChange:n}),e.jsx(wls,{open:a,onOpenChange:o}),e.jsx(kls,{open:l,onOpenChange:i,year:t,existingGoals:A})]})}function dXe({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Qs(),[l,i]=M.useState(null),[d,u]=M.useState(!1),[f,g]=M.useState(!1);M.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:j,error:N}=await K.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(j&&j.share_token)i(j);else if(j&&!j.share_token){const{data:S,error:A}=await K.from("listing_shares").update({share_type:"referral_link"}).eq("id",j.id).select("id, share_token, click_count, lead_count").single();if(A)throw A;i(S)}else{const{data:S,error:A}=await K.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(A)throw A;i(S)}}catch(j){console.error("Error creating share link:",j),ge.error("Failed to generate share link")}finally{u(!1)}}})()},[t,o,r]);const v=l!=null&&l.share_token?`https://listings.relevelup.com/${n||r}?ref=${l.share_token}`:"",_=async()=>{try{await navigator.clipboard.writeText(v),g(!0),ge.success("Link copied to clipboard!"),setTimeout(()=>g(!1),2e3)}catch{ge.error("Failed to copy link")}},b=w=>{const j=encodeURIComponent(v),N=encodeURIComponent(`Check out this listing: ${a}`);switch(w){case"email":window.open(`mailto:?subject=${N}&body=${j}`);break;case"text":window.open(`sms:?body=${N}%20${j}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${j}`,"_blank");break}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(gn,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Kr,{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(_e,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:d?"Generating...":v,readOnly:!0,className:"font-mono text-sm"}),e.jsx(Z,{onClick:_,disabled:d||!v,variant:f?"default":"outline",children:f?e.jsx(ma,{className:"h-4 w-4"}):e.jsx(Ni,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Z,{variant:"outline",className:"flex-1",onClick:()=>b("email"),disabled:d,children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(Z,{variant:"outline",className:"flex-1",onClick:()=>b("text"),disabled:d,children:[e.jsx(ho,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Z,{variant:"outline",className:"flex-1",onClick:()=>b("facebook"),disabled:d,children:[e.jsx(Fd,{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(_e,{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(Na,{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(xr,{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 Als={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Els={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},Pls={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function lR({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var w,j;const{user:o}=Qs(),{data:l}=iqe(t.id),i=aqe(),[d,u]=M.useState(!1),f=N=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(N),g=((w=t.photos)==null?void 0:w.find(N=>N.is_primary))||((j=t.photos)==null?void 0:j[0]),v=(o==null?void 0:o.id)===t.agent_id,_=async N=>{N.stopPropagation();try{const S=await i.mutateAsync(t.id);ge.success(S.saved?"Listing saved!":"Listing removed from saved")}catch{ge.error("Failed to save listing")}},b=N=>{if(N.stopPropagation(),o)u(!0);else{const S=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(S),ge.success("Link copied to clipboard!")}};return e.jsxs(De,{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:[g?e.jsx("img",{src:g.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(Ux,{className:"h-12 w-12"})}),e.jsx(nt,{className:`absolute top-2 left-2 ${Als[t.status]} text-white border-0`,children:Els[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(Gn,{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(Z,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,children:e.jsx(Oi,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(Z,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:b,title:v?"Copy link":"Share & earn leads",children:v?e.jsx(nd,{className:"h-4 w-4"}):e.jsx(gn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(dXe,{open:d,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xl font-bold text-primary",children:f(t.price)}),t.open_to_referrals&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:[e.jsx(xr,{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(Pi,{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(q1,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(f0,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ux,{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(nt,{variant:"secondary",className:"text-xs",children:Pls[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(Na,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nd,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Oi,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(Z,{variant:"outline",size:"sm",className:"flex-1",onClick:N=>{N.stopPropagation(),r()},children:[e.jsx(Pc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(Z,{variant:"destructive",size:"sm",onClick:N=>{N.stopPropagation(),n()},children:e.jsx(Cr,{className:"h-4 w-4"})})]})]})]})}const Ils=[{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"}],Lls=[{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 Dls({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Vt,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Vr,{className:"h-4 w-4"})})]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Status"}),e.jsxs(tr,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"All statuses"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),Ils.map(a=>e.jsx(At,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Property Type"}),e.jsxs(tr,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"All types"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),Lls.map(a=>e.jsx(At,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Min Price"}),e.jsx(Re,{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(_e,{children:"Max Price"}),e.jsx(Re,{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(_e,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(qr,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function Ols({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(so,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(w0,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(dc,{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(nt,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-emerald-500/10 to-emerald-500/5 border border-emerald-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-emerald-500/20 flex items-center justify-center",children:e.jsx(nd,{className:"h-6 w-6 text-emerald-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Listing Amplifier"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Share 10+ listings"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-sky-500/10 to-sky-500/5 border border-sky-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-sky-500/20 flex items-center justify-center",children:e.jsx(Hn,{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(w0,{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(so,{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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Community Leaderboard"})}),e.jsx(Oe,{children:e.jsxs(Ia,{defaultValue:"sharers",children:[e.jsxs(Aa,{className:"w-full",children:[e.jsxs(Ts,{value:"sharers",className:"flex-1",children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(Ts,{value:"listers",className:"flex-1",children:[e.jsx(Hn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(Vs,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(Vs,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const VIe={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},HIe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Rls(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Fls({listings:t,isLoading:s}){const r=Or(),n=M.useRef(null),a=M.useRef(null),o=M.useRef([]),{isAdmin:l}=Qs(),[i,d]=M.useState(""),[u,f]=M.useState(!0),[g,v]=M.useState(!1),_=t.filter(w=>w.latitude!=null&&w.longitude!=null),b=t.filter(w=>(w.latitude==null||w.longitude==null)&&(w.property_address||w.city));return M.useEffect(()=>{(async()=>{f(!0);try{const{data:j}=await K.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();j!=null&&j.value&&d(j.value)}catch(j){console.error("Error fetching mapbox token:",j)}f(!1)})()},[]),M.useEffect(()=>{if(!i||b.length===0||g)return;(async()=>{var j;v(!0);for(const N of b){const S=[N.property_address,N.city,N.state].filter(Boolean).join(", ");if(S)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(S)}.json?access_token=${i}&limit=1`)).json();if((j=I.features)!=null&&j[0]){const[L,F]=I.features[0].center;await K.from("listings").update({latitude:F,longitude:L}).eq("id",N.id),N.latitude=F,N.longitude=L}}catch(A){console.error("Geocode error:",A)}}v(!1)})()},[i,t]),M.useEffect(()=>{if(!n.current||!i||a.current)return;Fc.accessToken=i;const w=t.filter(S=>S.latitude!=null&&S.longitude!=null);let j=[-98.5795,39.8283],N=4;if(w.length>0){const S=w.reduce((I,L)=>I+L.longitude,0)/w.length,A=w.reduce((I,L)=>I+L.latitude,0)/w.length;j=[S,A],N=w.length===1?12:10}return a.current=new Fc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:N,center:j}),a.current.addControl(new Fc.NavigationControl,"top-right"),()=>{var S;(S=a.current)==null||S.remove(),a.current=null}},[i]),M.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(j=>j.remove()),o.current=[];const w=t.filter(j=>j.latitude!=null&&j.longitude!=null);if(w.forEach(j=>{var F,$,q;const N=VIe[j.status]||"#10B981",S=((F=j.photos)==null?void 0:F.find(H=>H.is_primary))||(($=j.photos)==null?void 0:$[0]),A=document.createElement("div");A.className="cursor-pointer",A.innerHTML=`
`;const I=new Fc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${S!=null&&S.photo_url?``:""}
${Rls(j.price)}
${j.property_address||""}
${j.city}, ${j.state}
${HIe[j.status]||j.status} ${j.bedrooms?`${j.bedrooms} bed`:""} ${j.bathrooms?`${j.bathrooms} bath`:""}
${(q=j.agent)!=null&&q.name?`
Listed by ${j.agent.name}
`:""}
Click to view details →
`),L=new Fc.Marker(A).setLngLat([j.longitude,j.latitude]).setPopup(I).addTo(a.current);o.current.push(L)}),w.length>1){const j=new Fc.LngLatBounds;w.forEach(N=>j.extend([N.longitude,N.latitude])),a.current.fitBounds(j,{padding:60,maxZoom:13})}else w.length===1&&a.current.flyTo({center:[w[0].longitude,w[0].latitude],zoom:12})},[t,i,g]),M.useEffect(()=>(window.__navigateToListing__=w=>{r(`/mission-control/listings/${w}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(De,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[60vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Pi,{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(VIe).map(([w,j])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:j}}),e.jsx("span",{className:"text-xs",children:HIe[w]})]},w)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[_.length," of ",t.length," mapped",g&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Yo,{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 zls(){var H,U,Q,se,te,Y,ce,oe;const t=Or(),{brokerageId:s}=Qs(),{data:r,isLoading:n}=eqe(),[a,o]=M.useState("feed"),[l,i]=M.useState(!1),[d,u]=M.useState(""),[f,g]=M.useState({sortBy:"newest"}),{data:v,isLoading:_}=tqe({...f,city:d||f.city}),{data:b,isLoading:w}=Qjt(),{data:j,isLoading:N}=sqe(),{data:S,isLoading:A}=skt(),{data:I,isLoading:L}=akt(),{data:F}=nkt(),$=nqe(),q=async le=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await $.mutateAsync(le),ge.success("Listing deleted successfully")}catch{ge.error("Failed to delete listing")}};return n?e.jsx(Ms,{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(Ms,{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(Z,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Ys,{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(De,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Hn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(v==null?void 0:v.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Listings"})]})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Oi,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(b==null?void 0:b.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(Uk,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(j==null?void 0:j.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(xr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((H=S==null?void 0:S.sent)==null?void 0:H.length)||0)+(((U=S==null?void 0:S.received)==null?void 0:U.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(Ia,{value:a,onValueChange:o,children:[e.jsxs(Aa,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(Ts,{value:"feed",children:"Community Feed"}),s&&e.jsx(Ts,{value:"brokerage",children:"Brokerage"}),e.jsx(Ts,{value:"my-listings",children:"My Listings"}),e.jsx(Ts,{value:"saved",children:"Saved"}),e.jsx(Ts,{value:"referrals",children:"Referrals"}),e.jsx(Ts,{value:"map",children:"Map"}),e.jsx(Ts,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(Vs,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by city or neighborhood...",value:d,onChange:le=>u(le.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:f.sortBy,onValueChange:le=>g({...f,sortBy:le}),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Sort by"})}),e.jsxs(er,{children:[e.jsx(At,{value:"newest",children:"Newest First"}),e.jsx(At,{value:"updated",children:"Recently Updated"}),e.jsx(At,{value:"price_asc",children:"Price: Low to High"}),e.jsx(At,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(Z,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(y0,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(Dls,{filters:f,onFiltersChange:g,onClose:()=>i(!1)}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((le,de)=>e.jsxs(De,{children:[e.jsx(gs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{className:"h-4 w-1/2"}),e.jsx(gs,{className:"h-4 w-1/4"})]})]},de))}):(v==null?void 0:v.length)===0?e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Hn,{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(Z,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Ys,{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:v==null?void 0:v.map(le=>e.jsx(lR,{listing:le,onClick:()=>t(`/mission-control/listings/${le.id}`)},le.id))})]}),e.jsx(Vs,{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((le,de)=>e.jsxs(De,{children:[e.jsx(gs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{className:"h-4 w-1/2"})]})]},de))}):(j==null?void 0:j.length)===0?e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Uk,{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(Z,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j==null?void 0:j.map(le=>e.jsx(lR,{listing:le,showActions:!0,onClick:()=>t(`/mission-control/listings/${le.id}`),onEdit:()=>t(`/mission-control/listings/${le.id}/edit`),onDelete:()=>q(le.id)},le.id))})}),e.jsx(Vs,{value:"saved",className:"space-y-4",children:w?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((le,de)=>e.jsxs(De,{children:[e.jsx(gs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{className:"h-4 w-1/2"})]})]},de))}):(b==null?void 0:b.length)===0?e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Oi,{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:b==null?void 0:b.map(le=>e.jsx(lR,{listing:le.listing,onClick:()=>t(`/mission-control/listings/${le.listing.id}`)},le.id))})}),e.jsx(Vs,{value:"referrals",className:"space-y-6",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(nd,{className:"h-4 w-4"}),"Referrals Sent (",((Q=S==null?void 0:S.sent)==null?void 0:Q.length)||0,")"]}),((se=S==null?void 0:S.sent)==null?void 0:se.length)===0?e.jsx(De,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(te=S==null?void 0:S.sent)==null?void 0:te.map(le=>{var de,xe;return e.jsx(De,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:le.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((de=le.listing)==null?void 0:de.property_address)||((xe=le.listing)==null?void 0:xe.city)})]}),e.jsx(nt,{variant:le.status==="closed"?"default":"secondary",children:le.status.replace("_"," ")})]})})},le.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(xr,{className:"h-4 w-4"}),"Referrals Received (",((Y=S==null?void 0:S.received)==null?void 0:Y.length)||0,")"]}),((ce=S==null?void 0:S.received)==null?void 0:ce.length)===0?e.jsx(De,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(oe=S==null?void 0:S.received)==null?void 0:oe.map(le=>{var de;return e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:le.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(de=le.sender)==null?void 0:de.name]})]}),e.jsx(nt,{variant:le.status==="closed"?"default":"secondary",children:le.status.replace("_"," ")})]}),e.jsx(Z,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${le.listing_id}`),children:"View Listing"})]})},le.id)})})]})]})}),s&&e.jsx(Vs,{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((le,de)=>e.jsxs(De,{children:[e.jsx(gs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{className:"h-4 w-1/2"})]})]},de))}):(I==null?void 0:I.length)===0?e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Uk,{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(Z,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Ys,{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(le=>e.jsx(lR,{listing:le,onClick:()=>t(`/mission-control/listings/${le.id}`)},le.id))})}),e.jsx(Vs,{value:"map",children:e.jsx(Fls,{listings:v||[],isLoading:_})}),e.jsx(Vs,{value:"leaderboard",children:e.jsx(Ols,{leaderboard:F})})]})]})}):e.jsx(Ms,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Hn,{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 Hwe(t){const s=t.expected_commission;if(!s)return null;let r=s;return t.brokerage_split_pct&&(r-=s*(t.brokerage_split_pct/100)),t.team_split_pct&&(r-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(r-=s*(t.franchise_fee_pct/100)),t.referral_fee_pct&&(r-=s*(t.referral_fee_pct/100)),t.transaction_fee&&(r-=t.transaction_fee),Math.max(0,r)}function hce(){const t=vi();return Tt({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function uXe(){const t=vi(),s=ds();return Bt({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await K.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function mce(){const t=vi();return Tt({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 hXe(){const t=vi(),s=ds();return Bt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await K.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 K.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 mXe(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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 Bls(){const t=ds();return Bt({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await K.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await K.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 $ls(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.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 qls(t){return Tt({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await K.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Uls(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 Vls(t){return Tt({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await K.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function Hls(){const t=ds();return Bt({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await K.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 Wls(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 Gls(){const t=vi();return Tt({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.from("deal_pipeline").select("expected_price, expected_commission, brokerage_split_pct, team_split_pct, franchise_fee_pct, referral_fee_pct, transaction_fee, stage_id, 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(o=>{var l,i,d;return!((l=o.deal_pipeline_stages)!=null&&l.is_won_stage)&&!((i=o.deal_pipeline_stages)!=null&&i.is_lost_stage)&&((d=o.deal_pipeline_stages)==null?void 0:d.name)!=="Cancelled"}))||[],a=(s==null?void 0:s.filter(o=>{var l;return(l=o.deal_pipeline_stages)==null?void 0:l.is_won_stage}))||[];return{totalDeals:(s==null?void 0:s.length)||0,activeDeals:n.length,wonDeals:a.length,pipelineValue:n.reduce((o,l)=>o+(l.expected_price||0),0),expectedCommission:n.reduce((o,l)=>o+(l.expected_commission||0),0),expectedNetToAgent:n.reduce((o,l)=>o+(Hwe(l)||0),0),wonValue:a.reduce((o,l)=>o+(l.expected_price||0),0)}},enabled:!!t})}function Kls(t){const s=vi();return Tt({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await K.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 Zls(){const t=ds();return Bt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await K.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await K.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 Yls(){const t=ds();return Bt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await K.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 Xls({listing:t}){const s=Or(),[r,n]=M.useState(""),[a,o]=M.useState(!1),{data:l,isLoading:i}=Kls(t.id),{data:d,isLoading:u}=hce(),{data:f,isLoading:g}=mce(),v=uXe(),_=Zls(),b=Yls(),w=hXe(),j=(f==null?void 0:f.filter(L=>!L.listing_id))||[],N=L=>{if(!(d!=null&&d.length))return null;switch(L){case"coming_soon":case"active":case"price_improvement":return d.find(F=>F.name==="Active");case"under_contract":return d.find(F=>F.name==="Under Contract");case"sold":return d.find(F=>F.is_won_stage);default:return d.find(F=>F.name==="Active")}},S=async()=>{o(!0);try{d!=null&&d.length||await v.mutateAsync();const L=N(t.status);await w.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}),ge.success("Deal created and linked to listing!")}catch(L){console.error("Failed to create deal:",L),ge.error("Failed to create deal")}finally{o(!1)}},A=async()=>{if(!r){ge.error("Please select a deal");return}try{await _.mutateAsync({dealId:r,listingId:t.id}),ge.success("Listing linked to deal!"),n("")}catch{ge.error("Failed to link listing")}},I=async()=>{if(l)try{await b.mutateAsync({dealId:l.id,listingId:t.id}),ge.success("Listing unlinked from deal")}catch{ge.error("Failed to unlink listing")}};return i||u?e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Bx,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Rs,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(De,{className:"border-primary/20 bg-primary/5",children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Al,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.deal_name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:l.deal_pipeline_stages&&e.jsx(nt,{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(Z,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(Ai,{className:"h-3 w-3 ml-1"})]}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:I,disabled:b.isPending,children:b.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(nN,{className:"h-4 w-4"})})]})]})]}):e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsxs(Vt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Bx,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(Z,{onClick:S,disabled:a||w.isPending,className:"w-full",size:"sm",children:[a||w.isPending?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsx(Js,{className:"flex-1 text-sm",children:e.jsx(rr,{placeholder:"Link to existing deal..."})}),e.jsx(er,{children:j.map(L=>e.jsx(At,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(Z,{variant:"secondary",size:"icon",onClick:A,disabled:!r||_.isPending,children:_.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(Al,{className:"h-4 w-4"})})]})]})]})]})}const Qls={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Jls={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},WIe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function ecs(){var te,Y,ce,oe,le,de,xe,be,ye;const{listingId:t}=Uo(),s=Or(),{user:r}=Qs(),{data:n,isLoading:a}=rqe(t||""),{data:o}=iqe(t||""),{data:l}=ekt(t||""),i=aqe(),d=Jjt(),u=tkt(),f=nqe(),g=rkt(),[v,_]=M.useState(!1),[b,w]=M.useState(!1),[j,N]=M.useState(!1),[S,A]=M.useState(null),[I,L]=M.useState({buyerName:"",buyerType:"",notes:""}),F=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=ve=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ve),q=async ve=>{const ke=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Ge=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:ve});try{switch(ve){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(ke)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(ke),ge.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Ge} ${ke}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ge)}&body=${encodeURIComponent(`Check out this listing: ${ke}`)}`);break}}catch(Ne){console.error("Share error:",Ne),ge.error("Failed to share")}},H=async()=>{try{await f.mutateAsync(n.id),ge.success("Listing deleted"),s("/mission-control/listings")}catch{ge.error("Failed to delete listing")}},U=async()=>{if(!I.buyerName.trim()){ge.error("Please enter buyer name");return}try{await g.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:I.buyerName,buyerType:I.buyerType||void 0,notes:I.notes||void 0}),ge.success("Referral sent successfully!"),w(!1),L({buyerName:"",buyerType:"",notes:""})}catch{ge.error("Failed to send referral")}},Q=ve=>{var Ie,Ve;const ke=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Ge=$((n==null?void 0:n.price)||0),Ne=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Ae=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Pe=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Fe=[Ne,Ae,Pe].filter(Boolean).join(" | ");switch(ve){case"just_listed":return`🏡 JUST LISTED! ${ke} ${Ge} ${Fe} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Ie=n==null?void 0:n.city)==null?void 0:Ie.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${ke} Now ${Ge}! ${Fe} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${WIe[(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! ${Fe} DM me for details! 📩 #ComingSoon #RealEstate #${(Ve=n==null?void 0:n.city)==null?void 0:Ve.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Ms,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-10 w-32"}),e.jsx(gs,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(gs,{className:"h-48"}),e.jsx(gs,{className:"h-48"}),e.jsx(gs,{className:"h-48"})]})]})});if(!n)return e.jsx(Ms,{title:"Listing Not Found",description:"",children:e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(Z,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const se=((te=n.photos)==null?void 0:te.find(ve=>ve.is_primary))||((Y=n.photos)==null?void 0:Y[0]);return e.jsxs(Ms,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Z,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Ba,{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:()=>se&&A(se.photo_url),children:se?e.jsx("img",{src:se.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((ve,ke)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>A(ve.photo_url),children:e.jsx("img",{src:ve.photo_url,alt:`Photo ${ke+2}`,className:"w-full h-full object-cover"})},ve.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(De,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(nt,{className:`${Qls[n.status]} text-white border-0`,children:Jls[n.status]}),n.is_featured&&e.jsxs(nt,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(nt,{variant:"outline",children:[e.jsx(xr,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:$(n.price)}),n.property_address&&e.jsx("p",{className:"text-xl font-medium",children:n.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Pi,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(Oi,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(Z,{variant:"outline",size:"icon",onClick:()=>d.mutate(n.id),children:l?e.jsx(U1,{className:"h-4 w-4"}):e.jsx(af,{className:"h-4 w-4"})}),!F&&e.jsxs(Z,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>N(!0),children:[e.jsx(gn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsxs(Z,{variant:"outline",children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(mu,{children:[e.jsxs(Wa,{onClick:()=>q("copy"),children:[e.jsx(Ni,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Wa,{onClick:()=>q("facebook"),children:[e.jsx(Fd,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Wa,{onClick:()=>q("text"),children:[e.jsx(ho,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Wa,{onClick:()=>q("email"),children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),F&&e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(Pc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(Z,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:e.jsx(Cr,{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(q1,{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(f0,{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(Ux,{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(nn,{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(nt,{variant:"secondary",children:[e.jsx(_a,{className:"h-3 w-3 mr-1"}),WIe[n.property_type]]}),n.lot_size&&e.jsxs(nt,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(nt,{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(Z,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(un,{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(Na,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nd,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Oi,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Share Content"})}),e.jsx(Oe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(ve=>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:[ve.replace("_"," ")," Caption"]}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(Q(ve)),ge.success("Caption copied!")},children:e.jsx(Ni,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:Q(ve)})]},ve))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:((le=(oe=n.agent)==null?void 0:oe.name)==null?void 0:le.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((de=n.agent)==null?void 0:de.name)||"Unknown"}),((be=(xe=n.agent)==null?void 0:xe.brokerage)==null?void 0:be.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!F&&e.jsx("div",{className:"space-y-2",children:((ye=n.agent)==null?void 0:ye.email)&&e.jsx(Z,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),F&&e.jsx(Xls,{listing:n}),!F&&n.open_to_referrals&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Have a buyer interested in this property? Send a referral to the listing agent."}),e.jsx(Z,{className:"w-full",onClick:()=>w(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(bs,{open:!!S,onOpenChange:()=>A(null),children:e.jsx(_s,{className:"max-w-4xl",children:e.jsx("img",{src:S||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(bs,{open:v,onOpenChange:_,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Delete Listing"}),e.jsx(Kr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(Z,{variant:"destructive",onClick:H,disabled:f.isPending,children:f.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(bs,{open:b,onOpenChange:w,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Send Buyer Referral"}),e.jsx(Kr,{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(_e,{children:"Buyer Name *"}),e.jsx(Re,{value:I.buyerName,onChange:ve=>L({...I,buyerName:ve.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Buyer Type"}),e.jsxs(tr,{value:I.buyerType,onValueChange:ve=>L({...I,buyerType:ve}),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"first_time",children:"First-Time Buyer"}),e.jsx(At,{value:"investor",children:"Investor"}),e.jsx(At,{value:"relocating",children:"Relocating"}),e.jsx(At,{value:"upgrade",children:"Upgrading"}),e.jsx(At,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Notes"}),e.jsx(Lr,{value:I.notes,onChange:ve=>L({...I,notes:ve.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(Z,{onClick:U,disabled:g.isPending,children:g.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(dXe,{open:j,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 tcs({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:d}=UWe({id:t.id}),u={transform:x3.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:It("relative aspect-square rounded-lg overflow-hidden bg-muted group",d&&"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(Rh,{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(Vr,{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(Gn,{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 scs({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=bWe(Nxe(lle,{activationConstraint:{distance:5}})),i=[...t].sort((u,f)=>(u.sort_order??0)-(f.sort_order??0)),d=u=>{const{active:f,over:g}=u;if(!g||f.id===g.id)return;const v=i.findIndex(N=>N.id===f.id),_=i.findIndex(N=>N.id===g.id),b=[...i],[w]=b.splice(v,1);b.splice(_,0,w);const j=b.map((N,S)=>({...N,sort_order:S}));a(j)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(FWe,{sensors:l,collisionDetection:NWe,onDragEnd:d,children:e.jsx($We,{items:i.map(u=>u.id),strategy:ule,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(tcs,{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(Rs,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{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 rcs({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=Or(),{user:a}=Qs(),[o,l]=M.useState(!1),[i,d]=M.useState([]),[u,f]=M.useState(!1),[g,v]=M.useState(null),[_,b]=M.useState({});M.useEffect(()=>{t&&a?w():v(null)},[t,a]);const w=async()=>{if(!t)return;const{data:H,error:U}=await K.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();!U&&H&&(v(H),j(H))},j=async H=>{try{const{data:U,error:Q}=await K.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:H.bunny_video_id,isAgentVideo:!0}});!Q&&(U!=null&&U.thumbnailUrl)&&b(se=>({...se,[H.id]:{thumbnailUrl:U.thumbnailUrl}}))}catch(U){console.warn("Failed to get signed URL",U)}},N=async()=>{if(a){f(!0);try{const{data:H,error:U}=await K.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(U)throw U;d(H||[]),H!=null&&H.length&&S(H)}catch(H){console.error("Error fetching videos:",H),ge.error("Failed to load videos")}finally{f(!1)}}},S=async H=>{var U;try{const Q=H.map(oe=>oe.bunny_video_id),{data:se,error:te}=await K.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Q,isAgentVideo:!0}});if(te)throw te;const Y=(se==null?void 0:se.assets)||{},ce={};for(const oe of H)(U=Y[oe.bunny_video_id])!=null&&U.thumbnailUrl&&(ce[oe.id]={thumbnailUrl:Y[oe.bunny_video_id].thumbnailUrl});b(oe=>({...oe,...ce}))}catch(Q){console.warn("Failed to bulk-fetch signed URLs",Q)}},A=()=>{l(!0),N()},I=H=>{s(H.id),v(H),l(!1),ge.success("Video selected")},L=()=>{s(null),v(null)},F=()=>{const H=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(H)}`)},$=H=>{if(!H)return"0:00";const U=Math.floor(H/60),Q=H%60;return`${U}:${Q.toString().padStart(2,"0")}`},q=H=>{var U;return((U=_[H.id])==null?void 0:U.thumbnailUrl)||H.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[g?e.jsx(De,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex items-start gap-4 p-4",children:[e.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[q(g)?e.jsx("img",{src:q(g),alt:g.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(dl,{className:"h-6 w-6 text-white fill-white"})}),g.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:$(g.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:g.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(Z,{type:"button",variant:"outline",size:"sm",onClick:A,children:"Change"}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:L,className:"text-destructive hover:text-destructive",children:e.jsx(Vr,{className:"h-4 w-4"})})]})]})})}):e.jsx(De,{className:"border-dashed",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Cn,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[e.jsxs(Z,{type:"button",variant:"outline",onClick:A,className:"gap-2",children:[e.jsx(r5,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(Z,{type:"button",variant:"outline",onClick:F,className:"gap-2",children:[e.jsx(Mg,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Cs,{children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(r5,{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(Rs,{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(Z,{onClick:F,className:"gap-2",children:[e.jsx(Mg,{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(H=>e.jsxs("button",{type:"button",onClick:()=>I(H),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===H.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:[q(H)?e.jsx("img",{src:q(H),alt:H.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(dl,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),H.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:$(H.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:H.title||"Untitled Video"})})]},H.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(Z,{type:"button",variant:"ghost",onClick:F,className:"gap-2",children:[e.jsx(Mg,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(Z,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const ncs=[{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"}],acs=[{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 GIe(){const{listingId:t}=Uo(),[s]=Gc(),r=s.get("brokerage"),n=Or(),{user:a}=Qs(),o=!!t&&t!=="new",l=!!r&&!o,{data:i,isLoading:d}=rqe(o?t:""),u=Hjt(),f=Wjt(),g=Gjt(),v=Kjt(),_=Zjt(),b=Yjt(),w=Xjt(),{data:j=[]}=Tt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:le,error:de}=await K.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(de)throw de;return le||[]},enabled:l}),[N,S]=M.useState(""),[A,I]=M.useState(!1),[L,F]=M.useState([]),[$,q]=M.useState([]),[H,U]=M.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});M.useEffect(()=>{var le,de,xe,be,ye;i&&o&&U({property_address:i.property_address||"",city:i.city||"",state:i.state||"",neighborhood:i.neighborhood||"",price:((le=i.price)==null?void 0:le.toString())||"",property_type:i.property_type,status:i.status,bedrooms:((de=i.bedrooms)==null?void 0:de.toString())||"",bathrooms:((xe=i.bathrooms)==null?void 0:xe.toString())||"",square_footage:((be=i.square_footage)==null?void 0:be.toString())||"",lot_size:i.lot_size||"",year_built:((ye=i.year_built)==null?void 0:ye.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 Q=le=>{if(!le)return;const de=Array.from(le);F(be=>[...be,...de]);const xe=de.map(be=>URL.createObjectURL(be));q(be=>[...be,...xe])},se=le=>{URL.revokeObjectURL($[le]),F(de=>de.filter((xe,be)=>be!==le)),q(de=>de.filter((xe,be)=>be!==le))},te=async le=>{var de;if(!(!le||!i)){I(!0);try{for(const xe of Array.from(le)){const be=xe.name.split(".").pop(),ye=`${a==null?void 0:a.id}/${i.id}/${Date.now()}.${be}`,{error:ve}=await K.storage.from("listing-photos").upload(ye,xe);if(ve)throw ve;const{data:{publicUrl:ke}}=K.storage.from("listing-photos").getPublicUrl(ye);await v.mutateAsync({listingId:i.id,photoUrl:ke,isPrimary:!((de=i.photos)!=null&&de.length)})}ge.success("Photos uploaded!")}catch(xe){console.error("Upload error:",xe),ge.error("Failed to upload photos")}finally{I(!1)}}},Y=async le=>{for(let de=0;de{if(i)try{await _.mutateAsync({photoId:le,listingId:i.id}),ge.success("Photo removed")}catch{ge.error("Failed to remove photo")}},oe=async le=>{if(le.preventDefault(),!H.city.trim()||!H.state.trim()||!H.price){ge.error("Please fill in required fields (City, State, Price)");return}if(l&&!N){ge.error("Please select an agent to assign this listing to");return}try{const de={property_address:H.property_address||null,city:H.city,state:H.state,neighborhood:H.neighborhood||null,price:Number(H.price),property_type:H.property_type,status:H.status,bedrooms:H.bedrooms?Number(H.bedrooms):null,bathrooms:H.bathrooms?Number(H.bathrooms):null,square_footage:H.square_footage?Number(H.square_footage):null,lot_size:H.lot_size||null,year_built:H.year_built?Number(H.year_built):null,has_hoa:H.has_hoa,description:H.description||null,agent_notes:H.agent_notes||null,agent_notes_public:H.agent_notes_public,mls_link:H.mls_link||null,video_link:H.video_link||null,video_id:H.video_id||null,allow_sharing:H.allow_sharing,open_to_referrals:H.open_to_referrals,open_to_social_promotion:H.open_to_social_promotion,share_with_brokerage:H.share_with_brokerage,is_public:H.is_public};if(o)await g.mutateAsync({id:t,...de}),ge.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{I(!0);let xe;if(l&&N?xe=await f.mutateAsync({agentId:N,...de}):xe=await u.mutateAsync(de),L.length>0)try{await Y(xe.id),$.forEach(be=>URL.revokeObjectURL(be)),F([]),q([])}catch(be){console.error("Photo upload error:",be),ge.error("Listing created but some photos failed to upload")}I(!1),ge.success("Listing created!"),n(l?"/my-brokerage":`/mission-control/listings/${xe.id}`)}}catch(de){console.error("Save error:",de),ge.error("Failed to save listing"),I(!1)}};return o&&d?e.jsx(Ms,{title:"Loading...",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-10 w-32"}),e.jsx(gs,{className:"h-[600px] w-full"})]})}):e.jsx(Ms,{title:o?"Edit Listing":l?"Add Listing for Agent":"Add Listing",description:"",children:e.jsxs("form",{onSubmit:oe,className:"space-y-6",children:[e.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>n(l?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Ba,{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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Assign to Agent *"})}),e.jsxs(Oe,{children:[e.jsxs(tr,{value:N,onValueChange:S,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select an agent..."})}),e.jsx(er,{children:j.map(le=>e.jsx(At,{value:le.id,children:le.name||le.email},le.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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Property Details"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Re,{value:H.property_address,onChange:le=>U({...H,property_address:le.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"City *"}),e.jsx(Re,{value:H.city,onChange:le=>U({...H,city:le.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"State *"}),e.jsx(Re,{value:H.state,onChange:le=>U({...H,state:le.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Neighborhood"}),e.jsx(Re,{value:H.neighborhood,onChange:le=>U({...H,neighborhood:le.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Price *"}),e.jsx(Re,{type:"number",value:H.price,onChange:le=>U({...H,price:le.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Property Type"}),e.jsxs(tr,{value:H.property_type,onValueChange:le=>U({...H,property_type:le}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:acs.map(le=>e.jsx(At,{value:le.value,children:le.label},le.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Status"}),e.jsxs(tr,{value:H.status,onValueChange:le=>U({...H,status:le}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:ncs.map(le=>e.jsx(At,{value:le.value,children:le.label},le.value))})]})]})]})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Property Specs (Optional)"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Bedrooms"}),e.jsx(Re,{type:"number",value:H.bedrooms,onChange:le=>U({...H,bedrooms:le.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Bathrooms"}),e.jsx(Re,{type:"number",step:"0.5",value:H.bathrooms,onChange:le=>U({...H,bathrooms:le.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Sq Ft"}),e.jsx(Re,{type:"number",value:H.square_footage,onChange:le=>U({...H,square_footage:le.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Lot Size"}),e.jsx(Re,{value:H.lot_size,onChange:le=>U({...H,lot_size:le.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Year Built"}),e.jsx(Re,{type:"number",value:H.year_built,onChange:le=>U({...H,year_built:le.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(qr,{checked:H.has_hoa,onCheckedChange:le=>U({...H,has_hoa:le})}),e.jsx(_e,{children:"Has HOA"})]})]})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Description & Links"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{value:H.description,onChange:le=>U({...H,description:le.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Agent Notes"}),e.jsx(Lr,{value:H.agent_notes,onChange:le=>U({...H,agent_notes:le.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:H.agent_notes_public,onCheckedChange:le=>U({...H,agent_notes_public:le})}),e.jsx(_e,{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(_e,{children:"MLS Link"}),e.jsx(Re,{value:H.mls_link,onChange:le=>U({...H,mls_link:le.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Video Link"}),e.jsx(Re,{value:H.video_link,onChange:le=>U({...H,video_link:le.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Oe,{children:e.jsx(rcs,{selectedVideoId:H.video_id,onVideoSelect:le=>U({...H,video_id:le}),listingId:o?t:void 0})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Photos"})}),e.jsx(Oe,{children:o&&(i!=null&&i.photos)?e.jsx(scs,{photos:i.photos,uploading:A,onUpload:le=>te(le),onRemove:le=>ce(le),onReorder:le=>{b.mutate({photos:le.map(de=>({id:de.id,sort_order:de.sort_order,is_primary:de.is_primary}))})},onSetPrimary:le=>{i&&w.mutate({photoId:le,listingId:i.id})}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[$.map((le,de)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:le,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>se(de),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:e.jsx(Vr,{className:"h-3 w-3"})}),de===0&&e.jsx("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded",children:"Primary"})]},de)),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(Rs,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{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:le=>Q(le.target.files),disabled:A})]})]}),L.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[L.length," photo",L.length!==1?"s":""," will be uploaded when you save."]})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Sharing & Collaboration"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(qr,{checked:H.allow_sharing,onCheckedChange:le=>U({...H,allow_sharing:le})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(qr,{checked:H.open_to_referrals,onCheckedChange:le=>U({...H,open_to_referrals:le})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(qr,{checked:H.open_to_social_promotion,onCheckedChange:le=>U({...H,open_to_social_promotion:le})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(qr,{checked:H.share_with_brokerage,onCheckedChange:le=>U({...H,share_with_brokerage:le})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(qr,{checked:H.is_public,onCheckedChange:le=>U({...H,is_public:le})})]})]})]}),e.jsx(Z,{type:"submit",className:"w-full",size:"lg",disabled:u.isPending||g.isPending,children:u.isPending||g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):o?"Update Listing":"Create Listing"})]})]})]})})}function pce({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=M.useRef(null),i=M.useRef(null),d=M.useRef(null),u=M.useRef([]),f=M.useRef(null),g=M.useRef(null),v=M.useRef(null),_=M.useRef(null),b=xM(),[w,j]=M.useState(!0),[N,S]=M.useState(!0),[A,I]=M.useState(null),[L,F]=M.useState(!1),[$,q]=M.useState(!1),[H,U]=M.useState(null),[Q,se]=M.useState(null),[te,Y]=M.useState(0),[ce,oe]=M.useState("user"),[le,de]=M.useState(0),[xe,be]=M.useState(!1),[ye,ve]=M.useState(!0),[ke,Ge]=M.useState(null),[Ne,Ae]=M.useState(!1),[Pe,Fe]=M.useState(null),Ie=M.useRef(null),Ve=M.useRef(r);Ve.current=r;const dt=M.useCallback(qe=>{j(qe)},[]),Le=M.useRef(w),Rt=M.useCallback(async()=>{var Je,Lt;S(!0),Ge(null);const qe=b&&w;console.log("[VideoRecorder] initCamera start",{isMobile:b,usePortraitMode:w,shouldBePortrait:qe,facingMode:ce});try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Camera not available in this browser or context. Try opening in a new tab.");d.current&&(console.log("[VideoRecorder] stopping existing stream"),d.current.getTracks().forEach(fs=>fs.stop()));const zt=b&&qe?{facingMode:{ideal:ce},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:ce},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",zt);const is=await navigator.mediaDevices.getUserMedia({video:zt,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),is.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=is,I(!0);const Qt=is.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",Qt.width,"x",Qt.height),l.current){const fs=l.current;fs.srcObject=is,fs.muted=!0,fs.playsInline=!0,fs.autoplay=!0,fs.setAttribute("muted",""),fs.setAttribute("playsinline",""),fs.setAttribute("autoplay","");try{(Je=fs.load)==null||Je.call(fs)}catch(bt){console.warn("[VideoRecorder] videoEl.load failed",bt)}const dr=async()=>{try{return await fs.play(),console.log("[VideoRecorder] preview play ok"),Ae(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:fs.readyState,videoWidth:fs.videoWidth,videoHeight:fs.videoHeight})},300),!0}catch(bt){return console.warn("[VideoRecorder] preview play blocked",bt),Ae(!0),!1}};await new Promise(bt=>{let ws=!1;const ir=()=>{ws||(ws=!0,bt())},Rr=()=>{dr().finally(ir)};fs.onloadedmetadata=Rr,fs.onloadeddata=Rr,setTimeout(ir,1500)})}try{g.current=new AudioContext;const fs=g.current.createMediaStreamSource(is);v.current=g.current.createAnalyser(),v.current.fftSize=256,fs.connect(v.current);const dr=()=>{if(v.current){const bt=new Uint8Array(v.current.frequencyBinCount);v.current.getByteFrequencyData(bt);const ws=bt.reduce((ir,Rr)=>ir+Rr)/bt.length;de(Math.min(100,ws/128*100))}_.current=requestAnimationFrame(dr)};dr()}catch(fs){console.warn("Audio context not available:",fs)}}catch(zt){console.error("Camera initialization error:",zt),I(!1);let is="Failed to access camera or microphone.";zt.name==="NotAllowedError"?is="Camera permission denied. Please allow camera access in your browser settings.":zt.name==="NotFoundError"?is="No camera found. Please connect a camera and try again.":zt.name==="NotReadableError"?is="Camera is in use by another application. Please close other apps using the camera.":zt.message&&(is=zt.message),Ge(is),(Lt=Ve.current)==null||Lt.call(Ve,is)}finally{S(!1)}},[ce,b,w]);M.useEffect(()=>{Le.current!==w&&A&&!L&&!Q&&(Le.current=w,Rt())},[w,A,L,Q,Rt]),M.useEffect(()=>(Rt(),()=>{d.current&&d.current.getTracks().forEach(qe=>qe.stop()),f.current&&clearInterval(f.current),_.current&&cancelAnimationFrame(_.current),g.current&&g.current.close(),Ie.current&&clearInterval(Ie.current),Q&&URL.revokeObjectURL(Q)}),[Rt,Q]),M.useEffect(()=>{if(N||A!==!0||Q)return;const qe=d.current,Je=l.current;!qe||!Je||(Je.srcObject!==qe&&(Je.srcObject=qe,Je.muted=!0,Je.playsInline=!0,Je.autoplay=!0,Je.setAttribute("muted",""),Je.setAttribute("playsinline",""),Je.setAttribute("autoplay","")),Je.play().then(()=>Ae(!1)).catch(Lt=>{Ae(!0),console.warn("Live preview play blocked on mount:",Lt)}))},[A,N,Q]),M.useEffect(()=>{n==null||n(L)},[L,n]);const fe=M.useCallback(async()=>{if(Q)return;const qe=l.current;if(qe)try{await qe.play(),Ae(!1)}catch(Je){Ae(!0),console.warn("Live preview still blocked (needs user gesture):",Je)}},[Q]),Qe=M.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),f.current&&(clearInterval(f.current),f.current=null),F(!1),q(!1)},[]),at=M.useCallback(()=>{if(!d.current)return;fe(),u.current=[],Y(0);const Je=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(zt=>MediaRecorder.isTypeSupported(zt)),Lt=new MediaRecorder(d.current,Je?{mimeType:Je,videoBitsPerSecond:25e5}:{videoBitsPerSecond:25e5});Lt.ondataavailable=zt=>{zt.data.size>0&&u.current.push(zt.data)},Lt.onstop=()=>{var Qt;const zt=Lt.mimeType||Je||((Qt=u.current[0])==null?void 0:Qt.type)||"video/webm",is=new Blob(u.current,{type:zt});U(is);const Kt=URL.createObjectURL(is);se(Kt)},i.current=Lt,Lt.start(100),F(!0),f.current=setInterval(()=>{Y(zt=>zt>=t-1?(Qe(),t):zt+1)},1e3)},[fe,t,Qe]),rt=M.useCallback(()=>{Ie.current&&(clearInterval(Ie.current),Ie.current=null),Fe(3);let qe=3;Ie.current=setInterval(()=>{qe-=1,qe<=0?(Ie.current&&clearInterval(Ie.current),Ie.current=null,Fe(null),at()):Fe(qe)},1e3)},[at]),je=M.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),q(!0),f.current&&clearInterval(f.current))},[]),mt=M.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),q(!1),f.current=setInterval(()=>{Y(qe=>qe>=t-1?(Qe(),t):qe+1)},1e3))},[t,Qe]),He=M.useCallback(()=>{Q&&URL.revokeObjectURL(Q),U(null),se(null),Y(0),be(!1),ve(!0),l.current&&d.current&&(l.current.srcObject=d.current,l.current.muted=!0,fe())},[fe,Q]),ct=M.useCallback(()=>{oe(qe=>qe==="user"?"environment":"user")},[]),We=M.useCallback(()=>{H&&s(H,te)},[H,te,s]),Ze=M.useCallback(()=>{l.current&&Q&&(xe?l.current.pause():(ve(!1),l.current.muted=!1,l.current.play()),be(!xe))},[Q,xe]);M.useEffect(()=>{if(!Q)return;const qe=l.current;if(!qe)return;ve(!1),qe.pause(),qe.removeAttribute("src"),qe.srcObject=null,qe.load(),qe.src=Q,qe.currentTime=0,qe.playsInline=!0,qe.muted=!1,qe.onended=()=>be(!1);const Je=()=>{var is;const Lt=qe.error,zt=Lt?`Recorded video failed to play (code ${Lt.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Lt),(is=Ve.current)==null||is.call(Ve,zt)};return qe.addEventListener("error",Je),qe.load(),()=>{qe.removeEventListener("error",Je)}},[Q]);const ht=qe=>{const Je=Math.floor(qe/60),Lt=qe%60;return`${Je}:${Lt.toString().padStart(2,"0")}`},Ke=b&&w?"aspect-[9/16]":"aspect-video";return N?e.jsx("div",{className:It("flex items-center justify-center bg-black rounded-lg",Ke,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(Rs,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):A===!1?e.jsx("div",{className:It("flex items-center justify-center bg-black rounded-lg",Ke,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(Yo,{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:ke||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Z,{onClick:()=>Rt(),variant:"secondary",className:"w-full",children:[e.jsx(Ao,{className:"h-4 w-4 mr-2"}),"Try Again"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-3",children:"💡 Tip: If you're viewing this in an embedded preview, try opening the app in a new browser tab for full camera access."})]})]})}):e.jsxs("div",{className:It("flex flex-col gap-2",a),children:[b&&!L&&!Q&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(Xk,{className:It("h-4 w-4",w?"text-muted-foreground":"text-primary")}),e.jsx(_e,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(qr,{id:"orientation-toggle",checked:w,onCheckedChange:dt}),e.jsx(_e,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(N0,{className:It("h-4 w-4",w?"text-primary":"text-muted-foreground")})]}),e.jsxs("div",{className:It("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{fe()},children:[e.jsx("video",{ref:l,src:Q??void 0,className:It("w-full bg-black",w&&!Q?"object-contain":"object-cover",Ke,ce==="user"&&!Q&&"scale-x-[-1]"),playsInline:!0,controls:!!Q,muted:Q?ye:!0,autoPlay:!Q},Q??"live"),!Q&&Ne&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(Z,{type:"button",variant:"secondary",onClick:()=>void fe(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!Q&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Pe!==null&&!Q&&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:Pe},Pe),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),L&&e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx("div",{className:It("w-3 h-3 rounded-full",$?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[ht(te)," / ",ht(t)]})]}),L&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(wo,{value:te/t*100,className:"h-1 rounded-none"})}),!Q&&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(rP,{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:`${le}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:Q?e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:He,children:[e.jsx(Ao,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(Z,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Ze,children:xe?e.jsx(mp,{className:"h-5 w-5"}):e.jsx(dl,{className:"h-5 w-5"})}),e.jsxs(Z,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:We,children:[e.jsx(ma,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:ct,disabled:L||Pe!==null,children:e.jsx(k0,{className:"h-5 w-5"})}),!L&&Pe===null?e.jsx(Z,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:rt,children:e.jsx(Cn,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:$?mt:je,children:$?e.jsx(dl,{className:"h-5 w-5"}):e.jsx(mp,{className:"h-5 w-5"})}),e.jsx(Z,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Qe,children:e.jsx(Ux,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const pXe="teleprompter_settings",epe={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function ics(){try{const t=localStorage.getItem(pXe);return t?{...epe,...JSON.parse(t)}:epe}catch{return epe}}function ocs(t){try{localStorage.setItem(pXe,JSON.stringify(t))}catch{}}function fXe({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=M.useRef(null),d=M.useRef(null),u=M.useRef(0),f=M.useRef(0),[g,v]=M.useState(ics),{scrollSpeed:_,fontSize:b,lineHeight:w,opacity:j,position:N,isMirrored:S}=g,A=M.useCallback((se,te)=>{v(Y=>{const ce={...Y,[se]:te};return ocs(ce),ce})},[]),[I,L]=M.useState(!1),[F,$]=M.useState(null),q=M.useCallback(se=>{if(!i.current)return;u.current===0&&(u.current=se);const te=se-u.current;u.current=se,f.current+=_*te/1e3;const Y=Math.floor(f.current);Y>0&&(i.current.scrollTop+=Y,f.current-=Y);const{scrollTop:ce,scrollHeight:oe,clientHeight:le}=i.current;if(ce+le>=oe){L(!1);return}d.current=requestAnimationFrame(q)},[_]);M.useEffect(()=>(I?(u.current=0,f.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[I,q]),M.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){$(3);let se=3;const te=setInterval(()=>{se-=1,se<=0?(clearInterval(te),$(null),o==null||o(),L(!0)):$(se)},1e3);return()=>clearInterval(te)}else setTimeout(()=>L(!0),100);else n||(L(!1),$(null))},[n,s,a,o]);const H=M.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),U=M.useCallback(()=>{L(se=>!se)},[]);if(!s)return e.jsx("div",{className:It("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(Z,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Na,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const Q={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:It("absolute inset-0 pointer-events-none",l),children:[F!==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:F},F),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:It("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",Q[N],F!==null&&"opacity-30"),style:{opacity:F!==null?.3:j},children:e.jsxs("div",{ref:i,className:It("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",S&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${b}px`,lineHeight:w,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:t}),e.jsx("div",{className:"h-full"})]})}),e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsx(Z,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(Pl,{className:"h-4 w-4"})})}),e.jsx(jo,{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(_e,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),e.jsx(kg,{value:[_],onValueChange:([se])=>A("scrollSpeed",se),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(_e,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b,"px"]})]}),e.jsx(kg,{value:[b],onValueChange:([se])=>A("fontSize",se),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(_e,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w.toFixed(1)})]}),e.jsx(kg,{value:[w*10],onValueChange:([se])=>A("lineHeight",se/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(_e,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(j*100),"%"]})]}),e.jsx(kg,{value:[j*100],onValueChange:([se])=>A("opacity",se/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:N==="top"?"default":"outline",size:"sm",onClick:()=>A("position","top"),children:e.jsx(Tg,{className:"h-4 w-4"})}),e.jsx(Z,{variant:N==="center"?"default":"outline",size:"sm",onClick:()=>A("position","center"),children:e.jsx(K1,{className:"h-4 w-4"})}),e.jsx(Z,{variant:N==="bottom"?"default":"outline",size:"sm",onClick:()=>A("position","bottom"),children:e.jsx(tl,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs",children:"Mirror Mode"}),e.jsx(qr,{checked:S,onCheckedChange:se=>A("isMirrored",se)})]})]})})]}),e.jsx(Z,{variant:"secondary",size:"icon",onClick:U,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:I?e.jsx(mp,{className:"h-4 w-4"}):e.jsx(dl,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"secondary",size:"icon",onClick:H,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(k0,{className:"h-4 w-4"})}),e.jsxs(Z,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Nm,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function lcs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=La(),[o,l]=M.useState(""),[i,d]=M.useState(null),[u,f]=M.useState("levelup"),{data:g,isLoading:v}=jOt(),{data:_,isLoading:b}=kOt(),{data:w,isLoading:j}=NOt(),N=SOt(),S=M.useMemo(()=>_?_.filter($=>{const q=!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())||$.tags.some(U=>U.toLowerCase().includes(o.toLowerCase())),H=!i||$.category_id===i;return q&&H}):[],[_,o,i]),A=M.useMemo(()=>w?w.filter($=>!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())):[],[w,o]),I=$=>{t({title:$.title,text:$.script_text})},L=async $=>{try{await N.mutateAsync($),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},F=v||b||j;return e.jsxs("div",{className:It("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search scripts...",value:o,onChange:$=>l($.target.value),className:"pl-9"})]})}),e.jsxs(Ia,{value:u,onValueChange:$=>f($),className:"flex-1 flex flex-col",children:[e.jsxs(Aa,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(Ts,{value:"levelup",children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(Ts,{value:"my-scripts",children:[e.jsx(Cg,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(Vs,{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(nt,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),g==null?void 0:g.map($=>e.jsx(nt,{variant:i===$.id?"default":"outline",className:"cursor-pointer",onClick:()=>d($.id),children:$.name},$.id))]}),e.jsx(Fi,{className:"flex-1 max-h-[50vh]",children:F?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Un,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:S.map($=>e.jsxs(De,{className:It("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx($t,{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(Vt,{className:"text-sm font-medium truncate",children:$.title}),$.category&&e.jsx(nt,{variant:"secondary",className:"mt-1 text-xs",children:$.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:q=>{q.stopPropagation(),L($)},children:e.jsx(Cg,{className:"h-4 w-4"})}),e.jsx(ei,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]}),e.jsxs(Vs,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[s&&e.jsxs(Z,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Fi,{className:"flex-1 max-h-[50vh]",children:j?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):A.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Cg,{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:A.map($=>e.jsxs(De,{className:It("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx($t,{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(Vt,{className:"text-sm font-medium truncate",children:$.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:$.is_custom?e.jsx(nt,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(ei,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]})]})]})}function ccs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=M.useState(()=>{const i=w5(t);return new Set([i.category])}),l=i=>{o(d=>{const u=new Set(d);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(_e,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(Rs,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:Z2t.map(i=>{const d=Y2t(i.id),u=a.has(i.id),f=d.some(g=>g.id===t);return e.jsxs(Eg,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(Pg,{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:["(",d.length,")"]}),f&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(tl,{className:It("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(Ig,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:d.map(g=>{const v=t===g.id;return e.jsxs("button",{type:"button",onClick:()=>s(g.id),disabled:n,className:It("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",v?"border-primary ring-1 ring-primary/20 bg-primary/5":"border-muted hover:border-muted-foreground/30"),children:[v&&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(ma,{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:g.icon}),e.jsx("span",{className:"text-sm font-medium truncate",children:g.name})]})]},g.id)})})})]},i.id)})}),r&&t!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Will show: "',w5(t).headerText(r),'"']})]})}function gXe({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=M.useState(r.page_template||"default"),[i,d]=M.useState(!1),[u,f]=M.useState(!1),[g,v]=M.useState(r.page_template||"default"),[_,b]=M.useState([]),[w,j]=M.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[N,S]=M.useState(!1),[A,I]=M.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";M.useEffect(()=>{t&&_.length===0&&F()},[t]);const F=async()=>{I(!0);try{const{data:ce,error:oe}=await K.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(oe)throw oe;const le=(ce||[]).map(de=>({id:de.id,name:[de.first_name,de.last_name].filter(Boolean).join(" ")||"Unnamed",email:de.email||null}));b(le)}catch(ce){console.error("Failed to fetch contacts:",ce)}finally{I(!1)}},$=async ce=>{j(ce),S(!1),d(!0);try{const{error:oe}=await K.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(oe)throw oe;ge.success(ce?`Assigned to ${ce.name}`:"Contact removed"),a==null||a()}catch(oe){console.error("Failed to update contact:",oe),ge.error("Failed to update contact")}finally{d(!1)}},q=async ce=>{l(ce),d(!0);try{const{error:oe}=await K.from("agent_videos").update({page_template:ce}).eq("id",r.id);if(oe)throw oe;v(ce),ge.success("Template saved!"),a==null||a()}catch(oe){console.error("Failed to save template:",oe),ge.error("Failed to save template"),l(g)}finally{d(!1)}},H=(w==null?void 0:w.name)||null,U=()=>{const ce=r.title||"Video Message",oe=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},Q=async()=>{if(!r.thumbnail_url){ge.error("Video thumbnail not available yet");return}const ce=U(),oe=`Watch: ${r.title||"Video Message"} ${L}`;try{const le=new Blob([ce],{type:"text/html"}),de=new Blob([oe],{type:"text/plain"}),xe=new ClipboardItem({"text/html":le,"text/plain":de});await navigator.clipboard.write([xe]),ge.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(oe+` `+ce),ge.success("Copied! Paste into your email.")}},se=async()=>{await navigator.clipboard.writeText(L),f(!0),ge.success("Share link copied!"),setTimeout(()=>f(!1),2e3)},te=()=>{const oe=w5(o).headerText(H),le=o==="default"?`Check out this video: ${L}`:`${oe} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(le)}`,"_self")},Y=()=>{const ce=w5(o),oe=ce.headerText(H),le=o==="default"?r.title||"Video Message":oe,de=`${ce.subText} Watch the video: ${L}`,xe=w!=null&&w.email?encodeURIComponent(w.email):"";window.open(`mailto:${xe}?subject=${encodeURIComponent(le)}&body=${encodeURIComponent(de)}`,"_self")};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Po,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Kr,{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(_e,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(No,{open:N,onOpenChange:S,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",role:"combobox","aria-expanded":N,className:"flex-1 justify-between",disabled:i,children:[w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-4 w-4 text-muted-foreground"}),w.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(of,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search contacts..."}),e.jsxs(yf,{children:[e.jsx(vf,{children:A?"Loading...":"No contacts found."}),e.jsx(_f,{children:_.map(ce=>e.jsxs(_m,{value:ce.name,onSelect:()=>$(ce),children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",(w==null?void 0:w.id)===ce.id?"opacity-100":"opacity-0")}),ce.name]},ce.id))})]})]})})]}),w&&e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>$(null),disabled:i,className:"shrink-0",children:e.jsx(Vr,{className:"h-4 w-4"})})]}),w&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',w5(o).headerText(w.name),'"']})]}),e.jsx(ccs,{selectedTemplate:o,onSelect:q,contactName:H,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:L,readOnly:!0,className:"font-mono text-sm"}),e.jsx(Z,{onClick:se,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ni,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Share for Email"}),e.jsxs(Z,{variant:"outline",className:"w-full gap-2",onClick:Q,children:[e.jsx(Xo,{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(_e,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Z,{variant:"outline",className:"flex-1 gap-2",onClick:te,children:[e.jsx(ho,{className:"h-4 w-4"}),"Text"]}),e.jsxs(Z,{variant:"outline",className:"flex-1 gap-2",onClick:Y,children:[e.jsx(Ar,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(qn,{children:e.jsx(Z,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function dcs(){var rt;const t=Or(),[s]=Gc(),{toast:r}=La(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d}=fGe(),{data:u}=Im(),f=XN(),g=EOt(),[v,_]=M.useState("record"),[b,w]=M.useState(""),[j,N]=M.useState(!1),[S,A]=M.useState(!1),[I,L]=M.useState(!1),[F,$]=M.useState(null),[q,H]=M.useState(0),[U,Q]=M.useState(0),[se,te]=M.useState(null),[Y,ce]=M.useState(null),[oe,le]=M.useState(n||""),[de,xe]=M.useState(""),[be,ye]=M.useState(""),[ve,ke]=M.useState(null),[Ge,Ne]=M.useState(null),[Ae,Pe]=M.useState(null),[Fe,Ie]=M.useState(!1),Ve=M.useCallback(async(je,mt)=>{$(je),_("uploading");try{const{videoId:He,uploadUrl:ct}=await EL(de||"Quick Video Touch");te(He);const{apiKey:We}=await PL(He),Ze=new XMLHttpRequest;Ze.upload.onprogress=Je=>{Je.lengthComputable&&H(Je.loaded/Je.total*100)},await new Promise((Je,Lt)=>{Ze.onload=()=>{Ze.status>=200&&Ze.status<300?Je():Lt(new Error(`Upload failed: ${Ze.status}`))},Ze.onerror=()=>Lt(new Error("Upload failed")),Ze.open("PUT",ct),Ze.setRequestHeader("AccessKey",We),Ze.send(je)}),_("processing");let ht=0;const Ke=Date.now(),qe=90*1e3;for(;ht<4;){if(await new Promise(Lt=>setTimeout(Lt,3e3)),Date.now()-Ke>qe){const Lt=je.size/1048576,zt=`https://iframe.mediadelivery.net/play/${He}/${He}`;await f.mutateAsync({bunny_video_id:He,playback_url:zt,file_size_mb:Lt,title:de||"Quick Video Touch",notes:be||void 0,contact_id:oe&&oe!=="none"?oe: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 Je=await y3(He);if(ht=Je.status,Q(Je.encodeProgress||0),ht===4)ce({playbackUrl:Je.directPlayUrl,thumbnailUrl:Je.thumbnailUrl,previewUrl:Je.previewUrl||null,duration:Je.length||mt,fileSizeMb:(Je.storageSize||je.size)/(1024*1024)});else if(ht===5||ht===6)throw new Error("Video processing failed")}_("details")}catch(He){console.error("Upload error:",He),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),_("record")}},[de,r]),dt=async()=>{if(!(!se||!Y))try{const je=oe&&oe!=="none"?oe:null,mt=await f.mutateAsync({bunny_video_id:se,contact_id:je,playback_url:Y.playbackUrl,thumbnail_url:Y.thumbnailUrl,preview_url:Y.previewUrl,duration_seconds:Y.duration,file_size_mb:Y.fileSizeMb,title:de||"Quick Video Touch",notes:be,task_id:a||null,status:"ready"});ke(mt.id),Ne(mt.share_token||null),je&&await g.mutateAsync({contactId:je,videoId:mt.id,notes:be}),r({title:"Video saved successfully!"}),_("share")}catch(je){console.error("Save video error:",je),r({title:"Failed to save video",description:(je==null?void 0:je.message)||"Please try again.",variant:"destructive"})}},Le=(je,mt)=>{navigator.clipboard.writeText(mt),Pe(je),setTimeout(()=>Pe(null),2e3),r({title:"Copied to clipboard!"})},Rt=()=>Ge?`https://video.relevelup.com/${Ge}`:(Y==null?void 0:Y.playbackUrl)||"",fe=()=>{const je=u==null?void 0:u.find(Ze=>Ze.id===oe),mt=je?`${je.first_name}`:"",He=(je==null?void 0:je.phone)||"",ct=(je==null?void 0:je.email)||"",We=Rt();return{text:`Hey${mt?` ${mt}`:""}! I recorded a quick video for you: ${We}`,link:We,contactPhone:He,contactEmail:ct}},Qe=()=>{const{text:je,contactPhone:mt}=fe(),He=mt?`sms:${mt}?body=${encodeURIComponent(je)}`:`sms:?body=${encodeURIComponent(je)}`;window.open(He,"_self")},at=()=>{const{link:je,contactEmail:mt}=fe(),He="Check out this video",ct=`I recorded a quick video for you: ${je}`,We=mt?`mailto:${mt}?subject=${encodeURIComponent(He)}&body=${encodeURIComponent(ct)}`:`mailto:?subject=${encodeURIComponent(He)}&body=${encodeURIComponent(ct)}`;window.open(We,"_self")};return o?e.jsx(Ms,{title:"Quick Video Touch",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(Z,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(Ba,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Quick Video Touch"}),e.jsx("p",{className:"text-muted-foreground",children:"Record a personal video message"})]})]}),d&&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"]})]})]}),v==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(pce,{maxDurationSeconds:60,onRecordingComplete:Ve,onRecordingStateChange:L,className:"w-full",teleprompterContent:j&&b&&e.jsx(fXe,{text:b,isVisible:j,onToggleVisibility:()=>N(!1),isRecording:I,startCountdown:!0})}),!j&&b&&e.jsxs(Z,{variant:"outline",className:"mt-4",onClick:()=>N(!0),children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(De,{className:"lg:col-span-1",children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Lr,{placeholder:"Type or paste your script here...",value:b,onChange:je=>w(je.target.value),rows:6}),e.jsxs(uL,{open:S,onOpenChange:A,children:[e.jsx(W1e,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:"w-full",children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(lM,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(hL,{className:"p-4 border-b",children:e.jsx(mL,{children:"Select a Script"})}),e.jsx(lcs,{onSelectScript:je=>{w(je.text),A(!1),N(!0)},className:"h-[calc(100vh-80px)]"})]})]}),b&&e.jsx(Z,{className:"w-full",onClick:()=>N(!0),children:"Use Script"})]})]})]}),v==="uploading"&&e.jsx(De,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center",children:[e.jsx(xi,{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(wo,{value:q,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[q.toFixed(0),"%"]})]})}),v==="processing"&&e.jsx(De,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center space-y-4",children:[e.jsx(Rs,{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(wo,{value:U,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[U.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.`})]})}),v==="details"&&e.jsxs(De,{className:"max-w-lg mx-auto",children:[e.jsx($t,{children:e.jsx(Vt,{children:"Video Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Re,{value:de,onChange:je=>xe(je.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Attach to Contact (Optional)"}),e.jsxs(tr,{value:oe,onValueChange:le,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"No contact - use anywhere"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Po,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(je=>e.jsx(At,{value:je.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-4 w-4"}),je.first_name," ",je.last_name]})},je.id))]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Notes"}),e.jsx(Lr,{value:be,onChange:je=>ye(je.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(Z,{className:"w-full",onClick:dt,disabled:f.isPending,children:[f.isPending&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),v==="share"&&e.jsxs(De,{className:"max-w-lg mx-auto",children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(ma,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(Z,{variant:"outline",className:"justify-start",onClick:Qe,children:[e.jsx(ho,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(Z,{variant:"outline",className:"justify-start",onClick:at,children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(Z,{variant:"outline",className:"justify-start",onClick:()=>Le("link",fe().link),children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Ae==="link"&&e.jsx(ma,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(Z,{variant:"outline",className:"justify-start",onClick:()=>Ie(!0),children:[e.jsx(El,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(Z,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(Z,{onClick:()=>{_("record"),$(null),te(null),ce(null)},children:"Record Another"})]})]})]}),ve&&Ge&&e.jsx(gXe,{open:Fe,onOpenChange:Ie,video:{id:ve,share_token:Ge,title:de||null,contact_id:oe||null,thumbnail_url:(Y==null?void 0:Y.thumbnailUrl)||null},contactName:((rt=u==null?void 0:u.find(je=>je.id===oe))==null?void 0:rt.first_name)||null})]})}):e.jsx(Ms,{title:"Quick Video Touch",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(jh,{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(Z,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function ucs({open:t,onOpenChange:s}){const{data:r}=Im(),{data:n}=fle(),a=XN(),o=M.useRef(null),[l,i]=M.useState(null),[d,u]=M.useState(""),[f,g]=M.useState(""),[v,_]=M.useState(""),[b,w]=M.useState(!1),[j,N]=M.useState(0),[S,A]=M.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,F=((n==null?void 0:n.max_storage_mb)||1024)-I,$=Q=>{var Y;const se=(Y=Q.target.files)==null?void 0:Y[0];if(!se)return;if(!se.type.startsWith("video/")){ge.error("Please select a video file");return}const te=se.size/(1024*1024);if(te>500){ge.error("Video file must be less than 500MB");return}if(te>F){ge.error(`Not enough storage. You have ${F.toFixed(1)} MB remaining.`);return}i(se),d||u(se.name.replace(/\.[^/.]+$/,""))},q=async()=>{if(!l){ge.error("Please select a video file");return}w(!0),N(0),A("creating");try{const{data:Q,error:se}=await K.functions.invoke("bunny-upload",{body:{action:"create",title:d||l.name,isAgentVideo:!0}});if(se)throw new Error(se.message);const{videoId:te,libraryId:Y}=Q;A("uploading");const{data:ce,error:oe}=await K.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:te,isAgentVideo:!0}});if(oe)throw new Error(oe.message);await new Promise((xe,be)=>{const ye=new XMLHttpRequest;ye.upload.addEventListener("progress",ve=>{if(ve.lengthComputable){const ke=Math.round(ve.loaded/ve.total*100);N(ke)}}),ye.addEventListener("load",()=>{ye.status>=200&&ye.status<300?xe():be(new Error(`Upload failed with status ${ye.status}`))}),ye.addEventListener("error",()=>be(new Error("Upload failed"))),ye.open("PUT",ce.uploadUrl),ye.setRequestHeader("AccessKey",ce.apiKey),ye.send(l)}),A("processing");const le=l.size/(1024*1024),de=`https://iframe.mediadelivery.net/embed/${Y}/${te}`;await a.mutateAsync({bunny_video_id:te,playback_url:de,file_size_mb:le,title:d||l.name,notes:f||void 0,contact_id:v||void 0,status:"processing",touch_type:"video_upload"}),ge.success("Video uploaded successfully! Processing may take a few minutes."),H()}catch(Q){console.error("Upload error:",Q),ge.error(Q instanceof Error?Q.message:"Failed to upload video")}finally{w(!1),A("idle")}},H=()=>{b||(i(null),u(""),g(""),_(""),N(0),A("idle"),s(!1))},U=()=>{switch(S){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${j}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(bs,{open:t,onOpenChange:H,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Upload Video"}),e.jsx(Kr,{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(_e,{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"]})]}),!b&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Q=>{Q.stopPropagation(),i(null)},children:e.jsx(Vr,{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=o.current)==null?void 0:Q.click()},children:[e.jsx(xi,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:o,type:"file",accept:"video/*",className:"hidden",onChange:$,disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",value:d,onChange:Q=>u(Q.target.value),placeholder:"Enter video title",disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Associate with Contact (optional)"}),e.jsxs(tr,{value:v||"__none__",onValueChange:Q=>_(Q==="__none__"?"":Q),disabled:b,children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select a contact"})}),e.jsxs(er,{children:[e.jsx(At,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(Q=>e.jsxs(At,{value:Q.id,children:[Q.first_name," ",Q.last_name||""]},Q.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Lr,{id:"notes",value:f,onChange:Q=>g(Q.target.value),placeholder:"Add any notes about this video",rows:2,disabled:b})]}),b&&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(Rs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:U()})]}),e.jsx(wo,{value:S==="uploading"?j:S==="processing"?100:10})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:H,disabled:b,children:"Cancel"}),e.jsx(Z,{onClick:q,disabled:!l||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function hcs(t){return Tt({queryKey:["video-share-recipients",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("video_share_recipients").select("*").eq("video_id",t).order("sent_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function mcs(){const{user:t}=Qs();return Tt({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 K.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 pcs(){const{user:t}=Qs();return Tt({queryKey:["video-share-history",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await K.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 fcs(){const{user:t}=Qs(),s=ds();return Bt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await K.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 gcs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function xcs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function ycs({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=M.useState([]),[d,u]=M.useState(null),[f,g]=M.useState(!1),[v,_]=M.useState(!1),[b,w]=M.useState(""),[j,N]=M.useState(""),[S,A]=M.useState(""),[I,L]=M.useState(!1),F=fcs(),$=r.share_token?`https://video.relevelup.com/share/video/${r.share_token}`:"",q=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",H=r.title||"Video Message";M.useEffect(()=>{t&&l.length===0&&U()},[t]),M.useEffect(()=>{if(t&&(N(`I recorded a video for you — ${H}`),A("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),w(""),r.contact_id)){const oe=l.find(le=>le.id===r.contact_id);oe&&(u(oe),w(oe.email||""))}},[t,r.contact_id,l]);const U=async()=>{_(!0);try{const{data:oe,error:le}=await K.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(le)throw le;i(oe||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},Q=oe=>{u(oe),g(!1),w(oe.email||""),A(`Hey ${oe.first_name}! I recorded a quick video just for you. Click below to watch it:`),N(`I recorded a video for you — ${H}`)},se=()=>{u(null),w(""),A("Hey! I recorded a quick video just for you. Click below to watch it:")},te=oe=>`${oe.first_name} ${oe.last_name||""}`.trim(),Y=oe=>{const le=S.split(/\n\n+/).map(be=>`

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

`).join(""),de=oe?xcs(oe):$,xe=oe?``:"";return`
${le}

▶ Watch Video

${xe}
`},ce=async()=>{if(!b){ge.error("Please enter a recipient email");return}if(!$){ge.error("Video does not have a share link");return}L(!0);try{let oe;try{const be=d?te(d):b.split("@")[0];oe=(await F.mutateAsync({video_id:r.id,recipient_email:b,recipient_name:be,contact_id:(d==null?void 0:d.id)||null,sent_via:"gmail"})).share_token}catch(be){console.warn("Failed to create tracking record, sending without tracking:",be)}const le=Y(oe),{data:de,error:xe}=await K.functions.invoke("gmail-send",{body:{to:b,subject:j,body:le,contactId:(d==null?void 0:d.id)||null}});if(xe)throw xe;if(!(de!=null&&de.success))throw new Error((de==null?void 0:de.error)||"Failed to send");ge.success("Video email sent!"),s(!1),o==null||o()}catch(oe){console.error("Gmail send error:",oe),ge.error("Failed to send: "+(oe instanceof Error?oe.message:"Unknown error"))}finally{L(!1)}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Ar,{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(_e,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(No,{open:f,onOpenChange:g,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-4 w-4 text-muted-foreground"}),te(d),d.email&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",d.email,")"]})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(of,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[350px] p-0",align:"start",children:e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search contacts..."}),e.jsxs(yf,{children:[e.jsx(vf,{children:v?"Loading...":"No contacts found."}),e.jsx(_f,{children:l.filter(oe=>oe.email).map(oe=>e.jsxs(_m,{value:`${oe.first_name} ${oe.last_name||""} ${oe.email||""}`,onSelect:()=>Q(oe),children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",(d==null?void 0:d.id)===oe.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:te(oe)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:oe.email})]})]},oe.id))})]})]})})]}),d&&e.jsx(Z,{variant:"ghost",size:"icon",onClick:se,className:"shrink-0",children:e.jsx(Vr,{className:"h-4 w-4"})})]})]}),!d&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(Re,{id:"video-to",value:b,onChange:oe=>w(oe.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(Jl,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Re,{id:"video-subject",value:j,onChange:oe=>N(oe.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Lr,{id:"video-message",value:S,onChange:oe=>A(oe.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(_e,{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:[q?e.jsx("img",{src:q,alt:H,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(dl,{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(dl,{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(Z,{variant:"outline",onClick:()=>s(!1),disabled:I,children:"Cancel"}),e.jsxs(Z,{onClick:ce,disabled:I||!b||!j,className:"gap-2",children:[I?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(Pa,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const vcs=()=>{const{user:t}=Qs();return Tt({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function _cs({recipient:t}){return t.watched_at?e.jsxs(nt,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(dl,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(nt,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(ym,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(nt,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(Na,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(nt,{variant:"outline",className:"text-[10px]",children:[e.jsx(Pa,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function bcs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=hcs(r);return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(Cs,{children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(ol,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(gs,{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(Fi,{className:"h-[400px]",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"Recipient"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Sent"}),e.jsx(kt,{children:"Last Activity"})]})}),e.jsx(Ln,{children:a.map(l=>e.jsxs(ks,{children:[e.jsx(lt,{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(lt,{children:e.jsx(_cs,{recipient:l})}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:js(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?$d(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function wcs(){const{data:t,isLoading:s}=mcs(),{data:r=[],isLoading:n}=pcs(),[a,o]=M.useState(null),l=s||n,i=r.reduce((d,u)=>{const f=u.agent_videos,g=(f==null?void 0:f.id)||u.video_id;return d[g]||(d[g]={videoId:g,title:(f==null?void 0:f.title)||"Untitled",thumbnailUrl:f==null?void 0:f.thumbnail_url,recipients:[]}),d[g].recipients.push(u),d},{});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((d,u)=>e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(gs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(gs,{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(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(Na,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.openRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalOpened)||0," opened"]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(ym,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.clickRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalClicked)||0," clicked"]})]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(_r,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Oe,{children:Object.keys(i).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No tracked sends yet. Send a video via Gmail to start tracking."}):e.jsx("div",{className:"space-y-2",children:Object.values(i).map(d=>{const u=d.recipients.filter(g=>g.opened_at).length,f=d.recipients.filter(g=>g.clicked_at).length;return e.jsxs("button",{onClick:()=>o({id:d.videoId,title:d.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:d.thumbnailUrl?e.jsx("img",{src:d.thumbnailUrl,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",onError:g=>{const v=g.currentTarget;v.style.display="none",v.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:d.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(Pa,{className:"h-3 w-3"})," ",d.recipients.length]}),e.jsxs("span",{className:"text-xs text-amber-600 flex items-center gap-1",children:[e.jsx(Na,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(ym,{className:"h-3 w-3"})," ",f]})]})]}),e.jsx(Vc,{className:"h-4 w-4 text-muted-foreground"})]},d.videoId)})})})]}),e.jsx(bcs,{open:!!a,onOpenChange:d=>!d&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function jcs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=M.useState(!1),[l,i]=M.useState(!1),d=n&&t&&!a,u=s&&!l;return!u&&!d?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 ${d?"opacity-0":"opacity-100"}`,onError:()=>i(!0)}),d&&e.jsx("img",{src:t,alt:r,className:"w-full h-full object-cover absolute inset-0",onError:()=>o(!0)})]})}function kcs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:u,onShareWithTemplate:f,onSendViaGmail:g,isGmailConnected:v,getContactName:_,getShareUrl:b,copyToClipboard:w,formatDuration:j}){const[N,S]=M.useState(!1);return e.jsxs(De,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(jcs,{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(dl,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:j(t.duration_seconds)}),t.status!=="ready"&&e.jsx(nt,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(mo,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:_(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(Tn,{className:"h-3 w-3"}),e.jsx("span",{children:js(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(Na,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),v&&t.share_token&&e.jsxs(Z,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:A=>{A.stopPropagation(),g==null||g()},children:[e.jsx(Ar,{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(mo,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:_(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(Tn,{className:"h-3 w-3"}),e.jsx("span",{children:js(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(Na,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:A=>A.stopPropagation(),children:e.jsx(xg,{className:"h-4 w-4"})})}),e.jsxs(mu,{align:"end",className:"bg-popover",children:[e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),n()},children:[e.jsx(Na,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(g_,{}),e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),f()},children:[e.jsx(El,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),w(b(t),"Share link")},children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),i()},children:[e.jsx(Vk,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),d()},children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),u()},children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),v&&t.share_token&&e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),g==null||g()},children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),o()},children:[e.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(g_,{}),t.contact_id&&e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),l()},children:[e.jsx(mo,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Wa,{onClick:A=>{A.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(Cr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function Ncs(){var Je,Lt;const t=Or(),{data:s,isLoading:r,refetch:n}=COt(),{data:a}=fle(),{data:o}=Im(),l=AOt(),i=TOt(),{isGmailConnected:d,gmailEmail:u}=G0(),{data:f}=Ug(),{data:g=[],isLoading:v}=vcs(),[_,b]=M.useState("my"),[w,j]=M.useState(""),[N,S]=M.useState(null),[A,I]=M.useState(!1),[L,F]=M.useState(!1),[$,q]=M.useState(!1),[H,U]=M.useState(!1),[Q,se]=M.useState(!1),[te,Y]=M.useState(""),[ce,oe]=M.useState(!1),[le,de]=M.useState(!1),[xe,be]=M.useState(!1),[ye,ve]=M.useState(!1),[ke,Ge]=M.useState(""),[Ne,Ae]=M.useState({}),Pe=zt=>{if(!zt)return"Unassigned";const is=o==null?void 0:o.find(Kt=>Kt.id===zt);return is?`${is.first_name} ${is.last_name||""}`.trim():"Unknown"},Fe=zt=>{if(!zt)return"0:00";const is=Math.floor(zt/60),Kt=zt%60;return`${is}:${Kt.toString().padStart(2,"0")}`},Ie=s==null?void 0:s.filter(zt=>{if(!w)return!0;const is=Pe(zt.contact_id).toLowerCase(),Kt=(zt.title||"").toLowerCase(),Qt=(zt.notes||"").toLowerCase();return is.includes(w.toLowerCase())||Kt.includes(w.toLowerCase())||Qt.includes(w.toLowerCase())}),[Ve,dt]=M.useState(!1);M.useEffect(()=>{if(Ve)return;(async()=>{if(!(s!=null&&s.length))return;const is=s.filter(Qt=>Qt.status==="processing"&&Qt.bunny_video_id);if(!is.length)return;let Kt=!1;for(const Qt of is)try{const{data:fs,error:dr}=await K.functions.invoke("bunny-upload",{body:{action:"status",videoId:Qt.bunny_video_id,isAgentVideo:!0}});if(dr||!fs)continue;fs.status===4&&(await K.from("agent_videos").update({status:"ready",playback_url:fs.directPlayUrl,thumbnail_url:fs.thumbnailUrl,preview_url:fs.previewUrl,duration_seconds:fs.length||Qt.duration_seconds,updated_at:new Date().toISOString()}).eq("id",Qt.id),Kt=!0)}catch(fs){console.warn("Reconcile check failed for video",Qt.id,fs)}dt(!0),Kt&&n()})()},[s,Ve,n]),M.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const is=s.filter(bt=>(bt==null?void 0:bt.bunny_video_id)&&!Ne[bt.id]);if(!is.length)return;const Kt=is.map(bt=>bt.bunny_video_id),{data:Qt,error:fs}=await K.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Kt,isAgentVideo:!0}});if(fs)throw fs;const dr=(Qt==null?void 0:Qt.assets)||{};Ae(bt=>{const ws={...bt};for(const ir of is)dr[ir.bunny_video_id]&&(ws[ir.id]={previewUrl:dr[ir.bunny_video_id].previewUrl,thumbnailUrl:dr[ir.bunny_video_id].thumbnailUrl});return ws})})().catch(is=>console.warn("Failed to load signed Bunny asset URLs",is))},[s,Ne]);const Le=(a==null?void 0:a.total_storage_mb)||0,Rt=(a==null?void 0:a.max_storage_mb)||1024,fe=Le/Rt*100,Qe=fe>=80,at=fe>=100,rt=async(zt,is)=>{await navigator.clipboard.writeText(zt),ge.success(`${is} copied to clipboard`)},je=zt=>zt.share_token?`https://video.relevelup.com/${zt.share_token}`:zt.playback_url||"",mt=zt=>{const is=je(zt),Kt=o==null?void 0:o.find(ir=>ir.id===zt.contact_id),Qt=Pe(zt.contact_id),fs=Qt!=="Unassigned"?Qt.split(" ")[0]:"",dr=(Kt==null?void 0:Kt.phone)||"",bt=`Hey${fs?` ${fs}`:""}! I recorded a quick video message for you. Check it out: ${is}`,ws=dr?`sms:${dr}?body=${encodeURIComponent(bt)}`:`sms:?body=${encodeURIComponent(bt)}`;window.open(ws,"_self")},He=zt=>{const is=o==null?void 0:o.find(ws=>ws.id===zt.contact_id),Kt=(is==null?void 0:is.email)||"",Qt=je(zt),fs="Check out this video",dr=`I recorded a quick video for you: ${Qt}`,bt=Kt?`mailto:${Kt}?subject=${encodeURIComponent(fs)}&body=${encodeURIComponent(dr)}`:`mailto:?subject=${encodeURIComponent(fs)}&body=${encodeURIComponent(dr)}`;window.open(bt,"_self")},ct=zt=>{var fs;const is=je(zt),Kt=zt.title||"Video Message",Qt=zt.share_token?`https://video.relevelup.com/thumb/${zt.share_token}`:((fs=Ne[zt.id])==null?void 0:fs.thumbnailUrl)||zt.thumbnail_url||"";return``},We=async zt=>{if(!zt.thumbnail_url&&!zt.share_token){ge.error("Video thumbnail not available yet");return}const is=ct(zt),Kt=je(zt),Qt=`Watch: ${zt.title||"Video Message"} ${Kt}`;try{const fs=new Blob([is],{type:"text/html"}),dr=new Blob([Qt],{type:"text/plain"}),bt=new ClipboardItem({"text/html":fs,"text/plain":dr});await navigator.clipboard.write([bt]),ge.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(Qt+` `+is),ge.success("Copied! Paste into your email.")}},Ze=async zt=>{try{ge.loading("Preparing download...",{id:"download"});const{data:is,error:Kt}=await K.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:zt.bunny_video_id,isAgentVideo:!0}});if(Kt||!(is!=null&&is.downloadUrl))throw new Error((Kt==null?void 0:Kt.message)||"Failed to get download URL");const fs=`${((zt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,dr=await fetch(is.downloadUrl);if(!dr.ok)throw new Error("Failed to fetch video file");const bt=await dr.blob(),ws=URL.createObjectURL(bt),ir=document.createElement("a");ir.href=ws,ir.download=fs,ir.rel="noreferrer",document.body.appendChild(ir),ir.click(),ir.remove(),URL.revokeObjectURL(ws),ge.success("Download started",{id:"download"})}catch(is){console.error("Download error:",is),ge.error("Could not force download (your browser may block it).",{id:"download"})}},ht=async zt=>{S(zt),oe(!0),Y(""),se(!0);try{const{data:is,error:Kt}=await K.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:zt.bunny_video_id,title:zt.title,isAgentVideo:!0,shareToken:zt.share_token}});if(Kt||!(is!=null&&is.html))throw new Error("Failed to generate CRM embed code");Y(is.html)}catch(is){console.error("CRM embed error:",is),ge.error("Failed to generate CRM embed code"),se(!1)}finally{oe(!1)}},Ke=zt=>{S(zt),I(!0)},qe=async()=>{if(N)try{await l.mutateAsync({id:N.id,bunnyVideoId:N.bunny_video_id,hardDelete:!0}),F(!1),S(null),ge.success("Video deleted successfully")}catch{ge.error("Failed to delete video")}};return e.jsx(Ms,{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:()=>b("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${_==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),f&&((Je=f.team)==null?void 0:Je.shared_videos_enabled)&&e.jsxs("button",{onClick:()=>b("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${_==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(xr,{className:"h-3.5 w-3.5"}),"Team"]}),e.jsxs("button",{onClick:()=>b("analytics"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${_==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ol,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),_==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Z,{variant:"outline",onClick:()=>q(!0),children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(Z,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?e.jsx(Scs,{videos:g,isLoading:v,searchTerm:w,setSearchTerm:j}):_==="analytics"?e.jsx(wcs,{}):e.jsxs(e.Fragment,{children:[e.jsx(De,{className:Qe?"border-amber-500":at?"border-destructive":"",children:e.jsxs(Oe,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(WE,{className:`h-5 w-5 ${at?"text-destructive":Qe?"text-amber-500":"text-muted-foreground"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Storage Used"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[Le.toFixed(1)," MB / ",Rt>=1024?`${(Rt/1024).toFixed(0)} GB`:`${Rt} MB`]})]}),e.jsx(wo,{value:Math.min(fe,100),className:`h-2 ${at?"[&>div]:bg-destructive":Qe?"[&>div]:bg-amber-500":""}`})]}),Qe&&!at&&e.jsxs(nt,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(Yo,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),at&&e.jsxs(nt,{variant:"destructive",children:[e.jsx(Yo,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),at&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:"You've reached your storage limit. Delete videos to record more."})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search videos by contact, title, or notes...",value:w,onChange:zt=>j(zt.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"})}):(Ie==null?void 0:Ie.length)===0?e.jsx(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Cn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No videos yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Record your first video touch to get started"}),e.jsxs(Z,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Ys,{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:Ie==null?void 0:Ie.map(zt=>{var is,Kt;return e.jsx(kcs,{video:zt,previewSrc:(is=Ne[zt.id])==null?void 0:is.previewUrl,thumbnailSrc:(Kt=Ne[zt.id])==null?void 0:Kt.thumbnailUrl,onOpen:()=>Ke(zt),onDelete:()=>{S(zt),F(!0)},onRename:()=>{S(zt),Ge(zt.title||""),ve(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${zt.contact_id}`),onGetEmbedCode:()=>{S(zt),U(!0)},onCopyEmailHtml:()=>We(zt),onEmbedToCrm:()=>ht(zt),onShareWithTemplate:()=>{S(zt),de(!0)},onSendViaGmail:()=>{S(zt),be(!0)},isGmailConnected:d,getContactName:Pe,getShareUrl:je,copyToClipboard:rt,formatDuration:Fe},zt.id)})}),e.jsx(bs,{open:A,onOpenChange:I,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:(N==null?void 0:N.title)||"Video Preview"}),e.jsx(Kr,{children:(N==null?void 0:N.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mo,{className:"h-3 w-3"}),Pe(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(Rs,{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(Z,{variant:"outline",size:"sm",onClick:()=>{I(!1),n()},children:[e.jsx(Ao,{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 zt=N.playback_url;return zt.includes("iframe.mediadelivery.net/play/")&&(zt=zt.replace("/play/","/embed/"),zt+=(zt.includes("?")?"&":"?")+"autoplay=false&responsive=true"),zt.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:zt,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:()=>ge.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(Z,{variant:"outline",onClick:()=>mt(N),children:[e.jsx(ho,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(Z,{variant:"outline",onClick:()=>He(N),children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(Z,{variant:"outline",onClick:()=>rt(je(N),"Share link"),children:[e.jsx(Ni,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Z,{variant:"outline",onClick:()=>We(N),children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Z,{variant:"outline",onClick:()=>Ze(N),children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(Z,{variant:"outline",onClick:()=>{I(!1),ht(N)},children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(Z,{variant:"outline",onClick:()=>{I(!1),de(!0)},children:[e.jsx(El,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(N==null?void 0:N.share_token)&&e.jsxs(Z,{variant:"outline",onClick:()=>{I(!1),be(!0)},children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(Z,{variant:"destructive",onClick:()=>{I(!1),F(!0)},children:[e.jsx(Cr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(bs,{open:L,onOpenChange:F,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Delete Video"}),e.jsx(Kr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),e.jsx(Z,{variant:"destructive",onClick:qe,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(ucs,{open:$,onOpenChange:q}),e.jsx(bs,{open:H,onOpenChange:U,children:e.jsxs(_s,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Embed Video"}),e.jsx(Kr,{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(_e,{children:"Embed Code"}),e.jsx(Lr,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(Z,{className:"flex-1",onClick:()=>{const zt=``;rt(zt,"Embed code")},children:[e.jsx(Ni,{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(gXe,{open:le,onOpenChange:de,video:N,contactName:Pe(N.contact_id)}),N&&e.jsx(ycs,{open:xe,onOpenChange:be,video:N,gmailEmail:u,signedThumbnailUrl:(Lt=Ne[N.id])==null?void 0:Lt.thumbnailUrl}),e.jsx(bs,{open:ye,onOpenChange:ve,children:e.jsxs(_s,{className:"max-w-sm",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Rename Video"}),e.jsx(Kr,{children:"Enter a new title for this video."})]}),e.jsx(Re,{value:ke,onChange:zt=>Ge(zt.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:zt=>{zt.key==="Enter"&&ke.trim()&&i.mutate({id:N.id,title:ke.trim()},{onSuccess:()=>{ge.success("Video renamed"),ve(!1)}})}}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>ve(!1),children:"Cancel"}),e.jsx(Z,{disabled:!ke.trim()||i.isPending,onClick:()=>{i.mutate({id:N.id,title:ke.trim()},{onSuccess:()=>{ge.success("Video renamed"),ve(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(bs,{open:Q,onOpenChange:se,children:e.jsxs(_s,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(Kr,{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(Rs,{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(_e,{children:"CRM Email HTML"}),e.jsx(Lr,{readOnly:!0,rows:12,value:te,className:"font-mono text-xs"})]}),e.jsxs(Z,{className:"w-full",onClick:()=>{rt(te,"CRM embed code")},children:[e.jsx(Ni,{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 Scs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=M.useMemo(()=>{if(!r)return t;const i=r.toLowerCase();return t.filter(d=>(d.title||"").toLowerCase().includes(i)||(d.owner_name||"").toLowerCase().includes(i)||(d.recipient_name||"").toLowerCase().includes(i))},[t,r]),o=M.useMemo(()=>{const i=new Map;return a.forEach(d=>{const u=i.get(d.owner_user_id);u?u.videos.push(d):i.set(d.owner_user_id,{name:d.owner_name,avatar:d.owner_avatar_url,videos:[d]})}),Array.from(i.entries())},[a]),l=i=>{if(!i)return"0:00";const d=Math.floor(i/60),u=i%60;return`${d}:${u.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{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(De,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(xr,{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,d])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(mn,{className:"h-7 w-7",children:[e.jsx(ba,{src:d.avatar||""}),e.jsx(pn,{children:(d.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:d.name}),e.jsx(nt,{variant:"secondary",className:"text-xs",children:d.videos.length})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:d.videos.map(u=>e.jsxs(De,{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:f=>{f.target.style.display="none"}}):e.jsx(Cn,{className:"h-10 w-10 text-muted-foreground"}),u.duration_seconds&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:l(u.duration_seconds)})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:u.title||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[u.recipient_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mo,{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(Na,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),js(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const Ccs=()=>{const{user:t}=Qs();return Tt({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},KIe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Mcs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Ccs(),[a,o]=M.useState(""),[l,i]=M.useState("all"),d=M.useMemo(()=>{if(!r)return new Map;const b=new Map;let w=0;return r.forEach(j=>{b.has(j.owner_user_id)||(b.set(j.owner_user_id,{name:j.owner_name||"Unknown",avatar:j.owner_avatar_url,color:KIe[w%KIe.length]}),w++)}),b},[r]),u=M.useMemo(()=>Array.from(d.entries()).map(([b,w])=>({id:b,...w})),[d]),f=M.useMemo(()=>{if(!r)return[];let b=r;if(l!=="all"&&(b=b.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();b=b.filter(j=>{var N,S,A,I;return j.deal_name.toLowerCase().includes(w)||((N=j.contact_name)==null?void 0:N.toLowerCase().includes(w))||((S=j.property_address)==null?void 0:S.toLowerCase().includes(w))||((A=j.city)==null?void 0:A.toLowerCase().includes(w))||((I=j.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return b},[r,a,l]),g=M.useMemo(()=>{const b=new Map;return f.forEach(w=>{const j=w.stage_name||"Unknown";b.has(j)||b.set(j,{name:j,color:w.stage_color,icon:w.stage_icon,deals:[],totalValue:0});const N=b.get(j);N.deals.push(w),N.totalValue+=w.sale_price||0}),Array.from(b.values())},[f]),v=b=>b>=1e6?`$${(b/1e6).toFixed(1)}M`:b>=1e3?`$${(b/1e3).toFixed(0)}K`:`$${b.toFixed(0)}`,_=b=>b?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(b):null;return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(Cs,{children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(xr,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search deals...",value:a,onChange:b=>o(b.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:l,onValueChange:i,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"All Members"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Members"}),u.map(b=>e.jsx(At,{value:b.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:b.color}}),b.name]})},b.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(b=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:b.color}}),b.name.split(" ")[0]]},b.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(b=>e.jsxs("div",{className:"min-w-[260px] flex-1",children:[e.jsx(gs,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(gs,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(gs,{className:"h-24 w-full rounded-lg"})]},b))}):g.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(xr,{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:g.map(b=>{const w=b.icon&&Bve[b.icon]||qc;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:b.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:b.color?`${b.color}20`:void 0},children:e.jsx(w,{className:"h-3.5 w-3.5",style:{color:b.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:b.name})]}),e.jsx(nt,{variant:"secondary",className:"text-xs px-2",children:b.deals.length})]}),b.totalValue>0&&e.jsx("p",{className:"text-xs text-muted-foreground ml-8",children:v(b.totalValue)})]}),e.jsx(Fi,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(j=>{const N=d.get(j.owner_user_id);return e.jsx(Tcs,{deal:j,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:_},j.id)})})})]},b.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[f.length," deal",f.length!==1?"s":""," across ",g.length," stage",g.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function Tcs({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(mn,{className:"h-4 w-4",children:[e.jsx(ba,{src:n||""}),e.jsx(pn,{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(nt,{variant:"outline",className:It("text-[10px] px-1.5 py-0 shrink-0",l.className),children:l.label})]}),t.contact_name&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.contact_name}),(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Hn,{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(Uc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function Acs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:It("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(xr,{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(ec,{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(Fi,{className:"flex-1 p-2",children:[e.jsx("div",{className:"space-y-1",children:t.map(l=>{const i=s.has(l.id);return e.jsxs("button",{onClick:()=>r(l.id),className:It("w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left transition-colors",i?"bg-primary/10 hover:bg-primary/15":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"relative",children:[e.jsxs(mn,{className:"h-7 w-7",children:[e.jsx(ba,{src:l.avatar_url||""}),e.jsx(pn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),e.jsx("span",{className:It("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(qr,{checked:i,onCheckedChange:()=>r(l.id),className:"scale-75",onClick:d=>d.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(mn,{className:It("h-7 w-7 transition-all",i?"ring-2 ring-offset-1 ring-offset-background":"opacity-50"),style:i?{"--tw-ring-color":l.color}:{},children:[e.jsx(ba,{src:l.avatar_url||""}),e.jsx(pn,{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 ZIe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Ecs(){const t=vi(),{data:s}=Ug(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=Tt({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await K.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(f=>f.user_id),{data:d,error:u}=await K.from("profiles").select("id, name, avatar_url").in("id",i);if(u)throw u;return(d||[]).map((f,g)=>({id:f.id,name:f.name||"Unknown",avatar_url:f.avatar_url,color:ZIe[g%ZIe.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function Pcs(t){return Tt({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await K.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 xXe({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=M.useState(!1),l=t.find(d=>d.id===s),i=d=>{d.id!==s&&r(d.id,d.name),o(!1)};return e.jsxs(Du,{open:a,onOpenChange:o,children:[e.jsx(Ou,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:d=>d.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(ei,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(mu,{align:"end",className:"w-48 z-50 bg-popover",onClick:d=>d.stopPropagation(),children:t.map(d=>{const u=d.icon&&Bve[d.icon]||qc,f=d.id===s;return e.jsxs(Wa,{onClick:()=>i(d),className:It("flex items-center gap-2 cursor-pointer",f&&"bg-accent"),children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${d.color}20`},children:e.jsx(u,{className:"h-3 w-3",style:{color:d.color}})}),e.jsx("span",{className:"flex-1",children:d.name}),f&&e.jsx(ma,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const Ics={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"}},Lcs={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 yXe({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var S,A;const d=xM(),u=Ics[t.deal_type],f=Lcs[t.priority],g=M.useMemo(()=>t.target_close_date?zg(new Date(t.target_close_date),new Date):null,[t.target_close_date]),v=g!==null&&g<0,_=g!==null&&g<=7&&g>=0,b=M.useMemo(()=>{var F;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const I=((F=t.listing)==null?void 0:F.created_at)||t.listing_date;if(!I)return null;const L=t.contract_date?new Date(t.contract_date):new Date;return zg(L,new Date(I))},[t]),w=l&&!t.scorecard_transaction_id,j=!!t.scorecard_transaction_id,N=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(De,{className:It("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",v&&"border-red-200 bg-red-50/30",w&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs(Oe,{className:"p-3 space-y-2.5",children:[i&&e.jsxs("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1",children:[e.jsxs(mn,{className:"h-4 w-4",children:[e.jsx(ba,{src:i.avatar_url||""}),e.jsx(pn,{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(nt,{variant:"outline",className:It("text-[10px] px-1.5 py-0 shrink-0",u.color),children:u.label})]}),t.contact&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(mn,{className:"h-5 w-5",children:e.jsxs(pn,{className:"text-[10px] bg-primary/10 text-primary",children:[(S=t.contact.first_name)==null?void 0:S[0],(A=t.contact.last_name)==null?void 0:A[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(Al,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),w&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(so,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),j&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(Ma,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),b!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(BE,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:It("font-medium",b>90?"text-red-600":b>60?"text-amber-600":"text-muted-foreground"),children:[b," 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(Hn,{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(Uc,{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=Hwe(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:It("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",f.color),children:[e.jsx("div",{className:It("w-1.5 h-1.5 rounded-full",f.dot)}),e.jsx("span",{className:"capitalize",children:t.priority})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.probability,"%"]})]}),o&&d&&n&&a?e.jsx(xXe,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:It("flex items-center gap-1 text-[10px]",v&&"text-red-600",_&&!v&&"text-amber-600",!v&&!_&&"text-muted-foreground"),children:[v?e.jsx(Yo,{className:"h-3 w-3"}):e.jsx(nn,{className:"h-3 w-3"}),e.jsx("span",{children:v?`${Math.abs(g)}d overdue`:_?`${g}d left`:js(new Date(t.target_close_date),"MMM d")})]}):null]})]})})}function Dcs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:u}){const f=M.useRef(null),g=s.reduce((j,N)=>j+(N.expected_price||0),0),v=s.reduce((j,N)=>j+(N.expected_commission||0),0),_=s.reduce((j,N)=>j+(Hwe(N)||0),0),b=j=>j>=1e6?`$${(j/1e6).toFixed(1)}M`:j>=1e3?`$${(j/1e3).toFixed(0)}K`:`$${j.toFixed(0)}`,w=t.icon&&Bve[t.icon]||qc;return e.jsxs("div",{ref:f,className:It("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:j=>o(j,t.id),onDrop:j=>l(j,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(w,{className:"h-4 w-4",style:{color:t.color}})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-sm",children:t.name})})]}),e.jsx(nt,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),g>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:b(g)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[b(v)," GCI"]}),_>0&&_!==v&&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(Fi,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(j=>e.jsx("div",{draggable:!0,onDragStart:N=>{N.dataTransfer.effectAllowed="move",a(j.id,t.id)},children:e.jsx(yXe,{deal:j,onClick:()=>r(j),isWonStage:d,ownerInfo:(u==null?void 0:u(j))||null})},j.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function Ocs({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:Mm,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Pipeline Value",value:r((t==null?void 0:t.pipelineValue)||0),icon:ol,color:"text-purple-500",bgColor:"bg-purple-500/10"},{label:"Expected GCI",value:r((t==null?void 0:t.expectedCommission)||0),icon:Uc,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},{label:"Net to Agent",value:r((t==null?void 0:t.expectedNetToAgent)||0),icon:jP,color:"text-teal-500",bgColor:"bg-teal-500/10"},{label:"Won Deals",value:(t==null?void 0:t.wonDeals)||0,icon:so,color:"text-amber-500",bgColor:"bg-amber-500/10"}];return s?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[1,2,3,4].map(a=>e.jsx(De,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>e.jsx(De,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:It("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:It("h-5 w-5",a.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a.label}),e.jsx("p",{className:"text-xl font-bold",children:a.value})]})]})})},a.label))})}function Rcs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Qs(),[a,o]=M.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(gn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(nt,{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(Eg,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(Pg,{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(gn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(nt,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(tl,{className:It("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(Ig,{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(_e,{className:"text-sm font-medium",children:"Enable Client Portal"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create a beautiful portal your client can track their deal from"})]}),e.jsx(qr,{checked:t.portal_enabled,onCheckedChange:i=>l({portal_enabled:i})})]}),t.portal_enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(u_e,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:It("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="private"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(pne,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Pu,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),e.jsxs("label",{className:It("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="public"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(pne,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(up,{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($o,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(_e,{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($o,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(_e,{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(_e,{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(_e,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(Re,{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(_e,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(Re,{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(_e,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(Re,{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(_e,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(tr,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"email",children:"Email"}),e.jsxs(At,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const Fcs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],zcs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function Bcs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=hce(),{data:o}=Im(),{data:l}=sqe(),i=Loe(),d=hXe(),u=mXe(),f=Lbe(),[g,v]=M.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=M.useState(""),[w,j]=M.useState(!1),[N,S]=M.useState(!1),[A,I]=M.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)))||[],[F,$]=M.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:"",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});M.useEffect(()=>{var te,Y,ce,oe,le,de,xe,be;t&&(r?($({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||"",contact_id:r.contact_id||"",listing_id:r.listing_id||"",property_address:r.property_address||"",city:r.city||"",state:r.state||"",zip_code:r.zip_code||"",expected_price:((te=r.expected_price)==null?void 0:te.toString())||"",commission_percentage:((Y=r.commission_percentage)==null?void 0:Y.toString())||"3",brokerage_split_pct:((ce=r.brokerage_split_pct)==null?void 0:ce.toString())||"",team_split_pct:((oe=r.team_split_pct)==null?void 0:oe.toString())||"",referral_fee_pct:((le=r.referral_fee_pct)==null?void 0:le.toString())||"",franchise_fee_pct:((de=r.franchise_fee_pct)==null?void 0:de.toString())||"",transaction_fee:((xe=r.transaction_fee)==null?void 0:xe.toString())||"",target_close_date:r.target_close_date?new Date(r.target_close_date):void 0,contract_date:r.contract_date?new Date(r.contract_date):void 0,listing_date:r.listing_date?new Date(r.listing_date):void 0,priority:r.priority,probability:r.probability.toString(),notes:r.notes||""}),r.contact&&b(`${r.contact.first_name} ${r.contact.last_name}`)):($({deal_name:"",deal_type:"buyer",stage_id:n||((be=a==null?void 0:a[0])==null?void 0:be.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:"",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),b(""),v({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 q=o==null?void 0:o.filter(te=>{var ce,oe,le;const Y=_.toLowerCase();return((ce=te.first_name)==null?void 0:ce.toLowerCase().includes(Y))||((oe=te.last_name)==null?void 0:oe.toLowerCase().includes(Y))||((le=te.email)==null?void 0:le.toLowerCase().includes(Y))}).slice(0,5),H=()=>{const te=parseFloat(F.expected_price)||0,Y=parseFloat(F.commission_percentage)||0;return te*(Y/100)},U=()=>{const te=H();if(!te)return null;let Y=te;const ce=parseFloat(F.brokerage_split_pct)||0,oe=parseFloat(F.team_split_pct)||0,le=parseFloat(F.referral_fee_pct)||0,de=parseFloat(F.franchise_fee_pct)||0,xe=parseFloat(F.transaction_fee)||0;return ce&&(Y=Y*((100-ce)/100)),oe&&(Y=Y*((100-oe)/100)),le&&(Y=Y-te*le/100),de&&(Y=Y-te*de/100),xe&&(Y=Y-xe),Math.max(0,Y)},Q=async te=>{var Y,ce,oe;if(te.preventDefault(),!F.deal_name.trim()){ge.error("Please enter a deal name");return}try{const le={deal_name:F.deal_name,deal_type:F.deal_type,stage_id:F.stage_id||null,contact_id:F.contact_id||null,listing_id:F.listing_id||null,property_address:F.property_address||null,city:F.city||null,state:F.state||null,zip_code:F.zip_code||null,expected_price:F.expected_price?parseFloat(F.expected_price):null,expected_commission:H()||null,commission_percentage:F.commission_percentage?parseFloat(F.commission_percentage):3,brokerage_split_pct:F.brokerage_split_pct?parseFloat(F.brokerage_split_pct):null,team_split_pct:F.team_split_pct?parseFloat(F.team_split_pct):null,referral_fee_pct:F.referral_fee_pct?parseFloat(F.referral_fee_pct):null,franchise_fee_pct:F.franchise_fee_pct?parseFloat(F.franchise_fee_pct):null,transaction_fee:F.transaction_fee?parseFloat(F.transaction_fee):null,net_commission:U(),target_close_date:((Y=F.target_close_date)==null?void 0:Y.toISOString().split("T")[0])||null,contract_date:((ce=F.contract_date)==null?void 0:ce.toISOString().split("T")[0])||null,listing_date:((oe=F.listing_date)==null?void 0:oe.toISOString().split("T")[0])||null,priority:F.priority,probability:parseInt(F.probability)||50,notes:F.notes||null};if(r)await u.mutateAsync({id:r.id,...le}),ge.success("Deal updated successfully");else{const de=await d.mutateAsync(le);if(ge.success("Deal created successfully"),g.portal_enabled&&(de!=null&&de.id))try{await f.mutateAsync({deal_id:de.id,visibility:g.visibility,require_onboarding:g.require_onboarding,allow_spouse:g.allow_spouse,client_name:g.client_name||null,client_email:g.client_email||null,client_phone:g.client_phone||null,invite_method:g.invite_method}),ge.success("Client portal created!")}catch{ge.error("Deal created, but portal setup failed")}}s(!1)}catch{ge.error("Failed to save deal")}},se=d.isPending||u.isPending;return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(Kr,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:Q,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(_e,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(Re,{id:"deal_name",value:F.deal_name,onChange:te=>$(Y=>({...Y,deal_name:te.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Deal Type"}),e.jsxs(tr,{value:F.deal_type,onValueChange:te=>$(Y=>({...Y,deal_type:te})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:Fcs.map(te=>e.jsx(At,{value:te.value,children:te.label},te.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Stage"}),e.jsxs(tr,{value:F.stage_id||"none",onValueChange:te=>$(Y=>({...Y,stage_id:te==="none"?"":te})),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select stage"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No Stage"}),a==null?void 0:a.map(te=>e.jsx(At,{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(_e,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:_,onChange:te=>{b(te.target.value),j(!0),S(!1),te.target.value||$(Y=>({...Y,contact_id:""}))},onFocus:()=>j(!0),placeholder:"Search contacts...",className:"pl-9"}),w&&_&&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:[q&&q.length>0?q.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:()=>{$(Y=>({...Y,contact_id:te.id})),b(`${te.first_name} ${te.last_name}`),j(!1)},children:[e.jsx(mo,{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=_.trim().split(/\s+/);I({first_name:te[0]||"",last_name:te.slice(1).join(" ")||"",email:"",phone:""}),S(!0),j(!1)},children:[e.jsx(pc,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',_.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(pc,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(Z,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>S(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Re,{placeholder:"First name *",value:A.first_name,onChange:te=>I(Y=>({...Y,first_name:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Last name",value:A.last_name,onChange:te=>I(Y=>({...Y,last_name:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Email",type:"email",value:A.email,onChange:te=>I(Y=>({...Y,email:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Phone",type:"tel",value:A.phone,onChange:te=>I(Y=>({...Y,phone:te.target.value})),className:"h-8 text-sm"})]}),e.jsx(Z,{type:"button",size:"sm",className:"w-full h-8",disabled:!A.first_name.trim()||i.isPending,onClick:async()=>{try{const te=await i.mutateAsync({first_name:A.first_name.trim(),last_name:A.last_name.trim()||null,email:A.email.trim()||null,phone:A.phone.trim()||null});te&&($(Y=>({...Y,contact_id:te.id})),b(`${te.first_name} ${te.last_name||""}`.trim()),S(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(pc,{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(_e,{className:"flex items-center gap-2",children:[e.jsx(Al,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(tr,{value:F.listing_id||"none",onValueChange:te=>{const Y=te==="none"?"":te,ce=L.find(oe=>oe.id===Y);$(ce?oe=>{var le;return{...oe,listing_id:Y,deal_type:"seller",property_address:ce.property_address||oe.property_address,city:ce.city||oe.city,state:ce.state||oe.state,expected_price:((le=ce.price)==null?void 0:le.toString())||oe.expected_price}}:oe=>({...oe,listing_id:Y}))},children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select a listing to sync status..."})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"None"}),L.map(te=>e.jsx(At,{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(_e,{htmlFor:"property_address",children:"Address"}),e.jsx(Re,{id:"property_address",value:F.property_address,onChange:te=>$(Y=>({...Y,property_address:te.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:F.city,onChange:te=>$(Y=>({...Y,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(_e,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:F.state,onChange:te=>$(Y=>({...Y,state:te.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(Re,{id:"zip_code",value:F.zip_code,onChange:te=>$(Y=>({...Y,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(_e,{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(Re,{id:"expected_price",type:"number",value:F.expected_price,onChange:te=>$(Y=>({...Y,expected_price:te.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{id:"commission_percentage",type:"number",step:"0.1",value:F.commission_percentage,onChange:te=>$(Y=>({...Y,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(_e,{children:"Expected GCI"}),e.jsx(Re,{value:H()?`$${H().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:"grid grid-cols-2 gap-3 mt-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:F.brokerage_split_pct,onChange:te=>$(Y=>({...Y,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(_e,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:F.team_split_pct,onChange:te=>$(Y=>({...Y,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(_e,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:F.referral_fee_pct,onChange:te=>$(Y=>({...Y,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(_e,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:F.franchise_fee_pct,onChange:te=>$(Y=>({...Y,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(_e,{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(Re,{type:"number",step:"1",min:"0",value:F.transaction_fee,onChange:te=>$(Y=>({...Y,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(_e,{className:"text-xs",children:"Net to Agent"}),e.jsx(Re,{value:U()?`$${Math.round(U()).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(_e,{children:"Target Close Date"}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("w-full justify-start text-left font-normal",!F.target_close_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),F.target_close_date?js(F.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:F.target_close_date,onSelect:te=>$(Y=>({...Y,target_close_date:te})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Contract Date"}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("w-full justify-start text-left font-normal",!F.contract_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),F.contract_date?js(F.contract_date,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:F.contract_date,onSelect:te=>$(Y=>({...Y,contract_date:te})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(F.deal_type==="seller"||F.deal_type==="dual")&&!F.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(_e,{children:"Listing Date (for Days on Market)"}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("w-full justify-start text-left font-normal",!F.listing_date&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),F.listing_date?js(F.listing_date,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:F.listing_date,onSelect:te=>$(Y=>({...Y,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(_e,{children:"Priority"}),e.jsxs(tr,{value:F.priority,onValueChange:te=>$(Y=>({...Y,priority:te})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:zcs.map(te=>e.jsx(At,{value:te.value,children:te.label},te.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",min:"0",max:"100",value:F.probability,onChange:te=>$(Y=>({...Y,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(_e,{htmlFor:"notes",children:"Notes"}),e.jsx(Lr,{id:"notes",value:F.notes,onChange:te=>$(Y=>({...Y,notes:te.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(Rcs,{formData:g,onChange:v}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",disabled:se,children:[se&&e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function $cs(t){return Tt({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await K.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function qcs(){const t=vi(),s=ds();return Bt({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 K.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:d}=await K.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(d)throw d;return i},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function Ucs(){const t=ds();return Bt({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await K.storage.from("deal-files").remove([r]);const{error:a}=await K.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function Vcs(){const t=ds();return Bt({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await K.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 Hcs(t){const{data:s,error:r}=await K.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const YIe={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function Wcs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=ROt(),a=FOt(),o=zOt(),l=BOt(),[i,d]=M.useState(!1),[u,f]=M.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[g,v]=M.useState(""),_=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}),f({question_text:"",field_type:"text",options:[],is_required:!1}),v(""),d(!1),ge.success("Question added")}catch{ge.error("Failed to add question")}},b=async S=>{try{await l.mutateAsync(S),ge.success("Question removed")}catch{ge.error("Failed to remove question")}},w=async(S,A)=>{try{await o.mutateAsync({id:S,is_required:A})}catch{ge.error("Failed to update question")}},j=()=>{g.trim()&&(f(S=>({...S,options:[...S.options,g.trim()]})),v(""))},N=S=>{f(A=>({...A,options:A.options.filter((I,L)=>L!==S)}))};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(Fi,{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(Rs,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(S=>{var A;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(Rh,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:S.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"secondary",className:"text-xs",children:YIe[S.field_type]||S.field_type}),S.is_required&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Required"})]}),S.field_type==="dropdown"&&((A=S.options)==null?void 0:A.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",S.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(qr,{checked:S.is_required,onCheckedChange:I=>w(S.id,I),className:"scale-75"}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>b(S.id),children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]})]})},S.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Question"}),e.jsx(Re,{value:u.question_text,onChange:S=>f(A=>({...A,question_text:S.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(YIe).map(([S,A])=>e.jsx("button",{type:"button",onClick:()=>f(I=>({...I,field_type:S,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===S?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:A},S))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((S,A)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:S}),e.jsx("button",{onClick:()=>N(A),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Vr,{className:"h-3.5 w-3.5"})})]},A)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:g,onChange:S=>v(S.target.value),onKeyDown:S=>S.key==="Enter"&&(S.preventDefault(),j()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(Z,{variant:"outline",size:"sm",onClick:j,disabled:!g.trim(),className:"h-8",children:e.jsx(Ys,{className:"h-3 w-3"})})]})]})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:u.is_required,onCheckedChange:S=>f(A=>({...A,is_required:S}))}),e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>d(!1),className:"flex-1",children:"Cancel"}),e.jsxs(Z,{size:"sm",onClick:_,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(Rs,{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(Z,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function Gcs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=M.useState(""),[i,d]=M.useState(!1),{data:u,isLoading:f}=Tt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:b,error:w}=await K.from("client_portals").select(` id, slug, client_name, client_email, deal_id, archived_at, deal_pipeline (id, deal_name, deal_type, property_address) `).eq("owner_user_id",s).neq("id",t).is("archived_at",null).eq("is_enabled",!0);if(w)throw w;return b},enabled:i||!!n}),g=M.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),v=M.useMemo(()=>!u||!r?[]:u.filter(b=>{var w;return((w=b.client_email)==null?void 0:w.toLowerCase())===r.toLowerCase()&&b.id!==t}),[u,r,t]),_=M.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(w=>{var N,S,A,I;const j=w.deal_pipeline;return((N=w.client_name)==null?void 0:N.toLowerCase().includes(b))||((S=w.client_email)==null?void 0:S.toLowerCase().includes(b))||((A=j==null?void 0:j.deal_name)==null?void 0:A.toLowerCase().includes(b))||((I=j==null?void 0:j.property_address)==null?void 0:I.toLowerCase().includes(b))})},[u,o]);if(n){const b=g==null?void 0:g.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{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(Al,{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:(g==null?void 0:g.client_name)||(b==null?void 0:b.deal_name)||"Linked Portal"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[(b==null?void 0:b.deal_type)==="listing"?"🏠 Listing":"🔑 Purchase"," · ",(b==null?void 0:b.property_address)||"No address"]})]}),e.jsxs(Z,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(nN,{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(_e,{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(Z,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>d(!i),children:[e.jsx(Al,{className:"h-3 w-3 mr-1"}),i?"Cancel":"Link"]})]}),!i&&v.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)"}),v.map(b=>{const w=b.deal_pipeline;return e.jsxs("button",{onClick:()=>a(b.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(nt,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:w==null?void 0:w.property_address})]}),e.jsx(Al,{className:"h-3.5 w-3.5 text-amber-600 shrink-0"})]},b.id)})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{value:o,onChange:b=>l(b.target.value),placeholder:"Search by name, email, or address...",className:"pl-8 h-8 text-xs",autoFocus:!0})]}),f&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Rs,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),_.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:_.map(b=>{const w=b.deal_pipeline;return e.jsxs("button",{onClick:()=>{a(b.id),d(!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(nt,{variant:"outline",className:"text-[10px] shrink-0",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:b.client_email})]})]},b.id)})}),o&&_.length===0&&!f&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function Wwe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=M.useState(!1),[d,u]=M.useState([]),[f,g]=M.useState(!1),[v,_]=M.useState("");M.useEffect(()=>{!l||!t||(g(!0),K.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",t).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:w})=>{u(w||[]),g(!1)}))},[l,t]);const b=d.filter(w=>!v||(w.title||w.recipient_name||"").toLowerCase().includes(v.toLowerCase()));return e.jsxs(bs,{open:l,onOpenChange:i,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(eu,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(_s,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search videos...",value:v,onChange:w=>_(w.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:f?e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"h-16 w-full"}),e.jsx(gs,{className:"h-16 w-full"})]}):b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:d.length===0?"No videos in your library yet":"No videos match your search"}):b.map(w=>e.jsxs("button",{onClick:()=>{s(w.playback_url||""),i(!1)},className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-accent/50 transition-colors text-left",children:[e.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:j=>{const N=j.currentTarget.parentElement;if(N){j.currentTarget.remove();const S=document.createElement("span");S.innerHTML="🎬",S.className="text-lg",N.appendChild(S)}}}):e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:w.title||w.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.duration_seconds?`${Math.round(w.duration_seconds)}s`:"",w.created_at?` · ${new Date(w.created_at).toLocaleDateString()}`:""]})]})]},w.id))})]})]})}function Gwe({contactId:t,onVideoReady:s}){const[r,n]=M.useState(!1),[a,o]=M.useState("record"),[l,i]=M.useState(0),[d,u]=M.useState(0),f=XN(),g=()=>{o("record"),i(0),u(0)},v=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||g())},_=M.useCallback(async(b,w)=>{o("uploading");try{const j="Card Video",{videoId:N,libraryId:S}=await EL(j),{uploadUrl:A,apiKey:I}=await PL(N),L=new XMLHttpRequest;L.upload.onprogress=se=>{se.lengthComputable&&i(se.loaded/se.total*100)},await new Promise((se,te)=>{L.onload=()=>L.status>=200&&L.status<300?se():te(new Error("Upload failed")),L.onerror=()=>te(new Error("Upload failed")),L.open("PUT",A),L.setRequestHeader("AccessKey",I),L.send(b)}),o("processing");let F=0;const $=Date.now(),q=9e4,H=`https://iframe.mediadelivery.net/embed/${S}/${N}`;for(;F<4;){if(await new Promise(te=>setTimeout(te,3e3)),Date.now()-$>q){const te=b.size/1048576;await f.mutateAsync({bunny_video_id:N,playback_url:`https://iframe.mediadelivery.net/play/${S}/${N}`,file_size_mb:te,title:j,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(H),ge.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),g()},1500);return}const se=await y3(N);if(F=se.status,u(se.encodeProgress||0),F===5||F===6)throw new Error("Video processing failed")}const U=await y3(N),Q=(U.storageSize||b.size)/(1024*1024);await f.mutateAsync({bunny_video_id:N,contact_id:t||void 0,playback_url:U.directPlayUrl||H,thumbnail_url:U.thumbnailUrl,preview_url:U.previewUrl||null,duration_seconds:U.length||w,file_size_mb:Q,title:j,status:"ready",touch_type:"video"}),s(H),ge.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),g()},1500)}catch(j){console.error("Recording upload error:",j),ge.error("Failed to process video. Please try again."),o("record")}},[t,s,f]);return e.jsxs(bs,{open:r,onOpenChange:v,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{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(_s,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(pce,{maxDurationSeconds:60,onRecordingComplete:_,onError:b=>ge.error(b)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(Rs,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(wo,{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(Rs,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(wo,{value:d,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(d),"%"]})]}),a==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(hi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}function vXe({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=IL(),[o,l]=M.useState(!1),[i,d]=M.useState(r.next_step_text||""),[u,f]=M.useState(r.next_step_video_url||""),[g,v]=M.useState(r.inspection_date||""),[_,b]=M.useState(r.appraisal_date||""),[w,j]=M.useState(r.welcome_message||""),[N,S]=M.useState(r.review_url||""),[A,I]=M.useState(r.show_post_close_tips),[L,F]=M.useState(r.notify_client),[$,q]=M.useState(r.require_onboarding),[H,U]=M.useState(r.allow_spouse),[Q,se]=M.useState(r.visibility),[te,Y]=M.useState(r.stage_mapping||[]),[ce,oe]=M.useState(null),[le,de]=M.useState(r.linked_portal_id||null),{data:xe}=Tt({queryKey:["pipeline-stages-for-portal",n],queryFn:async()=>{const{data:Ne,error:Ae}=await K.from("deal_pipeline_stages").select("*").eq("owner_user_id",n).order("sort_order",{ascending:!0});if(Ae)throw Ae;return Ne},enabled:t});M.useEffect(()=>{d(r.next_step_text||""),f(r.next_step_video_url||""),v(r.inspection_date||""),b(r.appraisal_date||""),j(r.welcome_message||""),S(r.review_url||""),I(r.show_post_close_tips),F(r.notify_client),q(r.require_onboarding),U(r.allow_spouse),se(r.visibility),Y(r.stage_mapping||[]),de(r.linked_portal_id||null)},[r]);const be=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:i||null,next_step_video_url:u||null,inspection_date:g||null,appraisal_date:_||null,welcome_message:w||null,review_url:N||null,show_post_close_tips:A,notify_client:L,require_onboarding:$,allow_spouse:H,visibility:Q,stage_mapping:te.length>0?te:null,linked_portal_id:le});const Ne=r.linked_portal_id;le&&le!==Ne&&await K.from("client_portals").update({linked_portal_id:r.id}).eq("id",le),!le&&Ne&&await K.from("client_portals").update({linked_portal_id:null}).eq("id",Ne),ge.success("Portal settings saved"),s(!1)}catch{ge.error("Failed to save settings")}},ye=()=>{Y([...te,{label:""}])},ve=Ne=>{Y(te.filter((Ae,Pe)=>Pe!==Ne)),ce===Ne&&oe(null)},ke=(Ne,Ae,Pe)=>{const Fe=[...te];Fe[Ne]={...Fe[Ne],[Ae]:Pe},Y(Fe)},Ge=()=>{const Ae=H1e(null).map(Pe=>({label:Pe.label,description:Pe.description,stageId:void 0}));Y(Ae)};return e.jsxs(e.Fragment,{children:[e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Portal Settings"})}),e.jsxs(Ia,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Aa,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(Ts,{value:"general",children:"General"}),e.jsx(Ts,{value:"timeline",children:"Timeline"}),e.jsx(Ts,{value:"content",children:"Content"})]}),e.jsxs(Fi,{className:"flex-1 mt-4",children:[e.jsxs(Vs,{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(_e,{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:()=>se(Ne),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${Q===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(_e,{className:"text-sm font-medium",children:"Require Onboarding"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Clients must fill out intake form"})]}),e.jsx(qr,{checked:$,onCheckedChange: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(_e,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(Z,{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(_e,{className:"text-sm font-medium",children:"Allow Spouse/Partner"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show spouse fields on onboarding"})]}),e.jsx(qr,{checked:H,onCheckedChange:U})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Post-Close Celebration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show congrats card when deal closes"})]}),e.jsx(qr,{checked:A,onCheckedChange:I})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Notify Client on Updates"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email client when you post portal updates"})]}),e.jsx(qr,{checked:L,onCheckedChange:F})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(Gcs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:le,onLink:de})}),e.jsx("div",{children:e.jsx(Re,{type:"date",value:g,onChange:Ne=>v(Ne.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(Re,{type:"date",value:_,onChange:Ne=>b(Ne.target.value),className:"mt-1"})]})]}),e.jsx(Vs,{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(_e,{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(Z,{variant:"outline",size:"sm",onClick:Ge,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(Z,{variant:"outline",size:"sm",onClick:Ge,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(Rh,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(Re,{value:Ne.label,onChange:Pe=>ke(Ae,"label",Pe.target.value),placeholder:`Stage ${Ae+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-primary",onClick:()=>oe(ce===Ae?null:Ae),children:ce===Ae?"Less":"More"}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>ve(Ae),children:e.jsx(Cr,{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(_e,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:Ne.description||"",onChange:Pe=>ke(Ae,"description",Pe.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(_e,{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(Z,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>ke(Ae,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(Gwe,{onVideoReady:Pe=>ke(Ae,"video_url",Pe)}),e.jsx(Wwe,{userId:n,onSelect:Pe=>ke(Ae,"video_url",Pe),triggerSize:"sm",triggerClassName:"gap-1.5 shrink-0 flex-1"}),e.jsxs(Z,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const Pe=prompt("Paste a YouTube or Loom URL:");Pe&&ke(Ae,"video_url",Pe)},children:[e.jsx(Po,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Ae))}),te.length>0&&e.jsxs(Z,{variant:"outline",size:"sm",onClick:ye,className:"mt-2 text-xs w-full",children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(Vs,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:w,onChange:Ne=>j(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(_e,{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=>d(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(_e,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(Re,{value:u,onChange:Ne=>f(Ne.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(_e,{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(Re,{value:N,onChange:Ne=>S(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(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{onClick:be,disabled:a.isPending,children:[a.isPending?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zh,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})}),e.jsx(Wcs,{open:o,onOpenChange:l})]})}function _Xe({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const[o,l]=M.useState(""),[i,d]=M.useState(""),[u,f]=M.useState(""),[g,v]=M.useState(!1),[_,b]=M.useState(a??!1),w=gGe(),j=async()=>{if(o.trim())try{if(await w.mutateAsync({portal_id:r,title:o.trim(),content:i.trim()||void 0,video_url:u.trim()||void 0,is_stage_change:g}),_&&n)try{const N=M0(n);await K.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:o.trim(),update_content:i.trim()||null,portal_url:N}}),ge.success("Update posted & client notified")}catch(N){console.error("Notification failed:",N),ge.success("Update posted (notification failed to send)")}else ge.success("Update posted to portal");l(""),d(""),f(""),v(!1),s(!1)}catch{ge.error("Failed to post update")}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Title *"}),e.jsx(Re,{value:o,onChange:N=>l(N.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:i,onChange:N=>d(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(_e,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(Re,{value:u,onChange:N=>f(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:()=>v(!g),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${g?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),e.jsxs("button",{type:"button",onClick:()=>b(!_),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${_?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[_?e.jsx(af,{className:"h-3 w-3"}):e.jsx(U1,{className:"h-3 w-3"}),_?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{onClick:j,disabled:!o.trim()||w.isPending,children:[w.isPending?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})})}function bXe({open:t,onOpenChange:s,portal:r,dealName:n}){const a=IL(),{isGmailConnected:o,gmailEmail:l}=G0(),[i,d]=M.useState(r.client_name||""),[u,f]=M.useState(r.client_email||""),[g,v]=M.useState(!1),[_,b]=M.useState(!1),w=M0(r.slug),j=i.split(" ")[0]||"there",N=`Your Transaction Portal – ${n}`,S=`Hi ${j}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${w} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,A=()=>{navigator.clipboard.writeText(w),b(!0),setTimeout(()=>b(!1),2e3),ge.success("Portal link copied!")},I=async()=>{if(!u.trim()){ge.error("Please enter the client email");return}v(!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:F}=await K.functions.invoke("gmail-send",{body:{to:u,subject:N,body:S.replace(/\n/g,"
")}});if(F)throw F;ge.success(`Invite sent to ${u}`),s(!1)}catch(F){ge.error(F.message||"Failed to send invite")}finally{v(!1)}},L=()=>{const F=encodeURIComponent(N),$=encodeURIComponent(S);window.open(`mailto:${u}?subject=${F}&body=${$}`,"_blank"),a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(Re,{value:i,onChange:F=>d(F.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(Re,{type:"email",value:u,onChange:F=>f(F.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Portal Link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:w})}),e.jsx(Z,{variant:"outline",size:"icon",onClick:A,className:"shrink-0",children:_?e.jsx(ma,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ni,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(Z,{onClick:I,disabled:g||!u.trim(),className:"w-full",children:[g?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(Z,{onClick:L,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(Z,{variant:"ghost",onClick:A,className:"w-full text-muted-foreground",children:[e.jsx(Ni,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function Kcs({deal:t}){const{isAdmin:s,user:r}=Qs(),{data:n,isLoading:a}=IOt(t.id),o=Lbe(),l=IL(),[i,d]=M.useState(!1),[u,f]=M.useState(!1),[g,v]=M.useState(!1),[_,b]=M.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(gn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Rs,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var L,F;d(!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:((F=t.contact)==null?void 0:F.phone)||void 0}),ge.success("Client portal enabled!")}catch{ge.error("Failed to create portal")}finally{d(!1)}},j=async L=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:L}),ge.success(L?"Portal enabled":"Portal disabled")}catch{ge.error("Failed to update portal")}},N=()=>{if(!n)return;const L=M0(n.slug);navigator.clipboard.writeText(L),ge.success("Portal link copied!")},S=()=>{if(!n)return;const L=M0(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(gn,{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(Z,{onClick:w,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(gn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const A=M0(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(gn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(nt,{variant:"outline",className:n.is_enabled?"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-xs bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:j})]}),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(nt,{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:A})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(Z,{variant:"outline",size:"sm",onClick:N,className:"text-xs flex-1 min-w-0",children:[e.jsx(Ni,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:S,className:"text-xs flex-1 min-w-0",children:[e.jsx(un,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>b(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(Pa,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(l5,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>f(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(Pl,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(vXe,{open:u,onOpenChange:f,portal:n,dealOwnerId:I}),e.jsx(_Xe,{open:g,onOpenChange:v,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(bXe,{open:_,onOpenChange:b,portal:n,dealName:t.deal_name})]})}const Zcs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function Ycs(t){return Tt({queryKey:["deal-contacts",t],queryFn:async()=>{const{data:s,error:r}=await K.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 Xcs(){const t=ds();return Bt({mutationFn:async({dealId:s,contactId:r,role:n})=>{const{data:a,error:o}=await K.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]}),ge.success("Contact linked to deal")},onError:s=>{var r;(r=s.message)!=null&&r.includes("duplicate")?ge.error("This contact is already linked to this deal"):ge.error("Failed to link contact")}})}function Qcs(){const t=ds();return Bt({mutationFn:async({id:s,dealId:r})=>{const{error:n}=await K.from("deal_contacts").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),ge.success("Contact removed from deal")},onError:()=>{ge.error("Failed to remove contact")}})}function Jcs({dealId:t,primaryContactId:s}){const r=Or(),{data:n,isLoading:a}=Ycs(t),{data:o}=Im(),l=Xcs(),i=Qcs(),[d,u]=M.useState(!1),[f,g]=M.useState(""),[v,_]=M.useState("Client"),b=new Set((n==null?void 0:n.map(A=>A.contact_id))||[]);s&&b.add(s);const w=o==null?void 0:o.filter(A=>{var L,F,$;if(b.has(A.id))return!1;if(!f.trim())return!0;const I=f.toLowerCase();return((L=A.first_name)==null?void 0:L.toLowerCase().includes(I))||((F=A.last_name)==null?void 0:F.toLowerCase().includes(I))||(($=A.email)==null?void 0:$.toLowerCase().includes(I))}).slice(0,8),j=A=>{l.mutate({dealId:t,contactId:A,role:v}),u(!1),g("")},N=A=>{i.mutate({id:A,dealId:t})},S={Client:"bg-primary/10 text-primary","Co-Buyer":"bg-blue-500/10 text-blue-600","Co-Seller":"bg-emerald-500/10 text-emerald-600",Spouse:"bg-pink-500/10 text-pink-600",Lender:"bg-amber-500/10 text-amber-600","Title Company":"bg-purple-500/10 text-purple-600",Inspector:"bg-orange-500/10 text-orange-600",Appraiser:"bg-cyan-500/10 text-cyan-600",Attorney:"bg-slate-500/10 text-slate-600",Contractor:"bg-lime-500/10 text-lime-600",Other:"bg-muted text-muted-foreground"};return!(n!=null&&n.length)&&!d?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(xr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(No,{open:d,onOpenChange:u,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(Ys,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(jo,{className:"w-80 p-3",align:"start",children:e.jsx(XIe,{search:f,setSearch:g,selectedRole:v,setSelectedRole:_,filteredContacts:w,onAdd:j})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(xr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(nt,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(No,{open:d,onOpenChange:u,children:[e.jsx(So,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(Ys,{className:"h-3.5 w-3.5"})})}),e.jsx(jo,{className:"w-80 p-3",align:"end",children:e.jsx(XIe,{search:f,setSearch:g,selectedRole:v,setSelectedRole:_,filteredContacts:w,onAdd:j})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(A=>{var I,L,F,$,q,H,U,Q;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(mn,{className:"h-7 w-7",children:e.jsxs(pn,{className:"text-[10px] bg-primary/10 text-primary",children:[(L=(I=A.contact)==null?void 0:I.first_name)==null?void 0:L[0],($=(F=A.contact)==null?void 0:F.last_name)==null?void 0:$[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${A.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(q=A.contact)==null?void 0:q.first_name," ",(H=A.contact)==null?void 0:H.last_name]})}),e.jsx(nt,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${S[A.role]||S.Other}`,children:A.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((U=A.contact)==null?void 0:U.phone)&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${A.contact.phone}`,children:e.jsx(ga,{className:"h-3 w-3"})})}),((Q=A.contact)==null?void 0:Q.email)&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${A.contact.email}`,children:e.jsx(Ar,{className:"h-3 w-3"})})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>N(A.id),children:e.jsx(Cr,{className:"h-3 w-3"})})]})]},A.id)})})]})}function XIe({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsx(Js,{className:"h-8 text-sm",children:e.jsx(rr,{placeholder:"Role"})}),e.jsx(er,{children:Zcs.map(l=>e.jsx(At,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Fi,{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 eds={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"}},tds={note:ho,call:ga,email:Ar,meeting:nn,stage_change:un,task_completed:Ma,document:Hn,system:Tn};function sds({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Pe,Fe;const{data:l,isLoading:i}=qls((t==null?void 0:t.id)||""),{data:d,isLoading:u}=Vls((t==null?void 0:t.id)||""),f=Uls(),g=Wls(),v=Hls(),_=$ls(),{data:b,isLoading:w}=$cs((t==null?void 0:t.id)||""),j=qcs(),N=Ucs(),S=Vcs(),A=M.useRef(null),[I,L]=M.useState(""),[F,$]=M.useState(""),[q,H]=M.useState(!1),[U,Q]=M.useState(!1);if(!t)return null;const se=eds[t.deal_type],te=(()=>{var dt;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const Ie=((dt=t.listing)==null?void 0:dt.created_at)||t.listing_date;if(!Ie)return null;const Ve=t.contract_date?new Date(t.contract_date):new Date;return zg(Ve,new Date(Ie))})(),Y=Ie=>Ie?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ie):"-",ce=async()=>{if(I.trim())try{await f.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:I}),L(""),ge.success("Note added")}catch{ge.error("Failed to add note")}},oe=async()=>{if(F.trim())try{await g.mutateAsync({deal_id:t.id,title:F,sort_order:((d==null?void 0:d.length)||0)+1}),$(""),ge.success("Task added")}catch{ge.error("Failed to add task")}},le=async(Ie,Ve)=>{try{await v.mutateAsync({id:Ie,is_completed:Ve,deal_id:t.id})}catch{ge.error("Failed to update task")}},de=async()=>{try{await _.mutateAsync(t.id),ge.success("Deal deleted"),r(!1)}catch{ge.error("Failed to delete deal")}},xe=(d==null?void 0:d.filter(Ie=>Ie.is_completed).length)||0,be=(d==null?void 0:d.length)||0,ye=(b==null?void 0:b.length)||0,ve=Ie=>Ie<1024?`${Ie} B`:Ie<1024*1024?`${(Ie/1024).toFixed(1)} KB`:`${(Ie/(1024*1024)).toFixed(1)} MB`,ke=Ie=>Ie?Ie.startsWith("image/")?Xo:Ie.includes("pdf")?Un:J4:J4,Ge=async Ie=>{const Ve=Ie.target.files;if(!(!Ve||!t)){Q(!0);try{for(const dt of Array.from(Ve)){if(dt.size>20*1024*1024){ge.error(`${dt.name} exceeds 20MB limit`);continue}await j.mutateAsync({dealId:t.id,file:dt})}ge.success("File(s) uploaded")}catch{ge.error("Failed to upload file")}finally{Q(!1),A.current&&(A.current.value="")}}},Ne=async(Ie,Ve)=>{if(t)try{await N.mutateAsync({fileId:Ie,storagePath:Ve,dealId:t.id}),ge.success("File deleted")}catch{ge.error("Failed to delete file")}},Ae=async(Ie,Ve)=>{try{const dt=await Hcs(Ie),Le=document.createElement("a");Le.href=dt,Le.download=Ve,Le.target="_blank",document.body.appendChild(Le),Le.click(),document.body.removeChild(Le)}catch{ge.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(uL,{open:s,onOpenChange:r,children:e.jsxs(lM,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(hL,{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(nt,{variant:"outline",className:It("text-xs",se.color),children:se.label}),e.jsxs(nt,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(mL,{className:"text-xl",children:t.deal_name})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(Pc,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>H(!0),children:e.jsx(Cr,{className:"h-4 w-4"})})]})]})}),e.jsx(Fi,{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(mn,{className:"h-10 w-10",children:e.jsxs(pn,{className:"bg-primary/10 text-primary",children:[(Pe=t.contact.first_name)==null?void 0:Pe[0],(Fe=t.contact.last_name)==null?void 0:Fe[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(Z,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(ga,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(Z,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(Ar,{className:"h-4 w-4"})})})]})]}),e.jsx(Jcs,{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(Hn,{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:Y(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:Y(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?` (${Y(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:Y(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:Y(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(Z,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(so,{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(Ma,{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:It("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(nn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",js(new Date(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Uc,{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(Kcs,{deal:t}),e.jsxs(Ia,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(Aa,{className:"w-full grid grid-cols-3",children:[e.jsxs(Ts,{value:"tasks",className:"gap-1",children:[e.jsx(Ma,{className:"h-4 w-4"}),"Tasks ",be>0&&`(${xe}/${be})`]}),e.jsxs(Ts,{value:"files",className:"gap-1",children:[e.jsx(Qk,{className:"h-4 w-4"}),"Files ",ye>0&&`(${ye})`]}),e.jsxs(Ts,{value:"activity",className:"gap-1",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(Vs,{value:"tasks",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Add a new task...",value:F,onChange:Ie=>$(Ie.target.value),onKeyDown:Ie=>Ie.key==="Enter"&&oe()}),e.jsx(Z,{onClick:oe,disabled:!F.trim(),children:e.jsx(Ys,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(Ie=>e.jsxs("div",{className:It("flex items-center gap-3 p-3 rounded-lg border transition-colors",Ie.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx($o,{checked:Ie.is_completed,onCheckedChange:Ve=>le(Ie.id,!!Ve)}),e.jsx("span",{className:It("flex-1 text-sm",Ie.is_completed&&"line-through text-muted-foreground"),children:Ie.title}),Ie.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:js(new Date(Ie.due_date),"MMM d")})]},Ie.id)),(d==null?void 0:d.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No tasks yet. Add one above!"})]})]}),e.jsxs(Vs,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:A,className:"hidden",multiple:!0,onChange:Ge,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(Z,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var Ie;return(Ie=A.current)==null?void 0:Ie.click()},disabled:U,children:[U?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(xi,{className:"h-4 w-4 mr-2"}),U?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[b==null?void 0:b.map(Ie=>{const Ve=ke(Ie.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(Ve,{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:Ie.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ve(Ie.file_size)," · ",js(new Date(Ie.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(HN,{children:e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${Ie.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>S.mutate({fileId:Ie.id,visible:!Ie.visible_on_portal,dealId:t.id}),children:Ie.visible_on_portal?e.jsx(Na,{className:"h-4 w-4"}):e.jsx(Nm,{className:"h-4 w-4"})})}),e.jsx(au,{side:"top",children:Ie.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ae(Ie.storage_path,Ie.file_name),children:e.jsx(Ei,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Ne(Ie.id,Ie.storage_path),children:e.jsx(Vr,{className:"h-4 w-4"})})]})]},Ie.id)}),(b==null?void 0:b.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(Vs,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lr,{placeholder:"Add a note...",value:I,onChange:Ie=>L(Ie.target.value),rows:2}),e.jsxs(Z,{onClick:ce,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(Ie=>{const Ve=tds[Ie.activity_type]||Tn;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(Ve,{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:Ie.title}),Ie.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:Ie.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:$d(new Date(Ie.created_at),{addSuffix:!0})})]})]},Ie.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(uc,{open:q,onOpenChange:H,children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete Deal?"}),e.jsxs(Xl,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:de,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function rds({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=Roe(),o=mXe(),{data:l}=gL(),{data:i}=Vg(),[d,u]=M.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:js(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});M.useEffect(()=>{if(r&&t){const v=r.deal_type==="seller"?"seller":"buyer",_=r.expected_price||0,b=r.commission_percentage||3,w=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:v,close_date:r.actual_close_date||r.target_close_date||js(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:w,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const f=async v=>{if(v.preventDefault(),!!r)try{const _=await a.mutateAsync({property_address:d.property_address,city:d.city||null,state:d.state||null,zip:d.zip||null,transaction_type:d.transaction_type,close_date:d.close_date,sale_price:d.sale_price,commission_amount:d.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:d.lead_source_id||null,client_type_id:d.client_type_id||null,contact_id:r.contact_id||null,notes:d.notes||null,is_win:!0});await o.mutateAsync({id:r.id,scorecard_transaction_id:_.id,actual_close_date:d.close_date}),ge.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(_){console.error("Error syncing to scorecard:",_),ge.error("Failed to add to scorecard")}},g=v=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(v);return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{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(so,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(Ss,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(Kr,{className:"text-center",children:"Review and confirm the details before adding this deal to your Scorecard."})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(Re,{id:"property_address",value:d.property_address,onChange:v=>u(_=>({..._,property_address:v.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(_e,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:d.city,onChange:v=>u(_=>({..._,city:v.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:d.state,onChange:v=>u(_=>({..._,state:v.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"zip",children:"Zip"}),e.jsx(Re,{id:"zip",value:d.zip,onChange:v=>u(_=>({..._,zip:v.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(_e,{children:"Transaction Type *"}),e.jsxs(tr,{value:d.transaction_type,onValueChange:v=>u(_=>({..._,transaction_type:v})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(Re,{id:"close_date",type:"date",value:d.close_date,onChange:v=>u(_=>({..._,close_date:v.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(_e,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(Uc,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(Re,{id:"sale_price",type:"number",value:d.sale_price||"",onChange:v=>u(_=>({..._,sale_price:Number(v.target.value)})),placeholder:"450000",required:!0,min:0}),d.sale_price>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:g(d.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(c5,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(Re,{id:"commission_amount",type:"number",value:d.commission_amount||"",onChange:v=>u(_=>({..._,commission_amount:Number(v.target.value)})),placeholder:"13500",min:0}),d.commission_amount>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:g(d.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Lead Source"}),e.jsxs(tr,{value:d.lead_source_id,onValueChange:v=>u(_=>({..._,lead_source_id:v})),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select source"})}),e.jsx(er,{children:l==null?void 0:l.map(v=>e.jsx(At,{value:v.id,children:v.name},v.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Client Type"}),e.jsxs(tr,{value:d.client_type_id,onValueChange:v=>u(_=>({..._,client_type_id:v})),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select type"})}),e.jsx(er,{children:i==null?void 0:i.map(v=>e.jsx(At,{value:v.id,children:v.name},v.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"notes",children:"Notes"}),e.jsx(Lr,{id:"notes",value:d.notes,onChange:v=>u(_=>({..._,notes:v.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(qn,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(Z,{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(Ai,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const nds={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"}},QIe={urgent:0,high:1,medium:2,low:3};function ads({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=M.useState("target_close_date"),[l,i]=M.useState("asc"),d=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=M.useMemo(()=>[...t].sort((_,b)=>{var j,N;let w=0;switch(a){case"deal_name":w=_.deal_name.localeCompare(b.deal_name);break;case"stage":{const S=((j=s.find(I=>I.id===_.stage_id))==null?void 0:j.sort_order)||0,A=((N=s.find(I=>I.id===b.stage_id))==null?void 0:N.sort_order)||0;w=S-A;break}case"expected_price":w=(_.expected_price||0)-(b.expected_price||0);break;case"expected_commission":w=(_.expected_commission||0)-(b.expected_commission||0);break;case"target_close_date":{const S=_.target_close_date?new Date(_.target_close_date).getTime():1/0,A=b.target_close_date?new Date(b.target_close_date).getTime():1/0;w=S-A;break}case"priority":w=QIe[_.priority]-QIe[b.priority];break}return l==="asc"?w:-w}),[t,s,a,l]),f=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):"—",g=_=>_?s.find(b=>b.id===_):null,v=({field:_,children:b})=>e.jsxs(Z,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>d(_),children:[b,a===_?l==="asc"?e.jsx(Rd,{className:"ml-2 h-4 w-4"}):e.jsx(Ku,{className:"ml-2 h-4 w-4"}):e.jsx($c,{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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{className:"bg-muted/50",children:[e.jsx(kt,{className:"w-[250px]",children:e.jsx(v,{field:"deal_name",children:"Deal Name"})}),e.jsx(kt,{className:"w-[150px]",children:e.jsx(v,{field:"stage",children:"Stage"})}),e.jsx(kt,{className:"w-[100px]",children:"Type"}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(v,{field:"expected_price",children:"Price"})}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(v,{field:"expected_commission",children:"GCI"})}),e.jsx(kt,{className:"w-[130px]",children:e.jsx(v,{field:"target_close_date",children:"Close Date"})}),e.jsx(kt,{className:"w-[100px]",children:e.jsx(v,{field:"priority",children:"Priority"})})]})}),e.jsx(Ln,{children:u.map(_=>{g(_.stage_id);const b=nds[_.deal_type],w=_.target_close_date?zg(new Date(_.target_close_date),new Date):null,j=w!==null&&w<0,N=w!==null&&w<=7&&w>=0;return e.jsxs(ks,{className:It("cursor-pointer hover:bg-muted/50 transition-colors",j&&"bg-red-50/50"),onClick:()=>r(_),children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:_.deal_name}),_.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[_.contact.first_name," ",_.contact.last_name]})]})}),e.jsx(lt,{onClick:S=>S.stopPropagation(),children:e.jsx(xXe,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(S,A)=>n(_.id,S,A)})}),e.jsx(lt,{children:e.jsx(nt,{variant:"outline",className:It("text-xs",b.color),children:b.label})}),e.jsx(lt,{children:e.jsx("span",{className:"font-medium",children:f(_.expected_price)})}),e.jsx(lt,{children:e.jsx("span",{className:"text-emerald-600",children:f(_.expected_commission)})}),e.jsx(lt,{children:_.target_close_date?e.jsxs("div",{className:It("flex items-center gap-1 text-sm",j&&"text-red-600",N&&!j&&"text-amber-600"),children:[j&&e.jsx(Yo,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:js(new Date(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{children:e.jsx(nt,{variant:"outline",className:It("text-xs capitalize",_.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",_.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",_.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",_.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:_.priority})})]},_.id)})})]})})}function ids(){const t=vi();return Tt({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 ods(t){const s=vi();return Tt({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await K.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 lds(){const t=vi(),s=ds();return Bt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await K.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 cds(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function dds(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function Kwe(){const t=ds();return Bt({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await K.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 uds(){const t=ds();return Bt({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await K.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 hds(t){const s=vi();return Tt({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=K.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 mds(){const t=vi(),s=ds();return Bt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await K.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 pds(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function fds(){const t=vi(),s=ds();return Bt({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await K.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 K.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(g=>g.title)),d=a.filter(g=>!i.has(g.title)).map((g,v)=>({owner_user_id:t,deal_id:r,stage_id:n,title:g.title,description:g.description,priority:g.priority,due_date:g.default_due_offset_days?new Date(Date.now()+g.default_due_offset_days*864e5).toISOString().split("T")[0]:null,sort_order:v,status:"todo"}));if(d.length===0)return[];const{data:u,error:f}=await K.from("deal_tasks").insert(d).select();if(f)throw f;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const gds={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function xds({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:d,isLoading:u}=ods(t?r:void 0),f=uds(),g=fds(),[v,_]=M.useState(new Set),[b,w]=M.useState(!1),j=(d||[]).filter(I=>I.status!=="done");M.useEffect(()=>{j.length>0&&_(new Set(j.map(I=>I.id)))},[d]);const N=I=>{_(L=>{const F=new Set(L);return F.has(I)?F.delete(I):F.add(I),F})},S=async()=>{w(!0);try{const I=Array.from(v);I.length>0&&await f.mutateAsync(I),await i(),await g.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move failed:",I),ge.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{w(!1)}},A=async()=>{w(!0);try{await i(),await g.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move (skip) failed:",I),ge.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{w(!1)}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[480px]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Move Deal"}),e.jsxs(Kr,{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(nt,{variant:"outline",className:"text-sm",children:a}),e.jsx(Ai,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(nt,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:j.length})," incomplete task",j.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Fi,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:j.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($o,{checked:v.has(I.id),onCheckedChange:()=>N(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[gds[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(Z,{variant:"ghost",size:"sm",onClick:()=>{v.size===j.length?_(new Set):_(new Set(j.map(I=>I.id)))},children:v.size===j.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{variant:"outline",size:"sm",onClick:A,disabled:b,children:"Skip"}),e.jsxs(Z,{size:"sm",onClick:S,disabled:b,children:[b&&e.jsx(Rs,{className:"h-4 w-4 mr-1 animate-spin"}),v.size>0?`Complete ${v.size} & Move`:"Move Deal"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx(Ma,{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(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Z,{onClick:S,disabled:b,children:[b&&e.jsx(Rs,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function yds(){const t=vi();return Tt({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function vds({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=Lbe(),u=IL(),f=LOt(),g=DOt(),[v,_]=M.useState(!1),b=!!(n!=null&&n.archived_at),w=async()=>{_(!0);try{await d.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),ge.success("Portal enabled!")}catch{ge.error("Failed to create portal")}finally{_(!1)}},j=async L=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:L}),ge.success(L?"Portal enabled":"Portal disabled")}catch{ge.error("Failed to update portal")}},N=()=>{n&&(navigator.clipboard.writeText(M0(n.slug)),ge.success("Link copied!"))},S=()=>{n&&window.open(M0(n.slug),"_blank")},A=async()=>{if(n)try{await f.mutateAsync(n.id),ge.success("Portal archived")}catch{ge.error("Failed to archive portal")}},I=async()=>{if(n)try{await g.mutateAsync(n.id),ge.success("Portal restored")}catch{ge.error("Failed to restore portal")}};return n?b?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(nt,{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(Z,{variant:"ghost",size:"sm",onClick:I,className:"text-xs gap-1",children:[e.jsx(OE,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(Cr,{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(nt,{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(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:N,title:"Copy link",children:e.jsx(Ni,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,title:"Preview",children:e.jsx(un,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx(Pa,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(l5,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx(Pl,{className:"h-3.5 w-3.5"})}),e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Xp,{className:"h-3.5 w-3.5"})})}),e.jsx(mu,{align:"end",children:e.jsxs(Wa,{onClick:A,children:[e.jsx(K4,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:j,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(Z,{size:"sm",onClick:w,disabled:v,className:"shrink-0 ml-4",children:[v?e.jsx(Rs,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(gn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function _ds(){const{data:t,isLoading:s}=mce(),{data:r,isLoading:n}=yds(),[a,o]=M.useState(""),[l,i]=M.useState("all"),d=OOt(),[u,f]=M.useState(null),[g,v]=M.useState(null),[_,b]=M.useState(null),[w,j]=M.useState(null),N=vi(),S=s||n,A=new Map;r==null||r.forEach(U=>A.set(U.deal_id,U));const L=[...(t||[]).filter(U=>{var ce,oe,le,de,xe;const Q=A.get(U.id),se=a.toLowerCase(),te=!se||U.deal_name.toLowerCase().includes(se)||((oe=(ce=U.contact)==null?void 0:ce.first_name)==null?void 0:oe.toLowerCase().includes(se))||((de=(le=U.contact)==null?void 0:le.last_name)==null?void 0:de.toLowerCase().includes(se))||((xe=Q==null?void 0:Q.client_name)==null?void 0:xe.toLowerCase().includes(se));let Y=!0;return l==="active"?Y=!!(Q!=null&&Q.is_enabled)&&!(Q!=null&&Q.archived_at):l==="disabled"?Y=!!Q&&!Q.is_enabled&&!Q.archived_at:l==="archived"?Y=!!(Q!=null&&Q.archived_at):l==="none"?Y=!Q:l==="all"&&(Y=!(Q!=null&&Q.archived_at)||!Q),te&&Y})].sort((U,Q)=>{const se=A.get(U.id),te=A.get(Q.id);if(se!=null&&se.archived_at&&!(te!=null&&te.archived_at))return 1;if(!(se!=null&&se.archived_at)&&(te!=null&&te.archived_at)||se&&!te)return-1;if(!se&&te)return 1;if(se&&te){if(se.is_enabled&&!te.is_enabled)return-1;if(!se.is_enabled&&te.is_enabled)return 1}return 0}),F=(r==null?void 0:r.filter(U=>!U.archived_at).length)||0,$=(r==null?void 0:r.filter(U=>U.is_enabled&&!U.archived_at).length)||0,q=(r==null?void 0:r.filter(U=>U.archived_at).length)||0,H=async()=>{if(w)try{await d.mutateAsync({id:w.id,dealId:w.deal_id}),ge.success("Portal permanently deleted"),j(null)}catch{ge.error("Failed to delete portal")}};return S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(Rs,{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(gn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[F," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[$," active · ",F-$," disabled",q>0&&` · ${q} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search deals or clients...",value:a,onChange:U=>o(U.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(Vr,{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(U=>e.jsx(Z,{variant:l===U?"secondary":"ghost",size:"sm",onClick:()=>i(U),className:"text-xs px-3 capitalize",children:U==="none"?"No Portal":U},U))})]}),e.jsx(Fi,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(U=>{const Q=A.get(U.id)||null,se=U.contact?`${U.contact.first_name||""} ${U.contact.last_name||""}`.trim():"";return e.jsx(vds,{dealId:U.id,dealName:U.deal_name,contactName:se,portal:Q,onSettingsOpen:f,onComposerOpen:te=>v(te),onInviteOpen:(te,Y)=>b({portal:te,dealName:Y}),onDeleteConfirm:j},U.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(gn,{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(vXe,{open:!!u,onOpenChange:U=>!U&&f(null),portal:u,dealOwnerId:N||""}),g&&e.jsx(_Xe,{open:!!g,onOpenChange:U=>!U&&v(null),portalId:g.id,portalSlug:g.slug,notifyClient:g.notify_client}),_&&e.jsx(bXe,{open:!!_,onOpenChange:U=>!U&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(uc,{open:!!w,onOpenChange:U=>!U&&j(null),children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Permanently delete this portal?"}),e.jsx(Xl,{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(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:H,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class bds extends M.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(Ms,{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 wds(){var is;const t=xM(),{data:s,isLoading:r}=hce(),{data:n,isLoading:a,refetch:o}=mce(),{data:l,isLoading:i}=Gls(),d=uXe(),u=Bls(),[f,g]=M.useState("board"),[v,_]=M.useState(!1),[b,w]=M.useState(!1),[j,N]=M.useState(null),[S,A]=M.useState(null),[I,L]=M.useState(null),[F,$]=M.useState(null),[q,H]=M.useState(!1),[U,Q]=M.useState(null),[se,te]=M.useState(""),[Y,ce]=M.useState("all"),[oe,le]=M.useState(!1),[de,xe]=M.useState(!1),[be,ye]=M.useState(new Set),[ve,ke]=M.useState(null),{data:Ge}=Ug(),{isTeamLeader:Ne,teamMembers:Ae}=Ecs(),Pe=M.useMemo(()=>Array.from(be),[be]),{data:Fe}=Pcs(Pe),Ie=M.useMemo(()=>{const Kt=new Map;return Ae.forEach(Qt=>Kt.set(Qt.id,{name:Qt.name,avatar_url:Qt.avatar_url,color:Qt.color})),Kt},[Ae]),Ve=M.useCallback(Kt=>Kt.owner_user_id&&Ie.get(Kt.owner_user_id)||null,[Ie]),dt=M.useCallback(Kt=>{ye(Qt=>{const fs=new Set(Qt);return fs.has(Kt)?fs.delete(Kt):fs.add(Kt),fs})},[]);M.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[Le,Rt]=Gc(),fe=M.useRef(!1);M.useEffect(()=>{const Kt=Le.get("deal");if(Kt&&n&&n.length>0&&!fe.current){const Qt=n.find(fs=>fs.id===Kt);Qt&&(fe.current=!0,N(Qt),w(!0),Le.delete("deal"),Rt(Le,{replace:!0}))}},[n,Le]);const Qe=M.useMemo(()=>{if(!Fe||!s)return[];const Kt=new Map(s.map(Qt=>[Qt.name,Qt.id]));return Fe.map(Qt=>{const fs=Qt._stage_name&&Kt.get(Qt._stage_name)||null;return{...Qt,stage_id:fs||Qt.stage_id}})},[Fe,s]),at=M.useMemo(()=>[...n||[],...Qe],[n,Qe]),rt=at.filter(Kt=>{var bt,ws,ir,Rr,oa,ri;const Qt=se.toLowerCase(),fs=!Qt||Kt.deal_name.toLowerCase().includes(Qt)||((ws=(bt=Kt.contact)==null?void 0:bt.first_name)==null?void 0:ws.toLowerCase().includes(Qt))||((Rr=(ir=Kt.contact)==null?void 0:ir.last_name)==null?void 0:Rr.toLowerCase().includes(Qt))||((oa=Kt.property_address)==null?void 0:oa.toLowerCase().includes(Qt))||((ri=Kt.city)==null?void 0:ri.toLowerCase().includes(Qt)),dr=Y==="all"||Kt.deal_type===Y;return fs&&dr}),je=M.useMemo(()=>{if(!s)return l||null;const Kt=new Set(s.filter(bt=>bt.is_won_stage).map(bt=>bt.id)),Qt=new Set(s.filter(bt=>bt.is_lost_stage).map(bt=>bt.id)),fs=at.filter(bt=>!Kt.has(bt.stage_id)&&!Qt.has(bt.stage_id)),dr=at.filter(bt=>Kt.has(bt.stage_id));return{totalDeals:at.length,activeDeals:fs.length,wonDeals:dr.length,pipelineValue:fs.reduce((bt,ws)=>bt+(ws.expected_price||0),0),expectedCommission:fs.reduce((bt,ws)=>bt+(ws.expected_commission||0),0),expectedNetToAgent:fs.reduce((bt,ws)=>{const ir=ws.expected_commission||0;if(!ir)return bt;let Rr=ir;return ws.brokerage_split_pct&&(Rr-=ir*(ws.brokerage_split_pct/100)),ws.team_split_pct&&(Rr-=ir*(ws.team_split_pct/100)),ws.franchise_fee_pct&&(Rr-=ir*(ws.franchise_fee_pct/100)),ws.referral_fee_pct&&(Rr-=ir*(ws.referral_fee_pct/100)),ws.transaction_fee&&(Rr-=ws.transaction_fee),bt+Math.max(0,Rr)},0),wonValue:dr.reduce((bt,ws)=>bt+(ws.expected_price||0),0)}},[at,s,l]),mt=Kt=>{N(Kt),w(!0)},He=Kt=>{A(Kt||null),N(null),_(!0)},ct=Kt=>{N(Kt),w(!1),_(!0)},We=(Kt,Qt)=>{L(Kt)},Ze=(Kt,Qt)=>{Kt.preventDefault(),Kt.dataTransfer.dropEffect="move",$(Qt)},ht=async(Kt,Qt)=>{if(Kt.preventDefault(),$(null),!I)return;const fs=n==null?void 0:n.find(ws=>ws.id===I),dr=s==null?void 0:s.find(ws=>ws.id===Qt),bt=s==null?void 0:s.find(ws=>ws.id===(fs==null?void 0:fs.stage_id));if(!fs||!dr||fs.stage_id===Qt){L(null);return}ke({dealId:I,dealName:fs.deal_name,fromStageName:(bt==null?void 0:bt.name)||"Unknown",toStageName:dr.name,toStageId:Qt,isWonStage:dr.is_won_stage,deal:fs}),L(null)},Ke=async()=>{if(!ve)return;const{dealId:Kt,toStageId:Qt,toStageName:fs,isWonStage:dr,deal:bt}=ve;if(await u.mutateAsync({dealId:Kt,stageId:Qt,stageName:fs}),ge.success(`Moved to ${fs}`),dr&&!bt.scorecard_transaction_id){const ws={...bt,stage_id:Qt};Q(ws),H(!0)}},qe=M.useCallback(async(Kt,Qt,fs)=>{const dr=n==null?void 0:n.find(ir=>ir.id===Kt),bt=s==null?void 0:s.find(ir=>ir.id===Qt),ws=s==null?void 0:s.find(ir=>ir.id===(dr==null?void 0:dr.stage_id));!dr||!bt||dr.stage_id===Qt||ke({dealId:Kt,dealName:dr.deal_name,fromStageName:(ws==null?void 0:ws.name)||"Unknown",toStageName:fs,toStageId:Qt,isWonStage:bt.is_won_stage,deal:dr})},[n,s]),Je=Kt=>rt.filter(Qt=>Qt.stage_id===Kt),Lt=r||a,zt=t?"list":f;return e.jsxs(Ms,{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(Z,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(Ao,{className:"h-4 w-4"})}),!t&&e.jsx(HN,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(Z,{variant:f==="board"?"secondary":"ghost",size:"sm",onClick:()=>g("board"),className:"px-3 gap-1.5",children:[e.jsx(hp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(au,{children:"Kanban board view"})]}),e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(Z,{variant:f==="list"?"secondary":"ghost",size:"sm",onClick:()=>g("list"),className:"px-3 gap-1.5",children:[e.jsx(Fh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(au,{children:"Grouped list view"})]}),e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(Z,{variant:f==="table"?"secondary":"ghost",size:"sm",onClick:()=>g("table"),className:"px-3 gap-1.5",children:[e.jsx(h5,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(au,{children:"Sortable table view"})]}),e.jsxs(Mu,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(Z,{variant:f==="portals"?"secondary":"ghost",size:"sm",onClick:()=>g("portals"),className:"px-3 gap-1.5",children:[e.jsx(gn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(au,{children:"Client portal management"})]})]})}),Ge&&!Ne&&e.jsxs(Z,{variant:"outline",onClick:()=>le(!0),children:[e.jsx(xr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(Z,{onClick:()=>He(),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),zt!=="portals"&&e.jsx(Ocs,{stats:je,isLoading:i}),zt!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search deals, contacts, addresses...",value:se,onChange:Kt=>te(Kt.target.value),className:"pl-9 pr-8"}),se&&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(Vr,{className:"h-4 w-4"})})]}),e.jsxs(tr,{value:Y,onValueChange:ce,children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(rr,{placeholder:"All Types"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"}),e.jsx(At,{value:"dual",children:"Dual"}),e.jsx(At,{value:"referral",children:"Referral"}),e.jsx(At,{value:"lease",children:"Lease"})]})]}),(se||Y!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[rt.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(Acs,{members:Ae,enabledMembers:be,onToggleMember:dt,isOpen:de,onToggleOpen:()=>xe(Kt=>!Kt)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Lt?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Kt=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(gs,{className:"h-full rounded-xl"})},Kt))}):zt==="board"?e.jsxs(Fi,{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(Kt=>e.jsx(Dcs,{stage:Kt,deals:Je(Kt.id),onDealClick:mt,onAddDeal:He,onDragStart:We,onDragOver:Ze,onDrop:ht,isDragOver:F===Kt.id,isWonStage:Kt.is_won_stage,getOwnerInfo:Ve},Kt.id))}),e.jsx(woe,{orientation:"horizontal"})]}):zt==="table"?e.jsx(Fi,{className:"h-full",children:e.jsx(ads,{deals:rt,stages:s||[],onDealClick:mt,onStageChange:qe})}):zt==="portals"?e.jsx(_ds,{}):e.jsx(Fi,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Kt=>{const Qt=Je(Kt.id);return Qt.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:Kt.color}}),e.jsx("h3",{className:"font-semibold",children:Kt.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",Qt.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:Qt.map(fs=>e.jsx(yXe,{deal:fs,onClick:()=>mt(fs),stages:s,onStageChange:qe,showStagePicker:!0,isWonStage:Kt.is_won_stage,ownerInfo:Ve(fs)},fs.id))})]},Kt.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(hp,{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(Z,{onClick:()=>He(),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&rt.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(xn,{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(Z,{variant:"outline",onClick:()=>{te(""),ce("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(Bcs,{open:v,onOpenChange:_,deal:j,defaultStageId:S}),e.jsx(sds,{deal:j,open:b,onOpenChange:w,onEdit:ct,isWonStage:j?(is=s==null?void 0:s.find(Kt=>Kt.id===j.stage_id))==null?void 0:is.is_won_stage:!1,onAddToScorecard:Kt=>{Q(Kt),H(!0),w(!1)}}),e.jsx(rds,{open:q,onOpenChange:H,deal:U,onComplete:()=>{o(),Q(null)}}),ve&&e.jsx(xds,{open:!!ve,onOpenChange:Kt=>{Kt||ke(null)},dealId:ve.dealId,dealName:ve.dealName,fromStageName:ve.fromStageName,toStageName:ve.toStageName,toStageId:ve.toStageId,onConfirm:Ke}),e.jsx(Mcs,{open:oe,onOpenChange:le})]})}function jds(){return e.jsx(bds,{children:e.jsx(wds,{})})}function wXe({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var te;const o=lds(),l=cds(),{data:i}=mce(),d=vi(),{data:u}=Tt({queryKey:["contacts-for-tasks",d],queryFn:async()=>{if(!d)return[];const{data:Y,error:ce}=await K.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",d).order("first_name").limit(500);if(ce)throw ce;return Y},enabled:!!d&&t}),[f,g]=M.useState(""),[v,_]=M.useState(""),[b,w]=M.useState("none"),[j,N]=M.useState("none"),[S,A]=M.useState("medium"),[I,L]=M.useState("todo"),[F,$]=M.useState(),[q,H]=M.useState(!1),[U,Q]=M.useState(!1);M.useEffect(()=>{r?(g(r.title),_(r.description||""),w(r.deal_id||"none"),N(r.contact_id||"none"),A(r.priority),L(r.status),$(r.due_date?kh(r.due_date):void 0)):(g(""),_(""),w(n||"none"),N("none"),A("medium"),L("todo"),$(void 0))},[r,t,n]);const se=async()=>{if(!f.trim()){ge.error("Task title is required");return}try{const Y={title:f.trim(),description:v.trim()||null,deal_id:b==="none"?null:b,contact_id:j==="none"?null:j,stage_id:a||null,priority:S,status:I,due_date:F?js(F,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...Y}),ge.success("Task updated")):(await o.mutateAsync(Y),ge.success("Task created")),s(!1)}catch{ge.error("Failed to save task")}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[480px]",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title *"}),e.jsx(Re,{value:f,onChange:Y=>g(Y.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{value:v,onChange:Y=>_(Y.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Priority"}),e.jsxs(tr,{value:S,onValueChange:Y=>A(Y),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"low",children:"🟢 Low"}),e.jsx(At,{value:"medium",children:"🟡 Medium"}),e.jsx(At,{value:"high",children:"🟠 High"}),e.jsx(At,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Status"}),e.jsxs(tr,{value:I,onValueChange:Y=>L(Y),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"todo",children:"To Do"}),e.jsx(At,{value:"in_progress",children:"In Progress"}),e.jsx(At,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Due Date"}),e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",className:It("w-full justify-start text-left font-normal",!F&&"text-muted-foreground"),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),F?js(F,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(xp,{mode:"single",selected:F,onSelect:$,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Link to Deal"}),e.jsxs(No,{open:q,onOpenChange:H,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{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(_a,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),b!=="none"?((te=i==null?void 0:i.find(Y=>Y.id===b))==null?void 0:te.deal_name)||"Select deal":"No Deal"]}),e.jsx(of,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search deals..."}),e.jsxs(yf,{children:[e.jsx(vf,{children:"No deals found."}),e.jsxs(_f,{children:[e.jsxs(_m,{value:"no-deal",onSelect:()=>{w("none"),H(!1)},children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Y=>e.jsxs(_m,{value:Y.deal_name,onSelect:()=>{w(Y.id),H(!1)},children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",b===Y.id?"opacity-100":"opacity-0")}),Y.deal_name]},Y.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Link to Contact"}),e.jsxs(No,{open:U,onOpenChange:Q,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{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(mo,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),j!=="none"?(()=>{const Y=u==null?void 0:u.find(ce=>ce.id===j);return Y?`${Y.first_name} ${Y.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(of,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(gf,{children:[e.jsx(xf,{placeholder:"Search contacts..."}),e.jsxs(yf,{children:[e.jsx(vf,{children:"No contacts found."}),e.jsxs(_f,{children:[e.jsxs(_m,{value:"no-contact",onSelect:()=>{N("none"),Q(!1)},children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",j==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Y=>e.jsxs(_m,{value:`${Y.first_name} ${Y.last_name}`,onSelect:()=>{N(Y.id),Q(!1)},children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",j===Y.id?"opacity-100":"opacity-0")}),Y.first_name," ",Y.last_name]},Y.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Z,{onClick:se,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const kds={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 Nds({tasks:t}){const s=Kwe(),r=dds(),n=Or(),[a,o]=M.useState(null),l=async f=>{const g=f.status==="done"?"todo":"done";try{await s.mutateAsync({id:f.id,status:g})}catch{ge.error("Failed to update task")}},i=async f=>{try{await r.mutateAsync(f),ge.success("Task deleted")}catch{ge.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(Ma,{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 d=new Map,u=[];return t.forEach(f=>{if(f.deal){const g=d.get(f.deal.id)||{dealName:f.deal.deal_name,tasks:[]};g.tasks.push(f),d.set(f.deal.id,g)}else u.push(f)}),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(f=>e.jsx(JIe,{task:f,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:g=>n(`/mission-control/pipeline?deal=${g}`)},f.id))]}),Array.from(d.entries()).map(([f,g])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${f}`),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(_a,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:g.dealName}),e.jsxs(nt,{variant:"secondary",className:"ml-auto text-xs",children:[g.tasks.filter(v=>v.status==="done").length,"/",g.tasks.length]}),e.jsx(ei,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),g.tasks.map(v=>e.jsx(JIe,{task:v,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},v.id))]},f)),a&&e.jsx(wXe,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function JIe({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&Wx(kh(t.due_date))&&!Ld(kh(t.due_date)),i=!o&&t.due_date&&Ld(kh(t.due_date)),d=kds[t.priority];return e.jsxs("div",{className:It("flex items-center gap-3 px-4 py-3 border-b last:border-b-0 group hover:bg-muted/30 transition-colors",o&&"opacity-60"),children:[e.jsx("button",{onClick:()=>s(t),className:"shrink-0",children:o?e.jsx(Ma,{className:"h-5 w-5 text-emerald-500"}):e.jsx(qc,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:It("text-sm font-medium truncate",o&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(mo,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(nt,{variant:"outline",className:It("text-[10px] shrink-0",d.color),children:[d.dot," ",d.label]}),t.due_date&&e.jsxs("span",{className:It("text-xs shrink-0 flex items-center gap-1",l&&"text-destructive font-medium",i&&"text-amber-600 font-medium",!l&&!i&&"text-muted-foreground"),children:[e.jsx(Tn,{className:"h-3 w-3"}),js(kh(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(Pc,{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(Cr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const Sds=[{status:"todo",label:"To Do",icon:qc,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:mm,color:"border-t-blue-500"},{status:"done",label:"Done",icon:Ma,color:"border-t-emerald-500"}],Cds={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Mds({tasks:t}){const s=Kwe(),r=M.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 d=t.find(u=>u.id===i);if(!(!d||d.status===l))try{await s.mutateAsync({id:i,status:l})}catch{ge.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:Sds.map(o=>e.jsxs("div",{className:It("border rounded-lg border-t-4 bg-muted/20",o.color),onDragOver:l=>l.preventDefault(),onDrop:l=>a(l,o.status),children:[e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[e.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-sm",children:o.label}),e.jsx(nt,{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(Tds,{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 Tds({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&Wx(kh(t.due_date))&&!Ld(kh(t.due_date)),a=!r&&t.due_date&&Ld(kh(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:It("bg-background border rounded-lg p-3 cursor-grab active:cursor-grabbing shadow-sm hover:shadow-md transition-shadow",n&&"border-destructive/50"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs mt-0.5",children:Cds[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:It("text-sm font-medium",r&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.deal&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(_a,{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(mo,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:It("text-[10px] mt-1.5 flex items-center gap-1",n&&"text-destructive font-medium",a&&"text-amber-600 font-medium",!n&&!a&&"text-muted-foreground"),children:[e.jsx(Tn,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",js(kh(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 e6e={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Ads({tasks:t}){const[s,r]=M.useState(new Date),n=Kwe(),a=Bh(s),o=dL(s),l=Ju(a),i=xoe(o),d=O0t({start:l,end:i}),u=M.useMemo(()=>{const v=new Map;return t.forEach(_=>{if(!_.due_date)return;const b=_.due_date,w=v.get(b)||[];w.push(_),v.set(b,w)}),v},[t]),f=M.useMemo(()=>t.filter(v=>!v.due_date),[t]),g=async v=>{const _=v.status==="done"?"todo":"done";try{await n.mutateAsync({id:v.id,status:_})}catch{ge.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(Z,{variant:"ghost",size:"icon",onClick:()=>r(v9e(s,1)),children:e.jsx(ec,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:js(s,"MMMM yyyy")}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>r($h(s,1)),children:e.jsx(ei,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 text-center",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(v=>e.jsx("div",{className:"text-xs font-medium text-muted-foreground py-2",children:v},v))}),e.jsx("div",{className:"grid grid-cols-7 border-l border-t",children:d.map(v=>{const _=js(v,"yyyy-MM-dd"),b=u.get(_)||[],w=voe(v,s),j=Ld(v);return e.jsxs("div",{className:It("border-r border-b min-h-[100px] p-1",!w&&"bg-muted/30",j&&"bg-primary/5"),children:[e.jsx("div",{className:It("text-xs font-medium mb-1 text-right px-1",!w&&"text-muted-foreground/40",j&&"text-primary font-bold"),children:js(v,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(N=>e.jsxs("button",{onClick:()=>g(N),className:It("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",N.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[N.status==="done"?e.jsx(Ma,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(qc,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[e6e[N.priority]," ",N.title]})]},N.id)),b.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",b.length-3," more"]})]})]},_)})}),f.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 (",f.length,")"]}),e.jsx("div",{className:"space-y-1",children:f.map(v=>e.jsxs("button",{onClick:()=>g(v),className:It("w-full text-left text-xs px-2 py-1.5 rounded flex items-center gap-2 hover:bg-muted transition-colors",v.status==="done"&&"opacity-50 line-through"),children:[v.status==="done"?e.jsx(Ma,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(qc,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[e6e[v.priority]," ",v.title]}),v.deal&&e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0",children:["• ",v.deal.deal_name]})]},v.id))})]})]})}const Eds={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Pds({open:t,onOpenChange:s,stages:r}){var N;const[n,a]=M.useState(((N=r[0])==null?void 0:N.id)||""),{data:o,isLoading:l}=hds(n||void 0),i=mds(),d=pds(),[u,f]=M.useState(""),[g,v]=M.useState("medium"),[_,b]=M.useState(""),w=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:g,default_due_offset_days:_?parseInt(_):null,sort_order:((o==null?void 0:o.length)||0)+1}),f(""),b(""),ge.success("Template added")}catch{ge.error("Failed to add template")}},j=async S=>{try{await d.mutateAsync(S),ge.success("Template deleted")}catch{ge.error("Failed to delete template")}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[560px]",children:[e.jsx(Cs,{children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(VE,{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(_e,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(S=>!S.is_won_stage&&!S.is_lost_stage).map(S=>e.jsx("button",{onClick:()=>a(S.id),className:It("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===S.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:S.name},S.id))})]}),e.jsx(Fi,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((S,A)=>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:Eds[S.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:S.title}),S.default_due_offset_days&&e.jsxs(nt,{variant:"outline",className:"text-[10px]",children:["+",S.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>j(S.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(Cr,{className:"h-3.5 w-3.5 text-destructive"})})]},S.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Task title...",value:u,onChange:S=>f(S.target.value),className:"flex-1",onKeyDown:S=>S.key==="Enter"&&w()}),e.jsxs(tr,{value:g,onValueChange:S=>v(S),children:[e.jsx(Js,{className:"w-[100px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"low",children:"🟢 Low"}),e.jsx(At,{value:"medium",children:"🟡 Med"}),e.jsx(At,{value:"high",children:"🟠 High"}),e.jsx(At,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(_e,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(Re,{type:"number",placeholder:"e.g., 7",value:_,onChange:S=>b(S.target.value)})]}),e.jsxs(Z,{onClick:w,disabled:!u.trim()||i.isPending,children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function Ids(){const{data:t,isLoading:s}=ids(),{data:r}=hce(),[n,a]=M.useState("list"),[o,l]=M.useState(""),[i,d]=M.useState("active"),[u,f]=M.useState("all"),[g,v]=M.useState("all"),[_,b]=M.useState(!1),[w,j]=M.useState(!1),N=M.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,F])=>({id:L,name:F}))},[t]),S=M.useMemo(()=>t?t.filter(I=>{var U,Q,se,te;const L=o.toLowerCase(),F=!L||I.title.toLowerCase().includes(L)||((Q=(U=I.deal)==null?void 0:U.deal_name)==null?void 0:Q.toLowerCase().includes(L))||`${((se=I.contact)==null?void 0:se.first_name)||""} ${((te=I.contact)==null?void 0:te.last_name)||""}`.toLowerCase().includes(L),$=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&&Wx(kh(I.due_date))&&!Ld(kh(I.due_date)),q=u==="all"||I.priority===u,H=g==="all"||g==="no_deal"&&!I.deal_id||I.deal_id===g;return F&&$&&q&&H}):[],[t,o,i,u,g]),A=M.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&&Wx(kh(L.due_date))&&!Ld(kh(L.due_date))).length,dueToday:I.filter(L=>L.due_date&&Ld(kh(L.due_date))).length,dueThisWeek:I.filter(L=>L.due_date&&P1t(kh(L.due_date))).length,completed:t.filter(L=>L.status==="done").length}},[t]);return e.jsx(Ms,{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(Z,{variant:"outline",size:"sm",onClick:()=>j(!0),children:[e.jsx(y0,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(Z,{size:"sm",onClick:()=>b(!0),children:[e.jsx(Ys,{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:()=>d("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(Fh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.total})]}),e.jsxs("button",{onClick:()=>d("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(jh,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:A.overdue})]}),e.jsxs("button",{onClick:()=>{d("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(Tn,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.dueToday})]}),e.jsxs("button",{onClick:()=>{d("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(jc,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.dueThisWeek})]}),e.jsxs("button",{onClick:()=>d("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(Ma,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search tasks...",value:o,onChange:I=>l(I.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:u,onValueChange:f,children:[e.jsx(Js,{className:"w-[130px]",children:e.jsx(rr,{placeholder:"Priority"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Priorities"}),e.jsx(At,{value:"urgent",children:"🔴 Urgent"}),e.jsx(At,{value:"high",children:"🟠 High"}),e.jsx(At,{value:"medium",children:"🟡 Medium"}),e.jsx(At,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(rr,{placeholder:"Deal"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Deals"}),e.jsx(At,{value:"no_deal",children:"No Deal"}),N.map(I=>e.jsx(At,{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(Fh,{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(Bx,{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(jc,{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(Nds,{tasks:S}),n==="kanban"&&e.jsx(Mds,{tasks:S}),n==="calendar"&&e.jsx(Ads,{tasks:S})]}),e.jsx(wXe,{open:_,onOpenChange:b}),e.jsx(Pds,{open:w,onOpenChange:j,stages:r||[]})]})})}const o0e=[{value:"video_intro",label:"Video Intro",icon:Cn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:sP,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:pp,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:Al,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:nd,description:"Links to your social profiles"}],Lds=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],Dds={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function jXe({cardId:t}){const{data:s,isLoading:r}=Byt(t),n=$yt(),a=qyt(),o=Uyt(),[l,i]=M.useState(!1),[d,u]=M.useState(""),[f,g]=M.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(gs,{className:"h-16 w-full"}),e.jsx(gs,{className:"h-16 w-full"})]});const v=()=>{d&&n.mutate({card_id:t,block_type:d,sort_order:(s==null?void 0:s.length)||0,config:Dds[d]||{}},{onSuccess:()=>{i(!1),u("")}})},_=S=>{a.mutate({id:S.id,is_visible:!S.is_visible})},b=(S,A)=>{if(!s)return;const I=s.findIndex($=>$.id===S.id),L=A==="up"?I-1:I+1;if(L<0||L>=s.length)return;const F=s[L];a.mutate({id:S.id,sort_order:F.sort_order}),a.mutate({id:F.id,sort_order:S.sort_order})},w=S=>{confirm("Remove this block from this card?")&&o.mutate(S.id)},j=(S,A)=>{a.mutate({id:S.id,config:A},{onSuccess:()=>g(null)})},N=S=>o0e.find(A=>A.value===S);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(Z,{size:"sm",onClick:()=>i(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((S,A)=>{const I=N(S.block_type),L=(I==null?void 0:I.icon)||pp;return e.jsx(De,{className:S.is_visible?"":"opacity-50",children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rh,{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)||S.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ods(S)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(S,"up"),disabled:A===0,children:e.jsx(Rd,{className:"h-3 w-3"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(S,"down"),disabled:A===s.length-1,children:e.jsx(Ku,{className:"h-3 w-3"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S),children:S.is_visible?e.jsx(Na,{className:"h-3 w-3"}):e.jsx(Nm,{className:"h-3 w-3"})}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>g(S),children:"Edit"}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>w(S),children:e.jsx(Cr,{className:"h-3 w-3"})})]})]})})},S.id)}),e.jsxs(Z,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(bs,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:o0e.map(S=>{const A=S.icon;return e.jsxs("button",{onClick:()=>u(S.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${d===S.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(A,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:S.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.description})]})]},S.value)})}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(Z,{onClick:v,disabled:!d||n.isPending,children:"Add Block"})]})]})}),f&&e.jsx(Rds,{block:f,onSave:S=>j(f,S),onClose:()=>g(null)})]})}function Ods(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 Rds({block:t,onSave:s,onClose:r}){const[n,a]=M.useState(t.config),o=o0e.find(l=>l.value===t.block_type);return e.jsx(bs,{open:!0,onOpenChange:r,children:e.jsxs(_s,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(Fds,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(zds,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(Bds,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx($ds,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(qds,{config:n,onChange:a}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(Z,{onClick:()=>s(n),children:"Save"})]})]})})}function Fds({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=M.useState(""),[o,l]=M.useState((_=t.video_url)!=null&&_.includes("youtube")||(b=t.video_url)!=null&&b.includes("youtu.be")?"youtube":"library"),{data:i}=Tt({queryKey:["card-owner",r],queryFn:async()=>{const{data:w}=await K.from("agent_cards").select("user_id").eq("id",r).single();return w==null?void 0:w.user_id},enabled:!!r}),{data:d,isLoading:u}=Tt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:w,error:j}=await K.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(j)throw j;return w||[]},enabled:!!i}),f=(d==null?void 0:d.filter(w=>!n||(w.title||"").toLowerCase().includes(n.toLowerCase())))||[],g=t.bunny_video_id,v=w=>{var A;const j=(A=w.playback_url)==null?void 0:A.match(/\/(?:play|embed)\/(\d+)\//),S=`https://iframe.mediadelivery.net/embed/${j?j[1]:"570924"}/${w.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:S,bunny_video_id:w.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(Ia,{value:o,onValueChange:l,children:[e.jsxs(Aa,{className:"w-full",children:[e.jsx(Ts,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(Ts,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(Vs,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search videos...",value:n,onChange:w=>a(w.target.value),className:"pl-9"})]}),e.jsx(Fi,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(gs,{className:"h-14 w-full"}),e.jsx(gs,{className:"h-14 w-full"})]}):f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:(d==null?void 0:d.length)===0?"No videos in library yet":"No matching videos"}):e.jsx("div",{className:"space-y-1.5 pr-3",children:f.map(w=>e.jsxs("button",{onClick:()=>v(w),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${g===w.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:j=>{var N;j.currentTarget.style.display="none",(N=j.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 ${w.thumbnail_url?"hidden":""}`,children:e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:w.title||"Untitled Video"}),g===w.bunny_video_id&&e.jsx(ma,{className:"h-4 w-4 text-primary flex-shrink-0"})]},w.id))})})]}),e.jsx(Vs,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(_e,{children:"YouTube URL"}),e.jsx(Re,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:w=>s({...t,video_url:w.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function zds({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,d)=>{const u=[...r];u[l]={...u[l],[i]:d},s({...t,testimonials:u})},a=()=>s({...t,testimonials:[...r,{name:"",quote:"",role:""}]}),o=l=>s({...t,testimonials:r.filter((i,d)=>d!==l)});return e.jsxs("div",{className:"space-y-4",children:[r.map((l,i)=>e.jsx(De,{children:e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),r.length>1&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(Cr,{className:"h-3 w-3"})})]}),e.jsx(Re,{placeholder:"Client name",value:l.name,onChange:d=>n(i,"name",d.target.value)}),e.jsx(Re,{placeholder:"Role/title (optional)",value:l.role||"",onChange:d=>n(i,"role",d.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:d=>n(i,"quote",d.target.value)})]})},i)),e.jsxs(Z,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function Bds({config:t,onChange:s}){const r=t.tags||[],[n,a]=M.useState(""),o=i=>{s({...t,tags:r.includes(i)?r.filter(d=>d!==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(_e,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Lds.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(_e,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(Z,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(_e,{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 $ds({config:t,onChange:s}){const r=t.links||[],n=(l,i,d)=>{const u=[...r];u[l]={...u[l],[i]:d},s({...t,links:u})},a=()=>s({...t,links:[...r,{label:"",url:""}]}),o=l=>s({...t,links:r.filter((i,d)=>d!==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(Re,{placeholder:"Button label",value:l.label,onChange:d=>n(i,"label",d.target.value)}),e.jsx(Re,{placeholder:"https://...",value:l.url,onChange:d=>n(i,"url",d.target.value)})]}),r.length>1&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(Cr,{className:"h-3 w-3"})})]},i)),e.jsxs(Z,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const t6e=[{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 qds({config:t,onChange:s}){const r=t.platforms||[],n=d=>{r.find(u=>u.platform===d)||s({...t,platforms:[...r,{platform:d,url:""}]})},a=(d,u)=>{const f=[...r];f[d]={...f[d],url:u},s({...t,platforms:f})},o=d=>{s({...t,platforms:r.filter((u,f)=>f!==d)})},l=t6e.filter(d=>!r.find(u=>u.platform===d.value)),i=d=>{const u=yge[d],f=t6e.find(g=>g.value===d);return{label:(f==null?void 0:f.label)||d,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((d,u)=>{const f=i(d.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:f.color+"30",backgroundColor:f.color+"10"},children:f.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:f.color,children:e.jsx("path",{d:f.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(Re,{placeholder:`Your ${f.label} profile URL`,value:d.url,onChange:g=>a(u,g.target.value)})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(_e,{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(d=>{const u=yge[d.value];return e.jsxs("button",{onClick:()=>n(d.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})}),d.label]},d.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 Uds=Object.defineProperty,uie=Object.getOwnPropertySymbols,kXe=Object.prototype.hasOwnProperty,NXe=Object.prototype.propertyIsEnumerable,s6e=(t,s,r)=>s in t?Uds(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,l0e=(t,s)=>{for(var r in s||(s={}))kXe.call(s,r)&&s6e(t,r,s[r]);if(uie)for(var r of uie(s))NXe.call(s,r)&&s6e(t,r,s[r]);return t},c0e=(t,s)=>{var r={};for(var n in t)kXe.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&uie)for(var n of uie(t))s.indexOf(n)<0&&NXe.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var $N;(t=>{const s=class eo{constructor(d,u,f,g){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],deo.MAX_VERSION)throw new RangeError("Version value out of range");if(g<-1||g>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let v=[];for(let b=0;b7)throw new RangeError("Invalid value");let b,w;for(b=f;;b++){const A=eo.getNumDataCodewords(b,u)*8,I=l.getTotalBits(d,b);if(I<=A){w=I;break}if(b>=g)throw new RangeError("Data too long")}for(const A of[eo.Ecc.MEDIUM,eo.Ecc.QUARTILE,eo.Ecc.HIGH])_&&w<=eo.getNumDataCodewords(b,A)*8&&(u=A);let j=[];for(const A of d){r(A.mode.modeBits,4,j),r(A.numChars,A.mode.numCharCountBits(b),j);for(const I of A.getData())j.push(I)}a(j.length==w);const N=eo.getNumDataCodewords(b,u)*8;a(j.length<=N),r(0,Math.min(4,N-j.length),j),r(0,(8-j.length%8)%8,j),a(j.length%8==0);for(let A=236;j.lengthS[I>>>3]|=A<<7-(I&7)),new eo(b,u,S,v)}getModule(d,u){return 0<=d&&d>>9)*1335;const g=(u<<10|f)^21522;a(g>>>15==0);for(let v=0;v<=5;v++)this.setFunctionModule(8,v,n(g,v));this.setFunctionModule(8,7,n(g,6)),this.setFunctionModule(8,8,n(g,7)),this.setFunctionModule(7,8,n(g,8));for(let v=9;v<15;v++)this.setFunctionModule(14-v,8,n(g,v));for(let v=0;v<8;v++)this.setFunctionModule(this.size-1-v,8,n(g,v));for(let v=8;v<15;v++)this.setFunctionModule(8,this.size-15+v,n(g,v));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let f=0;f<12;f++)d=d<<1^(d>>>11)*7973;const u=this.version<<12|d;a(u>>>18==0);for(let f=0;f<18;f++){const g=n(u,f),v=this.size-11+f%3,_=Math.floor(f/3);this.setFunctionModule(v,_,g),this.setFunctionModule(_,v,g)}}drawFinderPattern(d,u){for(let f=-4;f<=4;f++)for(let g=-4;g<=4;g++){const v=Math.max(Math.abs(g),Math.abs(f)),_=d+g,b=u+f;0<=_&&_{(A!=w-v||L>=b)&&S.push(I[A])});return a(S.length==_),S}drawCodewords(d){if(d.length!=Math.floor(eo.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let g=0;g>>3],7-(u&7)),u++)}}a(u==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let u=0;u5&&d++):(this.finderPenaltyAddHistory(b,w),_||(d+=this.finderPenaltyCountPatterns(w)*eo.PENALTY_N3),_=this.modules[v][j],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,w)*eo.PENALTY_N3}for(let v=0;v5&&d++):(this.finderPenaltyAddHistory(b,w),_||(d+=this.finderPenaltyCountPatterns(w)*eo.PENALTY_N3),_=this.modules[j][v],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,w)*eo.PENALTY_N3}for(let v=0;v_+(b?1:0),u);const f=this.size*this.size,g=Math.ceil(Math.abs(u*20-f*10)/f)-1;return a(0<=g&&g<=9),d+=g*eo.PENALTY_N4,a(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let f=[6];for(let g=this.size-7;f.lengtheo.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*d+128)*d+64;if(d>=2){const f=Math.floor(d/7)+2;u-=(25*f-10)*f-55,d>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(d,u){return Math.floor(eo.getNumRawDataModules(d)/8)-eo.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d]*eo.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let u=[];for(let g=0;g0);for(const g of d){const v=g^f.shift();f.push(0),u.forEach((_,b)=>f[b]^=eo.reedSolomonMultiply(_,v))}return f}static reedSolomonMultiply(d,u){if(d>>>8||u>>>8)throw new RangeError("Byte out of range");let f=0;for(let g=7;g>=0;g--)f=f<<1^(f>>>7)*285,f^=(u>>>g&1)*d;return a(f>>>8==0),f}finderPenaltyCountPatterns(d){const u=d[1];a(u<=this.size*3);const f=u>0&&d[2]==u&&d[3]==u*3&&d[4]==u&&d[5]==u;return(f&&d[0]>=u*4&&d[6]>=u?1:0)+(f&&d[6]>=u*4&&d[0]>=u?1:0)}finderPenaltyTerminateAndCount(d,u,f){return d&&(this.finderPenaltyAddHistory(u,f),u=0),u+=this.size,this.finderPenaltyAddHistory(u,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(d,u){u[0]==0&&(d+=this.size),u.pop(),u.unshift(d)}};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,d,u){if(d<0||d>31||i>>>d)throw new RangeError("Value out of range");for(let f=d-1;f>=0;f--)u.push(i>>>f&1)}function n(i,d){return(i>>>d&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class Ac{constructor(d,u,f){if(this.mode=d,this.numChars=u,this.bitData=f,u<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(d){let u=[];for(const f of d)r(f,8,u);return new Ac(Ac.Mode.BYTE,d.length,u)}static makeNumeric(d){if(!Ac.isNumeric(d))throw new RangeError("String contains non-numeric characters");let u=[];for(let f=0;f=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={}))})($N||($N={}));(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={}))})($N||($N={}));var D4=$N;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var Vds={L:D4.QrCode.Ecc.LOW,M:D4.QrCode.Ecc.MEDIUM,Q:D4.QrCode.Ecc.QUARTILE,H:D4.QrCode.Ecc.HIGH},SXe=128,CXe="L",MXe="#FFFFFF",TXe="#000000",AXe=!1,EXe=1,Hds=4,Wds=0,Gds=.1;function PXe(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 IXe(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 Kds(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*Gds),l=a/s,i=(n.width||o)*l,d=(n.height||o)*l,u=n.x==null?t.length/2-i/2:n.x*l,f=n.y==null?t.length/2-d/2:n.y*l,g=n.opacity==null?1:n.opacity;let v=null;if(n.excavate){let b=Math.floor(u),w=Math.floor(f),j=Math.ceil(i+u-b),N=Math.ceil(d+f-w);v={x:b,y:w,w:j,h:N}}const _=n.crossOrigin;return{x:u,y:f,h:d,w:i,excavation:v,opacity:g,crossOrigin:_}}function Zds(t,s){return s!=null?Math.max(Math.floor(s),0):t?Hds:Wds}function LXe({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let d=ut.useMemo(()=>{const b=(Array.isArray(t)?t:[t]).reduce((w,j)=>(w.push(...D4.QrSegment.makeSegments(j)),w),[]);return D4.QrCode.encodeSegments(b,Vds[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:f,numCells:g,calculatedImageSettings:v}=ut.useMemo(()=>{let _=d.getModules();const b=Zds(n,a),w=_.length+b*2,j=Kds(_,l,b,o);return{cells:_,margin:b,numCells:w,calculatedImageSettings:j}},[d,l,o,n,a]);return{qrcode:d,margin:f,cells:u,numCells:g,calculatedImageSettings:v}}var Yds=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Xds=ut.forwardRef(function(s,r){const n=s,{value:a,size:o=SXe,level:l=CXe,bgColor:i=MXe,fgColor:d=TXe,includeMargin:u=AXe,minVersion:f=EXe,boostLevel:g,marginSize:v,imageSettings:_}=n,w=c0e(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:j}=w,N=c0e(w,["style"]),S=_==null?void 0:_.src,A=ut.useRef(null),I=ut.useRef(null),L=ut.useCallback(Y=>{A.current=Y,typeof r=="function"?r(Y):r&&(r.current=Y)},[r]),[F,$]=ut.useState(!1),{margin:q,cells:H,numCells:U,calculatedImageSettings:Q}=LXe({value:a,level:l,minVersion:f,boostLevel:g,includeMargin:u,marginSize:v,imageSettings:_,size:o});ut.useEffect(()=>{if(A.current!=null){const Y=A.current,ce=Y.getContext("2d");if(!ce)return;let oe=H;const le=I.current,de=Q!=null&&le!==null&&le.complete&&le.naturalHeight!==0&&le.naturalWidth!==0;de&&Q.excavation!=null&&(oe=IXe(H,Q.excavation));const xe=window.devicePixelRatio||1;Y.height=Y.width=o*xe;const be=o/U*xe;ce.scale(be,be),ce.fillStyle=i,ce.fillRect(0,0,U,U),ce.fillStyle=d,Yds?ce.fill(new Path2D(PXe(oe,q))):H.forEach(function(ye,ve){ye.forEach(function(ke,Ge){ke&&ce.fillRect(Ge+q,ve+q,1,1)})}),Q&&(ce.globalAlpha=Q.opacity),de&&ce.drawImage(le,Q.x+q,Q.y+q,Q.w,Q.h)}}),ut.useEffect(()=>{$(!1)},[S]);const se=l0e({height:o,width:o},j);let te=null;return S!=null&&(te=ut.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{$(!0)},ref:I,crossOrigin:Q==null?void 0:Q.crossOrigin})),ut.createElement(ut.Fragment,null,ut.createElement("canvas",l0e({style:se,height:o,width:o,ref:L,role:"img"},N)),te)});Xds.displayName="QRCodeCanvas";var Zwe=ut.forwardRef(function(s,r){const n=s,{value:a,size:o=SXe,level:l=CXe,bgColor:i=MXe,fgColor:d=TXe,includeMargin:u=AXe,minVersion:f=EXe,boostLevel:g,title:v,marginSize:_,imageSettings:b}=n,w=c0e(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:j,cells:N,numCells:S,calculatedImageSettings:A}=LXe({value:a,level:l,minVersion:f,boostLevel:g,includeMargin:u,marginSize:_,imageSettings:b,size:o});let I=N,L=null;b!=null&&A!=null&&(A.excavation!=null&&(I=IXe(N,A.excavation)),L=ut.createElement("image",{href:b.src,height:A.h,width:A.w,x:A.x+j,y:A.y+j,preserveAspectRatio:"none",opacity:A.opacity,crossOrigin:A.crossOrigin}));const F=PXe(I,j);return ut.createElement("svg",l0e({height:o,width:o,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},w),!!v&&ut.createElement("title",null,v),ut.createElement("path",{fill:i,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),ut.createElement("path",{fill:d,d:F,shapeRendering:"crispEdges"}),L)});Zwe.displayName="QRCodeSVG";function Qds({slug:t,agentName:s}){const r=M.useRef(null),n=`https://cards.relevelup.com/${t}`,a=M.useCallback(()=>{var g;const o=(g=r.current)==null?void 0:g.querySelector("svg");if(!o)return;const l=document.createElement("canvas"),i=1024;l.width=i,l.height=i;const d=l.getContext("2d");if(!d)return;const u=new XMLSerializer().serializeToString(o),f=new Image;f.onload=()=>{d.fillStyle="#ffffff",d.fillRect(0,0,i,i),d.drawImage(f,0,0,i,i);const v=document.createElement("a");v.download=`${t}-qr-code.png`,v.href=l.toDataURL("image/png"),v.click(),ge.success("QR code downloaded!")},f.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(u)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{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(Zwe,{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(Z,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(Ei,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function tpe(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 Jds(){const{user:t}=Qs(),{data:s,isLoading:r}=Ryt(t==null?void 0:t.id),n=xM(),[a,o]=M.useState(null),l=M.useMemo(()=>a||(s?tpe(s):null),[a,s]);if(r)return e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(gs,{className:"h-8 w-48"}),e.jsx(gs,{className:"h-32 w-full"}),e.jsx(gs,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ms,{children:e.jsx(tus,{userId:t==null?void 0:t.id})});const i=l||tpe(s),d=u=>{o(f=>{const g=f||tpe(s);return typeof u=="function"?u(g):u})};return e.jsx(Ms,{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(sus,{card:s}),e.jsx(ius,{card:s,form:i,setForm:d})]}),!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(Xk,{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(eus,{card:s,form:i})})]})})]})})}function eus({card:t,form:s}){const{data:r}=Tt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await K.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 K.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=K.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=M.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(L1e,{card:n})})}function tus({userId:t}){var d;const[s,r]=M.useState(""),n=WBe(),{data:a}=Tt({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await K.from("profiles").select("name").eq("id",t).single();return u},enabled:!!t}),o=((d=a==null?void 0:a.name)==null?void 0:d.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){ge.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:u,is_published:!0},{onSuccess:()=>ge.success("Your digital card has been created!")})},i=[{icon:up,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Tm,title:"Lead Capture",desc:"Collect leads automatically"},{icon:Xu,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:El,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(gn,{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(De,{className:"shadow-lg border-2",children:[e.jsxs($t,{className:"text-center pb-2",children:[e.jsx(Vt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(_r,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Oe,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(_e,{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(Re,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(Z,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(gn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function sus({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),ge.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(nt,{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(up,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",t.slug]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Z,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(Ni,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(Z,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(un,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function rus({userId:t}){const s=ds(),r=M.useRef(null),[n,a]=M.useState(!1),[o,l]=M.useState(""),{data:i,isLoading:d}=Tt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:Q}=await K.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let se=(Q==null?void 0:Q.avatar_url)||null;if(!se){const{data:te}=await K.storage.from("avatars").list(`${t}`);if(te&&te.length>0){const{data:Y}=K.storage.from("avatars").getPublicUrl(`${t}/${te[0].name}`);se=`${Y.publicUrl}?t=${Date.now()}`,await K.from("profiles").update({avatar_url:se}).eq("id",t)}}return{...Q,avatar_url:se}}}),[u,f]=M.useState(null),[g,v]=M.useState(null),[_,b]=M.useState(null),[w,j]=M.useState(!1),N=u??(i==null?void 0:i.name)??"",S=g??(i==null?void 0:i.phone)??"",A=_??(i==null?void 0:i.email)??"",I=i==null?void 0:i.avatar_url,L=((i==null?void 0:i.name)||"A").split(" ").map(Q=>Q[0]).join("").toUpperCase().slice(0,2),F=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),$=Bt({mutationFn:async Q=>{const{error:se}=await K.from("profiles").update(Q).eq("id",t);if(se)throw se},onSuccess:()=>{s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),ge.success("Profile updated!")},onError:()=>ge.error("Failed to update profile")}),q=()=>{const Q={};if(u!==null&&u!==(i==null?void 0:i.name)&&(Q.name=u),g!==null&&g!==(i==null?void 0:i.phone)&&(Q.phone=g||null),_!==null&&_!==(i==null?void 0:i.email)&&(Q.email=_),Object.keys(Q).length===0){ge.info("No changes to save");return}$.mutate(Q)},H=Q=>{var Y;const se=(Y=Q.target.files)==null?void 0:Y[0];if(!se)return;if(!se.type.startsWith("image/")){ge.error("Please select an image file");return}const te=new FileReader;te.onloadend=()=>{l(te.result),a(!0)},te.readAsDataURL(se),Q.target.value=""},U=async Q=>{j(!0);try{const{data:se}=await K.storage.from("avatars").list(`${t}`);se&&se.length>0&&await K.storage.from("avatars").remove(se.map(le=>`${t}/${le.name}`));const te=`${t}/avatar.jpg`,{error:Y}=await K.storage.from("avatars").upload(te,Q,{upsert:!0,contentType:"image/jpeg"});if(Y)throw Y;const{data:ce}=K.storage.from("avatars").getPublicUrl(te),oe=ce.publicUrl+"?t="+Date.now();await K.from("profiles").update({avatar_url:oe}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),ge.success("Photo updated!")}catch{ge.error("Failed to upload photo")}finally{j(!1)}};return d?e.jsx(gs,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(De,{className:F?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(Oe,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(_e,{className:"text-sm font-semibold",children:"Profile Info"}),F&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(Yo,{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 Q;return(Q=r.current)==null?void 0:Q.click()},children:[e.jsxs(mn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(ba,{src:I||void 0,alt:N}),e.jsx(pn,{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(Mg,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:H})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:w?"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(_e,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(Re,{value:N,onChange:Q=>f(Q.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(_e,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(Re,{value:S,onChange:Q=>v(Q.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(Re,{value:A,onChange:Q=>b(Q.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(Z,{variant:"outline",size:"sm",onClick:q,disabled:$.isPending,className:"w-full",children:$.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(ibe,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:U,aspectRatio:1})]})}function nus({form:t,setForm:s,userId:r}){const[n,a]=M.useState(null),[o,l]=M.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=M.useState(t.team_logo_url?"logo":"name"),u=_=>{l(_),s(_==="name"?b=>({...b,brokerage_logo_url:""}):b=>({...b,brokerage_display_name:""}))},f=_=>{d(_),s(_==="name"?b=>({...b,team_logo_url:""}):b=>({...b,team_name:""}))},g=async(_,b)=>{var j;const w=(j=_.target.files)==null?void 0:j[0];if(w){if(!w.type.startsWith("image/")){ge.error("Please select an image file");return}a(b);try{const N=w.name.split(".").pop()||"png",A=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${N}`,{error:I}=await K.storage.from("card-logos").upload(A,w,{upsert:!0});if(I)throw I;const{data:L}=K.storage.from("card-logos").getPublicUrl(A),F=L.publicUrl+"?t="+Date.now();s(b==="brokerage_logo_url"?$=>({...$,[b]:F,brokerage_display_name:""}):$=>({...$,[b]:F,team_name:""})),ge.success("Logo uploaded!")}catch{ge.error("Failed to upload logo")}finally{a(null),_.target.value=""}}},v=_=>{s(b=>({...b,[_]:""}))};return e.jsx(De,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(_e,{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(_e,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("name"),children:"Use Name"}),e.jsx(Z,{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(_e,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(Re,{value:t.brokerage_display_name,onChange:_=>s(b=>({...b,brokerage_display_name:_.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{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:()=>v("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(Mg,{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:_=>g(_,"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(_e,{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(kg,{value:[t.brokerage_logo_size||56],onValueChange:([_])=>s(b=>({...b,brokerage_logo_size:_})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(_e,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>f("name"),children:"Use Name"}),e.jsx(Z,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>f("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(Re,{value:t.team_name,onChange:_=>s(b=>({...b,team_name:_.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{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:()=>v("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(Mg,{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:_=>g(_,"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(_e,{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(kg,{value:[t.team_logo_size||56],onValueChange:([_])=>s(b=>({...b,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function aus({form:t,setForm:s}){const r={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=t.bold_theme_colors||r,a=(i,d)=>{s(u=>({...u,bold_theme_colors:{...r,...u.bold_theme_colors,[i]:d}}))},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(_e,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(El,{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(Z,{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:d,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:f=>a(i,f.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:d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(Re,{value:n[i],onChange:f=>{const g=f.target.value;/^#[0-9a-fA-F]{0,6}$/.test(g)&&a(i,g)},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 ius({card:t,form:s,setForm:r}){var w;const n=GBe(),a=ds(),{data:o}=KBe(t.id),[l,i]=M.useState(t.slug),[d,u]=M.useState(!1),[f,g]=M.useState("idle"),v=M.useRef(JSON.stringify(s)),_=M.useRef(null);M.useEffect(()=>{const j=JSON.stringify(s);if(j!==v.current)return _.current&&clearTimeout(_.current),_.current=setTimeout(()=>{g("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:()=>{v.current=j,g("saved"),setTimeout(()=>g("idle"),2e3)},onError:()=>g("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[s]);const b=async()=>{const j=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!j){ge.error("Please enter a valid URL");return}if(j===t.slug){ge.info("No changes to save");return}u(!0);try{const{data:N}=await K.from("agent_cards").select("id").eq("slug",j).neq("id",t.id).maybeSingle();if(N){ge.error("This URL is already taken. Try another one.");return}const{error:S}=await K.from("agent_cards").update({slug:j}).eq("id",t.id);if(S)throw S;i(j),a.invalidateQueries({queryKey:["agent-card"]}),ge.success("Card address updated!")}catch{ge.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ia,{defaultValue:"content",children:[e.jsxs(Aa,{className:"w-full h-11 p-1",children:[e.jsxs(Ts,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(cp,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(Ts,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Na,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(Ts,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Tm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(Ts,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(eN,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(Ts,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Z1,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(Vs,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(rus,{userId:t.user_id}),e.jsx(nus,{form:s,setForm:r,userId:t.user_id}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-semibold",children:"Card Status"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Toggle your card on or off"})]}),e.jsx(qr,{checked:s.is_published,onCheckedChange:j=>r(N=>({...N,is_published:j}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{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(Re,{value:l,onChange:j=>i(j.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(Z,{variant:"outline",size:"sm",onClick:b,disabled:d||l===t.slug,className:"shrink-0",children:d?"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(_e,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(Re,{value:s.display_email,onChange:j=>r(N=>({...N,display_email:j.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(tr,{value:s.theme,onValueChange:j=>r(N=>({...N,theme:j})),children:[e.jsx(Js,{className:"h-11",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(At,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(At,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(At,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(aus,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(Re,{value:s.title,onChange:j=>r(N=>({...N,title:j.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(Re,{value:s.positioning_statement,onChange:j=>r(N=>({...N,positioning_statement:j.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Lr,{value:s.bio,onChange:j=>r(N=>({...N,bio:j.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(Re,{value:s.review_snippet,onChange:j=>r(N=>({...N,review_snippet:j.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(Re,{value:s.review_source_url,onChange:j=>r(N=>({...N,review_source_url:j.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(Re,{value:s.booking_url,onChange:j=>r(N=>({...N,booking_url:j.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(Re,{value:s.custom_cta_label,onChange:j=>r(N=>({...N,custom_cta_label:j.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(Vs,{value:"sections",className:"mt-4",children:e.jsx(De,{children:e.jsx(Oe,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:j,label:N,desc:S})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:N}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsx(qr,{checked:s[j],onCheckedChange:A=>r(I=>({...I,[j]:A}))})]},j))})})}),e.jsx(Vs,{value:"blocks",className:"mt-4",children:e.jsx(jXe,{cardId:t.id})}),e.jsx(Vs,{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:Na,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:Z1,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((w=o==null?void 0:o.leads)==null?void 0:w.length)??0,icon:pc,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(j=>e.jsx(De,{className:"overflow-hidden",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${j.color}`,children:e.jsx(j.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:j.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:j.value})]})},j.label))}),o&&o.leads.length>0&&e.jsxs(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsx(Vt,{className:"text-base",children:"Recent Leads"})}),e.jsx(Oe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(j=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:j.name}),j.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:j.phone})]}),j.intent&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:j.intent})]},j.id))})]}),(!o||o.leads.length===0)&&e.jsx(De,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(Z1,{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(Vs,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(De,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(Qds,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[f==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),f==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),f==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function ous(){const t=ds(),[s,r]=M.useState(""),[n,a]=M.useState(!1),[o,l]=M.useState(!1),[i,d]=M.useState(null),[u,f]=M.useState(!1),[g,v]=M.useState(!1),[_,b]=M.useState(null),[w,j]=M.useState(null),[N,S]=M.useState(0),{data:A,isLoading:I}=Tt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:te,error:Y}=await K.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Y)throw Y;return te}}),L=Bt({mutationFn:async te=>{const{data:Y,error:ce}=await K.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:te}});if(ce)throw ce;if(Y!=null&&Y.error)throw new Error(Y.error);return Y},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),ge.success("BoldTrail connected successfully!")},onError:te=>{ge.error(te.message||"Failed to connect BoldTrail")}}),F=Bt({mutationFn:async()=>{const{data:te,error:Y}=await K.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(Y)throw Y;return te},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),ge.success("BoldTrail disconnected")},onError:()=>ge.error("Failed to disconnect")}),$=Bt({mutationFn:async te=>{const{data:Y,error:ce}=await K.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:te}});if(ce)throw ce;if(Y!=null&&Y.error)throw new Error(Y.error);return Y},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),ge.success("Sync direction saved")},onError:te=>{ge.error(te.message||"Failed to save sync direction")}}),q=Bt({mutationFn:async()=>{const{data:te,error:Y}=await K.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(Y)throw Y;if(te!=null&&te.error)throw new Error(te.error);return te},onSuccess:te=>{b(null),d(te),a(!0)},onError:te=>{ge.error(te.message||"Failed to generate sync preview")}}),H=Bt({mutationFn:async()=>{j("Initializing sync..."),S(5);const{data:te,error:Y}=await K.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:se}});if(Y)throw Y;if(te!=null&&te.error)throw new Error(te.error);const ce=te;let oe=ce.sync_log_id,le=ce.next_phase,de=ce.next_offset;const xe=ce.push_total||0,be=ce.pull_total||0,ye=xe+be;let ve=0,ke=0;for(;le!=="finalize";){le==="push"?(j(`Pushing contacts to BoldTrail... (${ve}/${xe})`),S(ye>0?ve/ye*100:0)):le==="pull"&&(j(`Pulling contacts from BoldTrail... (${ke}/${be})`),S(ye>0?(xe+ke)/ye*100:0));const{data:Ae,error:Pe}=await K.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:le,offset:de,sync_log_id:oe,sync_direction:se}});if(Pe)throw Pe;if(Ae!=null&&Ae.error)throw new Error(Ae.error);const Fe=Ae;ve+=Fe.chunk_pushed||0,ke+=Fe.chunk_pulled||0,Fe.progress&&j(Fe.progress),le==="pull"&&be>0?S(Math.min(95,ke/be*100)):le==="push"&&xe>0&&S(Math.min(95,ve/xe*100)),le=Fe.next_phase,de=Fe.next_offset}j("Finalizing sync..."),S(95);const{data:Ge,error:Ne}=await K.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:oe,sync_direction:se}});if(Ne)throw Ne;return S(100),Ge},onSuccess:te=>{j(null),S(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),ge.success(`Sync complete! Pushed ${te.contacts_pushed||0}, pulled ${te.contacts_pulled||0}, skipped ${te.contacts_skipped||0} duplicates.`)},onError:te=>{j(null),S(0),ge.error(te.message||"Sync failed")}}),U=A==null?void 0:A.connected,Q=(A==null?void 0:A.sync_direction)||"bidirectional",se=_??Q;return e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx($t,{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($c,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",U&&e.jsx(nt,{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(mm,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(_r,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{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(hi,{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(hi,{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"})]}),U?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"}),(A==null?void 0:A.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(A.last_sync_at).toLocaleString(),A.last_sync_status&&e.jsx(nt,{variant:A.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:A.last_sync_status})]}),(A==null?void 0:A.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.boldtrail_contact_count," contacts in BoldTrail"]}),(A==null?void 0:A.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:A.last_sync_message})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect BoldTrail?"}),e.jsx(Xl,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>F.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(Txe,{value:Q,onChange:te=>$.mutate(te)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(Z,{onClick:()=>q.mutate(),disabled:q.isPending||H.isPending,variant:"outline",className:"gap-2",children:[q.isPending?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx(Na,{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(Re,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:te=>r(te.target.value),className:"flex-1"}),e.jsxs(Z,{onClick:()=>L.mutate(s),disabled:!s||s.length<10||L.isPending,children:[L.isPending?e.jsx(Ao,{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(bs,{open:n,onOpenChange:te=>{H.isPending||a(te)},children:e.jsxs(_s,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx($c,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Kr,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const te=se==="pull_only"?0:i.to_push,Y=se==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Txe,{value:se,onChange:b,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${se==="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(Rd,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${se==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Y}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ku,{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(xr,{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"]}),H.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(wo,{value:N||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:w||"Sync in progress..."})]}),te>0&&e.jsxs(Eg,{open:u,onOpenChange:f,children:[e.jsx(Pg,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Rd,{className:"h-3 w-3 text-emerald-600"}),te," contacts to push to BoldTrail"]}),e.jsx(tl,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(Ig,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((ce,oe)=>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})]},oe)),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"]})]})})]}),Y>0&&e.jsxs(Eg,{open:g,onOpenChange:v,children:[e.jsx(Pg,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ku,{className:"h-3 w-3 text-blue-600"}),Y," contacts to pull from BoldTrail"]}),e.jsx(tl,{className:`h-3 w-3 transition-transform ${g?"rotate-180":""}`})]})}),e.jsx(Ig,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((ce,oe)=>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})]},oe)),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&&Y===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(Z,{variant:"outline",onClick:()=>a(!1),disabled:H.isPending,children:"Cancel"}),e.jsxs(Z,{onClick:()=>H.mutate(),disabled:H.isPending||te===0&&Y===0,className:"gap-2",children:[H.isPending?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx($c,{className:"h-4 w-4"}),H.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(Cs,{className:"p-6 pb-0",children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx($c,{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 lus(){const{isAdmin:t}=Qs(),s=ds(),[r,n]=M.useState(!1),[a,o]=M.useState(!1),[l,i]=M.useState(!1),{data:d,isLoading:u}=Tt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:I,error:L}=await K.from("gmail_integrations").select("*").maybeSingle();if(L)throw L;return I}}),{data:f}=Tt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:I}}=await K.auth.getUser();if(!I)return[];const{data:L,error:F}=await K.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(F)throw F;return L}}),g=async()=>{n(!0);try{const{data:I,error:L}=await K.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),ge.error("Failed to start Gmail connection"),n(!1)}},v=async()=>{o(!0);try{const{data:I,error:L}=await K.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),ge.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},_=async()=>{i(!0);try{const{data:I,error:L}=await K.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),ge.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},b=Bt({mutationFn:async I=>{const{error:L}=await K.from("gmail_integrations").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),ge.success("Gmail disconnected")},onError:()=>{ge.error("Failed to disconnect Gmail")}}),w=Bt({mutationFn:async I=>{const{error:L}=await K.from("social_accounts").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),ge.success("Account disconnected")},onError:()=>{ge.error("Failed to disconnect account")}}),j=!!(d!=null&&d.is_active),N=(f==null?void 0:f.filter(I=>I.platform==="facebook"))||[],S=(f==null?void 0:f.filter(I=>I.platform==="instagram"))||[],A=(f==null?void 0:f.filter(I=>I.platform==="linkedin"))||[];return e.jsx(Ms,{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(De,{children:[e.jsx($t,{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(Ar,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:["Gmail",j&&e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(_r,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{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(hi,{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(hi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),j?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect Gmail?"}),e.jsx(Xl,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>b.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(Z,{className:"mt-4",onClick:g,disabled:r||u,children:[r?e.jsx(Ao,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ar,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(Ai,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(De,{className:t?"":"opacity-70",children:[e.jsx($t,{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(Fd,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?N.length>0?e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Pu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(_r,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Oe,{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(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:I.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(Fd,{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(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect Facebook?"}),e.jsx(Xl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(Z,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx(Ys,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(De,{className:t?"":"opacity-70",children:[e.jsx($t,{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(zd,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?S.length>0?e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Pu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(_r,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(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(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:I.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(zd,{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(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect Instagram?"}),e.jsx(Xl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(Z,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx(Ys,{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(De,{className:t?"":"opacity-70",children:[e.jsx($t,{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(Cm,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?A.length>0?e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Pu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(_r,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[A.length>0&&e.jsx("div",{className:"space-y-2",children:A.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(mn,{className:"h-8 w-8",children:[e.jsx(ba,{src:I.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(Cm,{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(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect LinkedIn?"}),e.jsx(Xl,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(Z,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx(Ys,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(ous,{})]})})}function cus(){const[t]=Gc(),s=Or(),[r,n]=M.useState("loading"),[a,o]=M.useState("Connecting your Gmail account...");return M.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),f=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),ge.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),ge.error("No authorization code received");return}try{const{data:g,error:v}=await K.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:f}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Gmail connected successfully!"),ge.success("Gmail connected!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("Gmail OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect Gmail"),ge.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(De,{className:"w-full max-w-md",children:[e.jsxs($t,{className:"text-center",children:[r==="loading"&&e.jsx(Rs,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(bc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Vt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(_r,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(Z,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function dus(){const t=Or();return M.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 uus(){const[t]=Gc(),s=Or(),[r,n]=M.useState("loading"),[a,o]=M.useState("Processing your connection...");return M.useEffect(()=>{(async()=>{var g;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),f=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),ge.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),ge.error("No authorization code received");return}try{const{data:v,error:_}=await K.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:f,callbackPath:"/mission-control/integrations/meta/callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((g=v.accounts)==null?void 0:g.length)||0} account(s)!`),ge.success("Social accounts connected successfully!");else throw new Error((v==null?void 0:v.error)||"Unknown error")}catch(v){console.error("OAuth callback error:",v),n("error"),o(v instanceof Error?v.message:"Failed to connect accounts"),ge.error("Failed to connect: "+(v instanceof Error?v.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsxs($t,{className:"text-center",children:[r==="loading"&&e.jsx(Rs,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(bc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Vt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(_r,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(Z,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const DXe=new Date().getFullYear(),hus=Array.from({length:5},(t,s)=>DXe-s);function mus(){const[t,s]=M.useState(DXe),r=Or(),{data:n,isLoading:a}=fkt();return a?e.jsx(Ms,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(gs,{className:"h-24"},o))}),e.jsx(gs,{className:"h-96"})]})}):e.jsx(Ms,{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(tr,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(rr,{})}),e.jsx(er,{children:hus.map(o=>e.jsx(At,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xr,{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(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ol,{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(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Agents with Scorecards"}),e.jsx(_r,{children:"Click to view individual agent scorecards"})]}),e.jsx(Oe,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ol,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Ln,{children:n.map(o=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:o.name}),e.jsx(lt,{className:"text-muted-foreground",children:o.email}),e.jsx(lt,{className:"text-right",children:e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(Na,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const OXe=new Date().getFullYear(),pus=Array.from({length:10},(t,s)=>OXe-s);function r6e(){var b;const{userId:t}=Uo(),s=Or(),n=sh().pathname.startsWith("/mission-control"),[a,o]=M.useState(OXe),{data:l,isLoading:i}=Tt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:w,error:j}=await K.from("profiles").select("id, name, email").eq("id",t).single();if(j)throw j;return w},enabled:!!t}),{data:d,isLoading:u}=x_e(a,t),{yearStats:f,lifetimeStats:g,showCommission:v}=fqe(a,t),{data:_}=pqe(a,t);return i?e.jsx(Ms,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(w=>e.jsx(gs,{className:"h-24"},w))})]})}):e.jsx(Ms,{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(Z,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(Ba,{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(tr,{value:String(a),onValueChange:w=>o(Number(w)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(rr,{})}),e.jsx(er,{children:pus.map(w=>e.jsx(At,{value:String(w),children:w},w))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Hn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:f.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.totalTransactions," lifetime"]})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xr,{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:[f.buyerCount,"/",f.sellerCount]})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Uc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Sl(f.totalVolume,!0)})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vc,{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:Sl(f.averagePrice,!0)})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(dc,{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=f.topLeadSource)==null?void 0:b.name)||"-"})]})})]}),_&&e.jsx(yGe,{goals:_,stats:f,year:a,showCommission:v}),e.jsxs(Ia,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"transactions",children:"Transactions"}),e.jsx(Ts,{value:"charts",children:"Charts"}),e.jsxs(Ts,{value:"map",children:[e.jsx(Pi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(Vs,{value:"transactions",children:e.jsx(Dbe,{transactions:d||[],showCommission:v,isLoading:u})}),e.jsx(Vs,{value:"charts",children:e.jsx(Uwe,{stats:f,year:a})}),e.jsx(Vs,{value:"map",children:e.jsx(Vwe,{transactions:d||[],isLoading:u})})]})]})})}function fus(){const t=ds(),[s,r]=M.useState(""),[n,a]=M.useState("all");M9e();const{data:o,refetch:l}=Tt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:S}=await K.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(S==null?void 0:S.enabled)??!1}}),{data:i,isLoading:d}=Tt({queryKey:["admin-listings"],queryFn:async()=>{const{data:S,error:A}=await K.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(A)throw A;return S}}),{data:u}=Tt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:S}=await K.from("listings").select("id, is_approved, status"),{data:A}=await K.from("listing_shares").select("id"),{data:I}=await K.from("listing_views").select("id");return{total:(S==null?void 0:S.length)||0,pending:(S==null?void 0:S.filter(L=>!L.is_approved).length)||0,active:(S==null?void 0:S.filter(L=>L.status==="active").length)||0,totalShares:(A==null?void 0:A.length)||0,totalViews:(I==null?void 0:I.length)||0}}}),f=Bt({mutationFn:async({id:S,approved:A})=>{const{error:I}=await K.from("listings").update({is_approved:A}).eq("id",S);if(I)throw I},onSuccess:(S,{approved:A})=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),ge.success(A?"Listing approved":"Listing unapproved")}}),g=Bt({mutationFn:async({id:S,featured:A})=>{const{error:I}=await K.from("listings").update({is_featured:A}).eq("id",S);if(I)throw I},onSuccess:(S,{featured:A})=>{t.invalidateQueries({queryKey:["admin-listings"]}),ge.success(A?"Listing featured":"Listing unfeatured")}}),v=Bt({mutationFn:async S=>{const{error:A}=await K.from("listings").delete().eq("id",S);if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),ge.success("Listing deleted")}}),_=Bt({mutationFn:async S=>{const{error:A}=await K.from("feature_flags").update({enabled:S}).eq("key","listing_exchange_enabled");if(A)throw A},onSuccess:()=>{l(),ge.success("Feature flag updated")}}),b=o??!1,w=i==null?void 0:i.filter(S=>{var L,F,$,q;const A=((L=S.city)==null?void 0:L.toLowerCase().includes(s.toLowerCase()))||(($=(F=S.agent)==null?void 0:F.name)==null?void 0:$.toLowerCase().includes(s.toLowerCase()))||((q=S.property_address)==null?void 0:q.toLowerCase().includes(s.toLowerCase())),I=n==="all"||n==="pending"&&!S.is_approved||n==="approved"&&S.is_approved;return A&&I}),j=S=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(S),N=S=>{const A={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 A[S]||A.active};return e.jsx(Ms,{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.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),e.jsx(qr,{checked:b,onCheckedChange:S=>_.mutate(S)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_a,{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(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vc,{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(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xr,{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(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Na,{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(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nd,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Shares"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalShares)||0})]})})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by city, address, or agent...",value:s,onChange:S=>r(S.target.value),className:"pl-9"})]}),e.jsx(Ia,{value:n,onValueChange:S=>a(S),children:e.jsxs(Aa,{children:[e.jsx(Ts,{value:"all",children:"All"}),e.jsx(Ts,{value:"pending",children:"Pending"}),e.jsx(Ts,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{children:["Listings (",(w==null?void 0:w.length)||0,")"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:d?e.jsx(ks,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(w==null?void 0:w.length)===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):w==null?void 0:w.map(S=>{var A,I,L,F,$;return e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(I=(A=S.photos)==null?void 0:A[0])!=null&&I.photo_url?e.jsx("img",{src:S.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(_a,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:S.property_address||`${S.city}, ${S.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(L=S.property_type)==null?void 0:L.replace("_"," ")})]})]})}),e.jsx(lt,{children:e.jsx("p",{className:"text-sm",children:((F=S.agent)==null?void 0:F.name)||"Unknown"})}),e.jsx(lt,{className:"font-medium",children:j(S.price)}),e.jsx(lt,{children:e.jsx(nt,{variant:"outline",className:N(S.status),children:($=S.status)==null?void 0:$.replace("_"," ")})}),e.jsx(lt,{className:"text-center",children:e.jsx(qr,{checked:S.is_approved??!1,onCheckedChange:q=>f.mutate({id:S.id,approved:q})})}),e.jsx(lt,{className:"text-center",children:e.jsx(qr,{checked:S.is_featured??!1,onCheckedChange:q=>g.mutate({id:S.id,featured:q})})}),e.jsx(lt,{children:S.view_count||0}),e.jsx(lt,{children:S.share_count||0}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:js(new Date(S.created_at),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",children:e.jsx(Xp,{className:"h-4 w-4"})})}),e.jsxs(mu,{align:"end",children:[e.jsxs(Wa,{onClick:()=>window.open(`/mission-control/listings/${S.id}`,"_blank"),children:[e.jsx(Na,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Wa,{onClick:()=>g.mutate({id:S.id,featured:!S.is_featured}),children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),S.is_featured?"Unfeature":"Feature"]}),e.jsxs(Wa,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&v.mutate(S.id)},children:[e.jsx(Vr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},S.id)})})]})})})]})]})})}const gus=()=>{var g,v;const[t,s]=M.useState(""),[r,n]=M.useState(null),{data:a,isLoading:o}=Tt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:_,error:b}=await K.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(b)throw b;const w=(_==null?void 0:_.map(S=>S.user_id))||[],{data:j}=await K.from("profiles").select("id, name, email").in("id",w);return _==null?void 0:_.map(S=>({...S,profiles:(j==null?void 0:j.find(A=>A.id===S.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var w,j,N,S,A;const b=t.toLowerCase();return((j=(w=_.profiles)==null?void 0:w.name)==null?void 0:j.toLowerCase().includes(b))||((S=(N=_.profiles)==null?void 0:N.email)==null?void 0:S.toLowerCase().includes(b))||((A=_.review_text)==null?void 0:A.toLowerCase().includes(b))}),i=a!=null&&a.length?(a.reduce((_,b)=>_+b.rating,0)/a.length).toFixed(1):"0.0",d=a==null?void 0:a.reduce((_,b)=>(_[b.rating]=(_[b.rating]||0)+1,_),{}),u=(a==null?void 0:a.filter(_=>_.posted_to_google).length)||0,f=_=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(b=>e.jsx(Gn,{className:It("h-4 w-4",_>=b?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},b))});return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{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(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"Total Reviews"}),e.jsx(Vt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"Average Rating"}),e.jsxs(Vt,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Gn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"5-Star Reviews"}),e.jsx(Vt,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(De,{children:e.jsxs($t,{className:"pb-2",children:[e.jsx(_r,{children:"Posted to Google"}),e.jsxs(Vt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(un,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or review...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:o?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(_=>{var b,w;return e.jsxs(ks,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(_),children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((b=_.profiles)==null?void 0:b.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(w=_.profiles)==null?void 0:w.email})]})}),e.jsx(lt,{children:f(_.rating)}),e.jsx(lt,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:_.review_text||"-"})}),e.jsx(lt,{children:_.posted_to_google?e.jsx(nt,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(nt,{variant:"outline",children:"No"})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:js(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(bs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:((g=r.profiles)==null?void 0:g.name)||"Unknown Member"}),((v=r.profiles)==null?void 0:v.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(Ar,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[f(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(nn,{className:"h-4 w-4"}),js(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(nt,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(nt,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},xus=[{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"}],yus=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 vus(){const t=ds(),{user:s}=Qs(),[r,n]=M.useState(!1),[a,o]=M.useState(!1),[l,i]=M.useState(!1),{data:d,isLoading:u}=Tt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:q,error:H}=await K.from("weekly_digest_settings").select("*").single();if(H)throw H;return q}}),{data:f,isLoading:g}=Tt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:q,error:H}=await K.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(H)throw H;return q}}),{data:v}=Tt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:q,error:H}=await K.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(H)throw H;return q||0}}),{data:_,refetch:b}=Tt({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[H,U,Q,se]=await Promise.all([K.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",q.toISOString()),K.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",q.toISOString()),K.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",q.toISOString()),K.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",q.toISOString())]);return{pending:H.count||0,processing:U.count||0,sent:Q.count||0,failed:se.count||0,total:(H.count||0)+(U.count||0)+(Q.count||0)+(se.count||0)}},refetchInterval:5e3});M.useEffect(()=>{if(_&&(_.pending>0||_.processing>0)){const q=setInterval(()=>{b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(q)}},[_,b,t]);const{data:w=0}=Tt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:H,error:U}=await K.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString());if(U)throw U;return H||0}}),j=Bt({mutationFn:async q=>{const{error:H}=await K.from("weekly_digest_settings").update(q).eq("id",d==null?void 0:d.id);if(H)throw H},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),ge.success("Settings updated")},onError:q=>{ge.error("Failed to update settings: "+q.message)}}),N=async()=>{n(!0);try{const{data:q,error:H}=await K.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(H)throw H;q.queued?ge.success(`${q.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):q.sent!==void 0&&ge.success(`Digest sent! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(q){ge.error("Failed to send digest: "+q.message)}finally{n(!1)}},S=async()=>{var q,H,U,Q,se,te;if(!(s!=null&&s.email)){ge.error("No email found for your account");return}o(!0);try{const{data:Y,error:ce}=await K.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ce)throw ce;const oe=Y==null?void 0:Y.resendId,le=Y==null?void 0:Y.resendDetails,de=le==null?void 0:le.status,xe=((q=le==null?void 0:le.body)==null?void 0:q.status)||((U=(H=le==null?void 0:le.body)==null?void 0:H.data)==null?void 0:U.status),be=((se=(Q=le==null?void 0:le.body)==null?void 0:Q.error)==null?void 0:se.message)||((te=le==null?void 0:le.body)==null?void 0:te.message);ge.success(oe?`Preview accepted by email provider (id: ${oe})${de?`, status check: ${de}`:""}${xe?`, provider: ${xe}`:""}${be?` (${be})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(Y){ge.error("Failed to send preview: "+Y.message)}finally{o(!1)}},A=async()=>{i(!0);try{const{data:q,error:H}=await K.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(H)throw H;q.queued===0||q.sent===0&&q.failed===0&&!q.queued?ge.info("No failed emails to retry"):q.queued?ge.success(`${q.queued} emails queued for retry!`):ge.success(`Retry complete! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(q){ge.error("Failed to retry: "+q.message)}finally{i(!1)}},I=_!=null&&_.total?Math.round((_.sent+_.failed)/_.total*100):0,L=((_==null?void 0:_.pending)||0)>0||((_==null?void 0:_.processing)||0)>0,{data:F}=Tt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var te,Y;const q=new Date;q.setUTCHours(0,0,0,0);const[H,U,Q,se]=await Promise.all([K.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",q.toISOString()),K.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString()),K.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",q.toISOString()),K.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:H.count||0,totalFailed:U.count||0,agentOsEngaged:Q.count||0,lastSent:((Y=(te=se.data)==null?void 0:te[0])==null?void 0:Y.sent_at)||null}},refetchInterval:L?5e3:!1}),$={totalSent:(F==null?void 0:F.totalSent)||0,totalFailed:(F==null?void 0:F.totalFailed)||0,lastSent:F==null?void 0:F.lastSent,agentOsEngaged:(F==null?void 0:F.agentOsEngaged)||0};return u?e.jsx(Ms,{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(Ms,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(Ia,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(Aa,{children:[e.jsxs(Ts,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(Pl,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(Ts,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(ol,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(Vs,{value:"settings",className:"space-y-6",children:[L&&_&&e.jsx(De,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(Rs,{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:[_.sent.toLocaleString()," sent, ",_.pending.toLocaleString()," pending",_.failed>0&&`, ${_.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[I,"%"]})]}),e.jsx(wo,{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(_.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(xr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:v}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:e.jsx(Ma,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:e.jsx(bc,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(Tn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.lastSent?js(new Date($.lastSent),"MMM d"):"Never"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Sent"})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(_r,{children:"Configure when the digest is sent"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(qr,{checked:d==null?void 0:d.is_enabled,onCheckedChange:q=>j.mutate({is_enabled:q})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Cron Frequency"}),e.jsxs(tr,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>j.mutate({cron_frequency:q}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(At,{value:"hourly",children:"Hourly (checks every hour)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(d==null?void 0:d.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(_e,{children:"Day of Week"}),e.jsxs(tr,{value:String(d==null?void 0:d.send_day),onValueChange:q=>j.mutate({send_day:parseInt(q)}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:xus.map(q=>e.jsx(At,{value:q.value,children:q.label},q.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Time (UTC)"}),e.jsxs(tr,{value:String(d==null?void 0:d.send_hour),onValueChange:q=>j.mutate({send_hour:parseInt(q)}),disabled:(d==null?void 0:d.cron_frequency)==="daily",children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:yus.map(q=>e.jsx(At,{value:q.value,children:q.label},q.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Z,{onClick:S,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(Na,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(Z,{onClick:N,disabled:r,className:"flex-1",children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),w>0&&e.jsxs(Z,{onClick:A,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Ao,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${w} Failed`]})]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Un,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(_r,{children:"Choose what to include in the digest"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"New Resources"})]}),e.jsx(qr,{checked:d==null?void 0:d.include_new_resources,onCheckedChange:q=>j.mutate({include_new_resources:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"Community Highlights"})]}),e.jsx(qr,{checked:d==null?void 0:d.include_community_posts,onCheckedChange:q=>j.mutate({include_community_posts:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ol,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"Agent OS Stats"})]}),e.jsx(qr,{checked:d==null?void 0:d.include_agent_os_stats,onCheckedChange:q=>j.mutate({include_agent_os_stats:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"Upcoming Events"})]}),e.jsx(qr,{checked:d==null?void 0:d.include_upcoming_events,onCheckedChange:q=>j.mutate({include_upcoming_events:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mm,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"Goals Progress"})]}),e.jsx(qr,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:q=>j.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Custom Introduction"}),e.jsx(_r,{children:"Personalize the intro message (optional)"})]}),e.jsx(Oe,{children:e.jsx(Lr,{placeholder:"Here's what's new this week to help you grow your business...",value:(d==null?void 0:d.custom_intro_text)||"",onChange:q=>j.mutate({custom_intro_text:q.target.value||null}),rows:3})})]})]}),e.jsx(Vs,{value:"stats",children:e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Ar,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(_r,{children:"Recent digest emails sent to members"})]}),e.jsx(Oe,{children:g?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(q=>e.jsx("div",{className:"h-12 bg-muted rounded"},q))}):f&&f.length>0?e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:f.map(q=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:q.email_sent_to}),e.jsx(lt,{children:js(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(lt,{children:e.jsx(nt,{variant:q.delivery_status==="sent"?"default":"destructive",children:q.delivery_status})}),e.jsx(lt,{children:q.resources_count}),e.jsx(lt,{children:q.has_agent_os_activity?e.jsx(nt,{variant:"secondary",children:"Active"}):e.jsx(nt,{variant:"outline",children:"Not Started"})})]},q.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ar,{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 _us={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 bus(){var ve,ke,Ge;const t=ds(),[s,r]=M.useState(""),[n,a]=M.useState(null),[o,l]=M.useState(!1),[i,d]=M.useState(!1),[u,f]=M.useState(""),[g,v]=M.useState(""),[_,b]=M.useState(!0),[w,j]=M.useState(!1),[N,S]=M.useState(""),[A,I]=M.useState(null),{data:L,isLoading:F}=Tt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Ne,error:Ae}=await K.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Ae)throw Ae;const Pe=(Ne==null?void 0:Ne.map(Ve=>Ve.user_id))||[],{data:Fe}=await K.from("profiles").select("id, name, email").in("id",Pe),Ie=new Map((Fe==null?void 0:Fe.map(Ve=>[Ve.id,{name:Ve.name,email:Ve.email}]))||[]);return Ne==null?void 0:Ne.map(Ve=>({...Ve,profile:Ie.get(Ve.user_id)||null}))}}),{data:$}=Tt({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const Ae=[];let Pe=0;for(;;){const{data:Fe,error:Ie}=await K.from("profiles").select("id, name, email").order("name").range(Pe,Pe+1e3-1);if(Ie)throw Ie;if(Ae.push(...Fe),!Fe||Fe.length<1e3)break;Pe+=1e3}return Ae}}),H=(($==null?void 0:$.filter(Ne=>!(L!=null&&L.some(Ae=>Ae.user_id===Ne.id))))||[]).filter(Ne=>{var Pe,Fe;if(!N)return!0;const Ae=N.toLowerCase();return((Pe=Ne.name)==null?void 0:Pe.toLowerCase().includes(Ae))||((Fe=Ne.email)==null?void 0:Fe.toLowerCase().includes(Ae))}),{data:U,isLoading:Q}=Tt({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 K.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:se}=Tt({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 K.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=Bt({mutationFn:async({userId:Ne,points:Ae,reason:Pe})=>{const{error:Fe}=await K.from("agent_points").insert({user_id:Ne,points:Ae,reason:Pe});if(Fe)throw Fe;const{data:Ie}=await K.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Ne).maybeSingle(),Ve=((Ie==null?void 0:Ie.total_points)||0)+Ae,dt=((Ie==null?void 0:Ie.spendable_points)||0)+Ae,{error:Le}=await K.from("agent_attendance_stats").upsert({user_id:Ne,total_points:Math.max(0,Ve),spendable_points:Math.max(0,dt),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(Le)throw Le},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),f(""),v(""),ge.success(_?"Points awarded successfully!":"Points deducted successfully!")},onError:Ne=>{console.error("Error modifying points:",Ne),ge.error("Failed to modify points")}}),Y=()=>{if(!n||!u||!g){ge.error("Please fill in all fields");return}const Ne=parseInt(u);if(isNaN(Ne)||Ne<=0){ge.error("Please enter a valid positive number");return}te.mutate({userId:n.user_id,points:_?Ne:-Ne,reason:g})},ce=()=>{if(!A||!u||!g){ge.error("Please fill in all fields");return}const Ne=parseInt(u);if(isNaN(Ne)||Ne<=0){ge.error("Please enter a valid positive number");return}te.mutate({userId:A.id,points:Ne,reason:g},{onSuccess:()=>{j(!1),I(null),S("")}})},oe=(Ne,Ae)=>{a(Ne),b(Ae),l(!0)},le=Ne=>{a(Ne),d(!0)},de=L==null?void 0:L.filter(Ne=>{var Ie,Ve,dt,Le;const Ae=((Ve=(Ie=Ne.profile)==null?void 0:Ie.name)==null?void 0:Ve.toLowerCase())||"",Pe=((Le=(dt=Ne.profile)==null?void 0:dt.email)==null?void 0:Le.toLowerCase())||"",Fe=s.toLowerCase();return Ae.includes(Fe)||Pe.includes(Fe)}),xe=(L==null?void 0:L.reduce((Ne,Ae)=>Ne+Ae.total_points,0))||0,be=(L==null?void 0:L.length)||0,ye=be>0?Math.round(xe/be):0;return F?e.jsx(Ms,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Ne=>e.jsx(gs,{className:"h-24"},Ne))}),e.jsx(gs,{className:"h-96"})]})}):e.jsx(Ms,{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(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xr,{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:be}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(so,{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:xe.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vc,{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:ye}),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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:s,onChange:Ne=>r(Ne.target.value),className:"pl-10"})]}),e.jsxs(Z,{onClick:()=>j(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Agent Leaderboard"}),e.jsx(_r,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Oe,{children:!de||de.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(so,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:de.map((Ne,Ae)=>{var Pe,Fe,Ie,Ve;return e.jsxs(ks,{children:[e.jsx(lt,{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(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(mn,{className:"h-8 w-8",children:e.jsx(pn,{children:((Fe=(Pe=Ne.profile)==null?void 0:Pe.name)==null?void 0:Fe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Ie=Ne.profile)==null?void 0:Ie.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Ve=Ne.profile)==null?void 0:Ve.email})]})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(nt,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Ne.total_points]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(nt,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(uo,{className:"h-3 w-3 mr-1"}),Ne.spendable_points||0]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3 text-muted-foreground"}),Ne.total_events_attended]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(dp,{className:"h-3 w-3 text-orange-500"}),Ne.current_streak]})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>oe(Ne,!0),title:"Award points",children:e.jsx(Ys,{className:"h-4 w-4 text-green-600"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>oe(Ne,!1),title:"Deduct points",children:e.jsx(K1,{className:"h-4 w-4 text-red-600"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>le(Ne),title:"View history",children:e.jsx(t5,{className:"h-4 w-4"})})]})})]},Ne.user_id)})})]})})]}),e.jsx(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:_?"Award Points":"Deduct Points"}),e.jsxs(Kr,{children:[_?"Award":"Deduct"," points ",_?"to":"from"," ",((ve=n==null?void 0:n.profile)==null?void 0:ve.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"points",children:"Points Amount"}),e.jsx(Re,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Ne=>f(Ne.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"reason",children:"Reason"}),e.jsx(Lr,{id:"reason",placeholder:"Enter reason for this adjustment...",value:g,onChange:Ne=>v(Ne.target.value)})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Z,{onClick:Y,disabled:te.isPending,className:_?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:te.isPending?"Saving...":_?"Award Points":"Deduct Points"})]})]})}),e.jsx(bs,{open:i,onOpenChange:d,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:["Point History: ",(ke=n==null?void 0:n.profile)==null?void 0:ke.name]}),e.jsx(Kr,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(Ia,{defaultValue:"history",className:"w-full",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-2",children:[e.jsx(Ts,{value:"history",children:"Point History"}),e.jsx(Ts,{value:"badges",children:"Badges"})]}),e.jsx(Vs,{value:"history",className:"mt-4",children:Q?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Ne=>e.jsx(gs,{className:"h-12"},Ne))}):!U||U.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(t5,{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:U.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:js(new Date(Ne.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(nt,{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(Vs,{value:"badges",className:"mt-4",children:!se||se.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(dc,{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:se.map(Ne=>e.jsxs("div",{className:`p-3 rounded-lg ${_us[Ne.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dc,{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 ",js(new Date(Ne.earned_at),"MMM d, yyyy")]})]},Ne.id))})})]})]})}),e.jsx(bs,{open:w,onOpenChange:Ne=>{j(Ne),Ne||(I(null),S(""),f(""),v(""))},children:e.jsxs(_s,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Award Points to New Agent"}),e.jsx(Kr,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(mn,{className:"h-10 w-10",children:e.jsx(pn,{children:((Ge=A.name)==null?void 0:Ge.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:A.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:A.email})]}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>I(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(Re,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Ne=>f(Ne.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Lr,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:g,onChange:Ne=>v(Ne.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:N,onChange:Ne=>S(Ne.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:H.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(xr,{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"})]}):H.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(mn,{className:"h-8 w-8",children:e.jsx(pn,{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(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),A&&e.jsxs(Z,{onClick:ce,disabled:te.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function wus(){const{data:t,isLoading:s}=Oyt(),[r,n]=M.useState(null),[a,o]=M.useState(!1),[l,i]=M.useState(""),[d,u]=M.useState("all"),[f,g]=M.useState("newest"),[v,_]=M.useState("table"),b=M.useMemo(()=>(t==null?void 0:t.map(A=>A.user_id))||[],[t]),w=M.useMemo(()=>(t==null?void 0:t.map(A=>A.id))||[],[t]),{data:j}=Tt({queryKey:["card-profiles-lookup",b],queryFn:async()=>{if(b.length===0)return{};const{data:A}=await K.from("profiles").select("id, name, email").in("id",b),I={};return A==null||A.forEach(L=>{I[L.id]={name:L.name||"",email:L.email||""}}),I},enabled:b.length>0}),{data:N}=Tt({queryKey:["card-stats-all",w],queryFn:async()=>{if(w.length===0)return{};const A={};w.forEach(F=>{A[F]={views:0,leads:0}});const{data:I}=await K.from("agent_card_interactions").select("card_id").in("card_id",w).eq("interaction_type","card_view");I==null||I.forEach(F=>{A[F.card_id]&&A[F.card_id].views++});const{data:L}=await K.from("agent_card_leads").select("card_id").in("card_id",w);return L==null||L.forEach(F=>{A[F.card_id]&&A[F.card_id].leads++}),A},enabled:w.length>0}),S=M.useMemo(()=>{if(!t)return[];let A=[...t];if(d==="live"?A=A.filter(I=>I.is_published):d==="draft"&&(A=A.filter(I=>!I.is_published)),l.trim()){const I=l.toLowerCase();A=A.filter(L=>{var $,q;const F=j==null?void 0:j[L.user_id];return L.slug.toLowerCase().includes(I)||(($=F==null?void 0:F.name)==null?void 0:$.toLowerCase().includes(I))||((q=F==null?void 0:F.email)==null?void 0:q.toLowerCase().includes(I))})}return f==="newest"?A.sort((I,L)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):f==="oldest"?A.sort((I,L)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):f==="name"?A.sort((I,L)=>{var F,$;return(((F=j==null?void 0:j[I.user_id])==null?void 0:F.name)||"").localeCompare((($=j==null?void 0:j[L.user_id])==null?void 0:$.name)||"")}):f==="slug"?A.sort((I,L)=>I.slug.localeCompare(L.slug)):f==="views_desc"?A.sort((I,L)=>{var F,$;return(((F=N==null?void 0:N[L.id])==null?void 0:F.views)||0)-((($=N==null?void 0:N[I.id])==null?void 0:$.views)||0)}):f==="views_asc"?A.sort((I,L)=>{var F,$;return(((F=N==null?void 0:N[I.id])==null?void 0:F.views)||0)-((($=N==null?void 0:N[L.id])==null?void 0:$.views)||0)}):f==="leads_desc"?A.sort((I,L)=>{var F,$;return(((F=N==null?void 0:N[L.id])==null?void 0:F.leads)||0)-((($=N==null?void 0:N[I.id])==null?void 0:$.leads)||0)}):f==="leads_asc"&&A.sort((I,L)=>{var F,$;return(((F=N==null?void 0:N[I.id])==null?void 0:F.leads)||0)-((($=N==null?void 0:N[L.id])==null?void 0:$.leads)||0)}),A},[t,d,l,f,j]);return e.jsxs(Ms,{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(Z,{onClick:()=>o(!0),children:[e.jsx(Ys,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or slug...",value:l,onChange:A=>i(A.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:d,onValueChange:u,children:[e.jsx(Js,{className:"w-full sm:w-36",children:e.jsx(rr,{placeholder:"Status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Status"}),e.jsx(At,{value:"live",children:"Live"}),e.jsx(At,{value:"draft",children:"Draft"})]})]}),e.jsxs(tr,{value:f,onValueChange:g,children:[e.jsx(Js,{className:"w-full sm:w-44",children:e.jsx(rr,{placeholder:"Sort by"})}),e.jsxs(er,{children:[e.jsx(At,{value:"newest",children:"Newest First"}),e.jsx(At,{value:"oldest",children:"Oldest First"}),e.jsx(At,{value:"name",children:"Name A–Z"}),e.jsx(At,{value:"slug",children:"Slug A–Z"}),e.jsx(At,{value:"views_desc",children:"Most Views"}),e.jsx(At,{value:"views_asc",children:"Fewest Views"}),e.jsx(At,{value:"leads_desc",children:"Most Leads"}),e.jsx(At,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(Z,{variant:v==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:e.jsx(h5,{className:"h-4 w-4"})}),e.jsx(Z,{variant:v==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(hp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",S.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(A=>e.jsx(gs,{className:"h-48"},A))}):S.length>0?v==="table"?e.jsx(jus,{cards:S,cardProfiles:j,cardStats:N,onEdit:n,sortBy:f,setSortBy:g}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:S.map(A=>e.jsx(kus,{card:A,onEdit:()=>n(A),stats:N==null?void 0:N[A.id]},A.id))}):t&&t.length>0?e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(xn,{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(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(xr,{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(Z,{onClick:()=>o(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(Nus,{open:a,onOpenChange:o}),r&&e.jsx(Sus,{card:r,open:!!r,onOpenChange:A=>!A&&n(null)})]})}function jus({cards:t,cardProfiles:s,cardStats:r,onEdit:n,sortBy:a,setSortBy:o}){const l=d=>{a===`${d}_desc`?o(`${d}_asc`):o(`${d}_desc`)},i=({field:d})=>a===`${d}_desc`?e.jsx(Ku,{className:"h-3 w-3"}):a===`${d}_asc`?e.jsx(Rd,{className:"h-3 w-3"}):e.jsx($c,{className:"h-3 w-3 opacity-40"});return e.jsx(De,{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(Rd,{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(d=>{const u=s==null?void 0:s[d.user_id],f=r==null?void 0:r[d.id],g=`https://cards.relevelup.com/${d.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:["/",d.slug]})}),e.jsx("td",{className:"p-3 text-center",children:e.jsx(nt,{variant:d.is_published?"default":"secondary",className:"text-xs",children:d.is_published?"Live":"Draft"})}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(f==null?void 0:f.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(f==null?void 0:f.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>n(d),className:"h-8 w-8 p-0",children:e.jsx(Ga,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(g),ge.success("Link copied!")},children:e.jsx(Ni,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",asChild:!0,children:e.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",children:e.jsx(un,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function kus({card:t,onEdit:s,stats:r}){const[n,a]=M.useState(null);M.useEffect(()=>{(async()=>{const{data:d}=await K.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:f}=await K.storage.from("avatars").list(`${t.user_id}`);if(f&&f.length>0){const{data:g}=K.storage.from("avatars").getPublicUrl(`${t.user_id}/${f[0].name}`);u=g.publicUrl}}catch{}a({name:(d==null?void 0:d.name)||"Unknown",avatar_url:u})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),ge.success("Link copied!")};return e.jsx(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(pn,{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(nt,{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(Na,{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(xr,{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(Z,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(Ga,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(Z,{variant:"outline",size:"sm",onClick:l,children:e.jsx(Ni,{className:"h-3 w-3"})}),e.jsx(Z,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(un,{className:"h-3 w-3"})})})]})]})})}function Nus({open:t,onOpenChange:s}){const[r,n]=M.useState(""),[a,o]=M.useState(""),[l,i]=M.useState(""),[d,u]=M.useState(!1),f=WBe(),g=l.trim(),{data:v}=Tt({queryKey:["profiles-search-for-cards",g],queryFn:async()=>{let S=K.from("profiles").select("id, name, email").order("name").limit(50);g.length>=2&&(S=S.or(`name.ilike.%${g}%,email.ilike.%${g}%`));const{data:A}=await S;return A||[]},enabled:t}),[_,b]=M.useState(null),w=(v==null?void 0:v.find(S=>S.id===r))||_,j=()=>{if(!r||!a.trim()){ge.error("Select an agent and enter a slug");return}f.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},N=S=>{var I;n(S),u(!1);const A=v==null?void 0:v.find(L=>L.id===S);A&&(b(A),o(((I=A.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create Agent Card"}),e.jsx(Kr,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Agent"}),e.jsxs(No,{open:d,onOpenChange:u,children:[e.jsx(So,{asChild:!0,children:e.jsxs(Z,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",children:[w?`${w.name} (${w.email})`:"Search for an agent...",e.jsx(of,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(gf,{shouldFilter:!1,children:[e.jsx(xf,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(yf,{children:[e.jsx(vf,{children:"No agents found."}),e.jsx(_f,{children:(v||[]).map(S=>e.jsxs(_m,{value:S.id,onSelect:N,children:[e.jsx(ma,{className:It("mr-2 h-4 w-4",r===S.id?"opacity-100":"opacity-0")}),S.name," (",S.email,")"]},S.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{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(Re,{value:a,onChange:S=>o(S.target.value),placeholder:"john-doe"})]})]}),e.jsx(Z,{onClick:j,disabled:f.isPending,className:"w-full",children:f.isPending?"Creating...":"Create Card"})]})]})})}function Sus({card:t,open:s,onOpenChange:r}){const n=GBe(),{data:a}=KBe(t.id),o=ds(),[l,i]=M.useState(null),[d,u]=M.useState(!1),[f,g]=M.useState(!1),[v,_]=M.useState(""),[b,w]=M.useState(t.slug),[j,N]=M.useState(!1),[S,A]=M.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});M.useEffect(()=>{s&&(async()=>{try{const{data:U}=await K.storage.from("avatars").list(`${t.user_id}`);if(U&&U.length>0){const{data:Q}=K.storage.from("avatars").getPublicUrl(`${t.user_id}/${U[0].name}`);i(`${Q.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=H=>{var se;const U=(se=H.target.files)==null?void 0:se[0];if(!U)return;if(!U.type.startsWith("image/")){ge.error("Please select an image file");return}if(U.size>5*1024*1024){ge.error("Image must be under 5MB");return}const Q=new FileReader;Q.onloadend=()=>{_(Q.result),g(!0)},Q.readAsDataURL(U),H.target.value=""},L=async H=>{u(!0);try{const{data:U}=await K.storage.from("avatars").list(`${t.user_id}`);U&&U.length>0&&await K.storage.from("avatars").remove(U.map(ce=>`${t.user_id}/${ce.name}`));const Q=`${t.user_id}/avatar.jpg`,{error:se}=await K.storage.from("avatars").upload(Q,H,{upsert:!0,contentType:"image/jpeg"});if(se)throw se;const{data:te}=K.storage.from("avatars").getPublicUrl(Q),Y=`${te.publicUrl}?t=${Date.now()}`;i(Y),await K.from("profiles").update({avatar_url:Y}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),ge.success("Photo updated!")}catch(U){ge.error(U.message||"Upload failed")}finally{u(!1)}},F=async()=>{const H=b.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!H){ge.error("Please enter a valid URL");return}if(H===t.slug){ge.info("No changes to save");return}N(!0);try{const{data:U}=await K.from("agent_cards").select("id").eq("slug",H).neq("id",t.id).maybeSingle();if(U){ge.error("This URL is already taken. Try another one.");return}const{error:Q}=await K.from("agent_cards").update({slug:H}).eq("id",t.id);if(Q)throw Q;w(H),o.invalidateQueries({queryKey:["agent-cards-admin"]}),ge.success("Card address updated!")}catch{ge.error("Failed to update card address")}finally{N(!1)}},$=async(H,U)=>{var se;const Q=(se=H.target.files)==null?void 0:se[0];if(Q){if(!Q.type.startsWith("image/")){ge.error("Please select an image file");return}try{const te=Q.name.split(".").pop()||"png",Y=U==="brokerage_logo_url"?"brokerage-logo":"team-logo",ce=`${t.user_id}/${Y}.${te}`,{error:oe}=await K.storage.from("card-logos").upload(ce,Q,{upsert:!0});if(oe)throw oe;const{data:le}=K.storage.from("card-logos").getPublicUrl(ce),de=le.publicUrl+"?t="+Date.now();A(U==="brokerage_logo_url"?xe=>({...xe,[U]:de,brokerage_display_name:""}):xe=>({...xe,[U]:de,team_name:""})),ge.success("Logo uploaded!")}catch{ge.error("Failed to upload logo")}finally{H.target.value=""}}},q=()=>{n.mutate({id:t.id,...S,title:S.title||null,positioning_statement:S.positioning_statement||null,bio:S.bio||null,review_snippet:S.review_snippet||null,review_source_url:S.review_source_url||null,booking_url:S.booking_url||null,custom_cta_label:S.custom_cta_label||null,custom_cta_url:S.custom_cta_url||null,brokerage_display_name:S.brokerage_display_name||null,brokerage_logo_url:S.brokerage_logo_url||null,brokerage_logo_size:S.brokerage_logo_size,team_name:S.team_name||null,team_logo_url:S.team_logo_url||null,team_logo_size:S.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(bs,{open:s,onOpenChange:r,children:e.jsxs(_s,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Agent Card"}),e.jsxs(Kr,{children:["/card/",t.slug]})]}),e.jsxs(Ia,{defaultValue:"content",children:[e.jsxs(Aa,{className:"w-full",children:[e.jsx(Ts,{value:"content",className:"flex-1",children:"Content"}),e.jsx(Ts,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(Ts,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(Ts,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(Vs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Published"}),e.jsx(qr,{checked:S.is_published,onCheckedChange:H=>A(U=>({...U,is_published:H}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(mn,{className:"h-16 w-16",children:[e.jsx(ba,{src:l||void 0}),e.jsx(pn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,disabled:d}),e.jsx(Z,{variant:"outline",size:"sm",asChild:!0,disabled:d,children:e.jsx("span",{children:d?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{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(Re,{value:b,onChange:H=>w(H.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(Z,{variant:"outline",size:"sm",onClick:F,disabled:j||b===t.slug,className:"shrink-0",children:j?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Theme"}),e.jsxs(tr,{value:S.theme,onValueChange:H=>A(U=>({...U,theme:H})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(At,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(At,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(At,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Title / Tagline"}),e.jsx(Re,{value:S.title,onChange:H=>A(U=>({...U,title:H.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(_e,{children:"Positioning Statement"}),e.jsx(Re,{value:S.positioning_statement,onChange:H=>A(U=>({...U,positioning_statement:H.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Bio"}),e.jsx(Lr,{value:S.bio,onChange:H=>A(U=>({...U,bio:H.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Review Snippet"}),e.jsx(Re,{value:S.review_snippet,onChange:H=>A(U=>({...U,review_snippet:H.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Review Source URL"}),e.jsx(Re,{value:S.review_source_url,onChange:H=>A(U=>({...U,review_source_url:H.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(Re,{value:S.booking_url,onChange:H=>A(U=>({...U,booking_url:H.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Custom CTA Label (optional)"}),e.jsx(Re,{value:S.custom_cta_label,onChange:H=>A(U=>({...U,custom_cta_label:H.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Custom CTA URL (optional)"}),e.jsx(Re,{value:S.custom_cta_url,onChange:H=>A(U=>({...U,custom_cta_url:H.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(_e,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{value:S.brokerage_display_name,onChange:H=>A(U=>({...U,brokerage_display_name:H.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!S.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${S.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A(H=>({...H,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(xi,{className:"h-3.5 w-3.5"}),S.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:H=>$(H,"brokerage_logo_url")})]})]}),S.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.brokerage_logo_size||56,"px"]})]}),e.jsx(kg,{value:[S.brokerage_logo_size||56],onValueChange:([H])=>A(U=>({...U,brokerage_logo_size:H})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(_e,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{value:S.team_name,onChange:H=>A(U=>({...U,team_name:H.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!S.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.team_logo_url,alt:"Team logo",style:{height:`${S.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A(H=>({...H,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(xi,{className:"h-3.5 w-3.5"}),S.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:H=>$(H,"team_logo_url")})]})]}),S.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.team_logo_size||56,"px"]})]}),e.jsx(kg,{value:[S.team_logo_size||56],onValueChange:([H])=>A(U=>({...U,team_logo_size:H})),min:24,max:120,step:4})]})]})]})]}),e.jsx(Vs,{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:H,label:U,hint:Q})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(_e,{children:U}),Q&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[Q," ",H==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(qr,{checked:S[H],onCheckedChange:se=>A(te=>({...te,[H]:se}))})]},H))}),e.jsx(Vs,{value:"blocks",className:"mt-4",children:e.jsx(jXe,{cardId:t.id})}),e.jsx(Vs,{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(De,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.views}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Views"})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.clicks}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Clicks"})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),e.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(H=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:H.name}),H.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",H.phone]}),H.intent&&e.jsx(nt,{variant:"secondary",className:"ml-2 text-xs",children:H.intent})]},H.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(Z,{onClick:q,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(ibe,{open:f,onClose:()=>g(!1),imageSrc:v,onCropComplete:L,aspectRatio:1})]})}const P5={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"},Ywe={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 Xwe(t=!0){return Tt({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=K.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 Cus(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),ge.success("Category created successfully")},onError:s=>{ge.error("Failed to create category: "+s.message)}})}function Mus(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),ge.success("Category updated successfully")},onError:s=>{ge.error("Failed to update category: "+s.message)}})}function Tus(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),ge.success("Category deleted successfully")},onError:s=>{ge.error("Failed to delete category: "+s.message)}})}function RXe(t,s=!0){return Tt({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=K.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 Aus(t){return Tt({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await K.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 Eus(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),ge.success("Product created successfully")},onError:s=>{ge.error("Failed to create product: "+s.message)}})}function Pus(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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]}),ge.success("Product updated successfully")},onError:s=>{ge.error("Failed to update product: "+s.message)}})}function Ius(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),ge.success("Product deleted successfully")},onError:s=>{ge.error("Failed to delete product: "+s.message)}})}function Lus(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 Dus(){const t=ds();return Bt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await K.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]}),ge.success("Image deleted successfully")},onError:s=>{ge.error("Failed to delete image: "+s.message)}})}function Ous(){const t=ds();return Bt({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await K.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await K.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]}),ge.success("Primary image updated")},onError:s=>{ge.error("Failed to set primary image: "+s.message)}})}function Rus(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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]}),ge.success("Variant added successfully")}})}function Fus(){const t=ds();return Bt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await K.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]}),ge.success("Variant deleted successfully")}})}function zus(){const t=ds();return Bt({mutationFn:async({productId:s,videoUrl:r})=>{await K.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await K.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]}),ge.success("Video updated successfully")}})}function Bus(t){const{isAdmin:s}=Qs();return Tt({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=K.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(d=>d.user_id))],{data:l}=await K.from("profiles").select("id, name, email").in("id",o),i=new Map((l==null?void 0:l.map(d=>[d.id,d]))||[]);return n.map(d=>({...d,user:i.get(d.user_id)}))}return n}})}function $us(){const{user:t}=Qs();return Tt({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await K.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 qus(t){return Tt({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await K.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 Uus(){const t=ds(),{user:s}=Qs();return Bt({mutationFn:async({orderId:r,status:n,notes:a,trackingNumber:o,trackingUrl:l,previousStatus:i})=>{const d={status:n};o!==void 0&&(d.tracking_number=o),l!==void 0&&(d.tracking_url=l);const{error:u}=await K.from("marketplace_orders").update(d).eq("id",r);if(u)throw u;const{error:f}=await K.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(f)throw f;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await K.functions.invoke("marketplace-order-notify",{body:{orderId:r,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(v){console.error("Failed to send notification email:",v)}},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",n.orderId]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),ge.success("Order status updated")},onError:r=>{ge.error("Failed to update order: "+r.message)}})}function Vus(){const t=ds();return Bt({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await K.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await K.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await K.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"]}),ge.success("Proof uploaded & customer notified")}})}function Hus(){const t=ds();return Bt({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await K.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"]}),ge.success("Proof approved")}})}function Wus(){const t=ds();return Bt({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await K.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"]}),ge.success("Proof rejected - please upload a new proof")}})}function Gus(){const{data:t,isLoading:s}=Xwe(!1),r=Cus(),n=Mus(),a=Tus(),[o,l]=M.useState(!1),[i,d]=M.useState(null),[u,f]=M.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),g=()=>{f({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),d(null)},v=w=>{d(w),f({name:w.name,description:w.description||"",image_url:w.image_url||"",sort_order:w.sort_order,is_active:w.is_active}),l(!0)},_=async w=>{w.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),g()},b=async w=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(w)};return s?e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(gs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(w=>e.jsx(gs,{className:"h-12 w-full"},w))})})]}):e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsx(Vt,{children:"Categories"}),e.jsxs(bs,{open:o,onOpenChange:w=>{l(w),w||g()},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:u.name,onChange:w=>f({...u,name:w.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",value:u.description,onChange:w=>f({...u,description:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"image_url",children:"Image URL"}),e.jsx(Re,{id:"image_url",value:u.image_url,onChange:w=>f({...u,image_url:w.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Re,{id:"sort_order",type:"number",value:u.sort_order,onChange:w=>f({...u,sort_order:parseInt(w.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:u.is_active,onCheckedChange:w=>f({...u,is_active:w})}),e.jsx(_e,{htmlFor:"is_active",children:"Active"})]}),e.jsx(Z,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:t.map(w=>e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium",children:w.name}),e.jsx(lt,{className:"max-w-xs truncate",children:w.description}),e.jsx(lt,{children:w.sort_order}),e.jsx(lt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${w.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:w.is_active?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>v(w),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>b(w.id),disabled:a.isPending,children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},w.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function Kus(){var ye,ve;const{data:t,isLoading:s}=RXe(void 0,!1),{data:r}=Xwe(!1),n=Eus(),a=Pus(),o=Ius(),l=Lus(),i=Dus(),d=Ous(),u=Rus(),f=Fus(),g=zus(),[v,_]=M.useState(!1),[b,w]=M.useState(!1),[j,N]=M.useState(!1),[S,A]=M.useState(null),[I,L]=M.useState(null),[F,$]=M.useState(!1),[q,H]=M.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}),[U,Q]=M.useState({name:"",price_adjustment:0}),[se,te]=M.useState(""),Y=()=>{H({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),A(null)},ce=ke=>{A(ke),H({name:ke.name,description:ke.description||"",base_price:Number(ke.base_price),shipping_fee:Number(ke.shipping_fee),category_id:ke.category_id||"",allow_artwork_upload:ke.allow_artwork_upload,requires_proof_approval:ke.requires_proof_approval,is_active:ke.is_active,sort_order:ke.sort_order}),_(!0)},oe=async ke=>{ke.preventDefault();const Ge={...q,category_id:q.category_id||null};S?await a.mutateAsync({id:S.id,...Ge}):await n.mutateAsync(Ge),_(!1),Y()},le=async ke=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(ke)},de=async ke=>{if(!I||!ke.target.files||ke.target.files.length===0)return;$(!0);const Ge=ke.target.files[0],Ne=Ge.name.split(".").pop(),Ae=`products/${I.id}/${Date.now()}.${Ne}`;try{const{error:Pe}=await K.storage.from("marketplace").upload(Ae,Ge);if(Pe)throw Pe;const{data:{publicUrl:Fe}}=K.storage.from("marketplace").getPublicUrl(Ae);await l.mutateAsync({product_id:I.id,image_url:Fe,is_primary:!I.images||I.images.length===0}),ge.success("Image uploaded successfully")}catch(Pe){ge.error("Failed to upload image: "+Pe.message)}finally{$(!1)}},xe=async ke=>{ke.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:U.name,price_adjustment:U.price_adjustment}),Q({name:"",price_adjustment:0}))},be=async()=>{!I||!se||(await g.mutateAsync({productId:I.id,videoUrl:se}),te(""))};return s?e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(gs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(ke=>e.jsx(gs,{className:"h-64 w-full"},ke))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsx(Vt,{children:"Products"}),e.jsxs(bs,{open:v,onOpenChange:ke=>{_(ke),ke||Y()},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:S?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:oe,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(_e,{htmlFor:"name",children:"Product Name"}),e.jsx(Re,{id:"name",value:q.name,onChange:ke=>H({...q,name:ke.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"category",children:"Category"}),e.jsxs(tr,{value:q.category_id,onValueChange:ke=>H({...q,category_id:ke}),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(er,{children:r==null?void 0:r.map(ke=>e.jsx(At,{value:ke.id,children:ke.name},ke.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Lr,{id:"description",value:q.description,onChange:ke=>H({...q,description:ke.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(_e,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(Re,{id:"base_price",type:"number",step:"0.01",min:"0",value:q.base_price,onChange:ke=>H({...q,base_price:parseFloat(ke.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(Re,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:q.shipping_fee,onChange:ke=>H({...q,shipping_fee:parseFloat(ke.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Re,{id:"sort_order",type:"number",value:q.sort_order,onChange:ke=>H({...q,sort_order:parseInt(ke.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:ke=>H({...q,allow_artwork_upload:ke})}),e.jsx(_e,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:ke=>H({...q,requires_proof_approval:ke})}),e.jsx(_e,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:q.is_active,onCheckedChange:ke=>H({...q,is_active:ke})}),e.jsx(_e,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(Z,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:S?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(ke=>{var Ge,Ne;return e.jsxs(De,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[ke.images&&ke.images.length>0?e.jsx("img",{src:((Ge=ke.images.find(Ae=>Ae.is_primary))==null?void 0:Ge.image_url)||ke.images[0].image_url,alt:ke.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"}),!ke.is_active&&e.jsx(nt,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:ke.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Ne=ke.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(ke.base_price).toFixed(2)]}),Number(ke.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(ke.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[ke.allow_artwork_upload&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),ke.requires_proof_approval&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Proof Required"}),ke.variants&&ke.variants.length>0&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:[ke.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>ce(ke),children:[e.jsx(Ga,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{L(ke),w(!0)},children:[e.jsx(_0,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{L(ke),N(!0)},children:[e.jsx(pp,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>le(ke.id),children:e.jsx(Cr,{className:"h-3 w-3 text-destructive"})})]})]})]},ke.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(bs,{open:b,onOpenChange:w,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{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:(ye=I==null?void 0:I.images)==null?void 0:ye.map(ke=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ke.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),ke.is_primary&&e.jsx(nt,{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:[!ke.is_primary&&e.jsx(Z,{variant:"secondary",size:"icon",onClick:async()=>{var Ge;await d.mutateAsync({imageId:ke.id,productId:I.id}),L({...I,images:(Ge=I.images)==null?void 0:Ge.map(Ne=>({...Ne,is_primary:Ne.id===ke.id}))})},disabled:d.isPending,title:"Set as primary",children:e.jsx(Gn,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"destructive",size:"icon",onClick:async()=>{var Ne;await i.mutateAsync({id:ke.id,productId:I.id});const Ge=t==null?void 0:t.find(Ae=>Ae.id===I.id);Ge&&L({...Ge,images:(Ne=Ge.images)==null?void 0:Ne.filter(Ae=>Ae.id!==ke.id)})},disabled:i.isPending,children:e.jsx(Cr,{className:"h-4 w-4"})})]})]},ke.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:de,className:"hidden",id:"image-upload",disabled:F}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(_0,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:F?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(_e,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(Re,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:se,onChange:ke=>te(ke.target.value)}),e.jsxs(Z,{onClick:be,disabled:!se,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(bs,{open:j,onOpenChange:N,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:xe,className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Variant name (e.g., 500 count)",value:U.name,onChange:ke=>Q({...U,name:ke.target.value}),required:!0}),e.jsx(Re,{type:"number",step:"0.01",placeholder:"Price adj.",value:U.price_adjustment,onChange:ke=>Q({...U,price_adjustment:parseFloat(ke.target.value)||0}),className:"w-32"}),e.jsx(Z,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(ve=I==null?void 0:I.variants)==null?void 0:ve.map(ke=>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:ke.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(ke.price_adjustment)>=0?"+":"","$",Number(ke.price_adjustment).toFixed(2)]})]}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>f.mutateAsync({id:ke.id,productId:I.id}),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]},ke.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 Zus=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function Yus(){var w,j,N;const{data:t,isLoading:s}=Bus(),r=Uus(),n=Vus(),[a,o]=M.useState(null),[l,i]=M.useState(!1),[d,u]=M.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[f,g]=M.useState(!1),v=S=>{o(S),u({status:S.status,notes:"",trackingNumber:S.tracking_number||"",trackingUrl:S.tracking_url||""}),i(!0)},_=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:d.status,notes:d.notes,trackingNumber:d.trackingNumber,trackingUrl:d.trackingUrl,previousStatus:a.status}),i(!1))},b=async(S,A)=>{if(!a||!S.target.files||S.target.files.length===0)return;g(!0);const I=S.target.files[0],L=I.name.split(".").pop(),F=`proofs/${a.id}/${A}/${Date.now()}.${L}`;try{const{error:$}=await K.storage.from("marketplace").upload(F,I);if($)throw $;const{data:{publicUrl:q}}=K.storage.from("marketplace").getPublicUrl(F);await n.mutateAsync({itemId:A,proofUrl:q,orderId:a.id}),ge.success("Proof uploaded successfully")}catch($){ge.error("Failed to upload proof: "+$.message)}finally{g(!1)}};return s?e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(gs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(S=>e.jsx(gs,{className:"h-16 w-full"},S))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Orders"})}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:t.map(S=>{var A,I;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-mono",children:S.order_number}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((A=S.user)==null?void 0:A.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(I=S.user)==null?void 0:I.email})]})}),e.jsx(lt,{children:js(new Date(S.created_at),"MMM d, yyyy")}),e.jsxs(lt,{className:"font-bold",children:["$",Number(S.total).toFixed(2)]}),e.jsx(lt,{children:e.jsx(nt,{className:Ywe[S.status],children:P5[S.status]})}),e.jsx(lt,{className:"text-right",children:e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>v(S),children:[e.jsx(Na,{className:"h-4 w-4 mr-1"}),"View"]})})]},S.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(bs,{open:l,onOpenChange:i,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Order ",a==null?void 0:a.order_number]})}),a&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),e.jsx("p",{children:(w=a.user)==null?void 0:w.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(j=a.user)==null?void 0:j.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(N=a.items)==null?void 0:N.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(S.unit_price).toFixed(2)," x ",S.quantity]})]}),S.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(nt,{variant:S.proof_status==="approved"?"default":"secondary",children:S.proof_status||"No proof yet"})]}),S.proof_url?e.jsx("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:A=>b(A,S.id),className:"hidden",id:`proof-${S.id}`,disabled:f}),e.jsx("label",{htmlFor:`proof-${S.id}`,children:e.jsx(Z,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(xi,{className:"h-4 w-4 mr-1"}),f?"Uploading...":"Upload Proof"]})})})]})]})})]},S.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Status"}),e.jsxs(tr,{value:d.status,onValueChange:S=>u({...d,status:S}),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:Zus.map(S=>e.jsx(At,{value:S,children:P5[S]},S))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Tracking Number"}),e.jsx(Re,{value:d.trackingNumber,onChange:S=>u({...d,trackingNumber:S.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Tracking URL"}),e.jsx(Re,{value:d.trackingUrl,onChange:S=>u({...d,trackingUrl:S.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Notes (optional)"}),e.jsx(Lr,{value:d.notes,onChange:S=>u({...d,notes:S.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(Z,{onClick:_,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(S=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(nt,{variant:"outline",children:P5[S.status]}),S.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:S.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:js(new Date(S.created_at),"MMM d, h:mm a")})]},S.id))})]})]})]})})]})}function Xus(){const[t,s]=M.useState("products"),r=Or();return e.jsx(Ms,{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(Z,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(Ia,{value:t,onValueChange:s,children:[e.jsxs(Aa,{className:"grid w-full grid-cols-3",children:[e.jsxs(Ts,{value:"products",className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(Ts,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Oh,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(Ts,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(vm,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(Vs,{value:"products",children:e.jsx(Kus,{})}),e.jsx(Vs,{value:"categories",children:e.jsx(Gus,{})}),e.jsx(Vs,{value:"orders",children:e.jsx(Yus,{})})]})]})})}function FXe(){return Tt({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await K.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function Qus(t){return Tt({queryKey:["reward-items",t],queryFn:async()=>{let s=K.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 Jus(t){return Tt({queryKey:["active-reward-items",t],queryFn:async()=>{let s=K.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 ehs(t){return Tt({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 ths(){return Tt({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await K.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 K.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 shs(t){return Tt({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await K.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 rhs(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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"]})}})}function nhs(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function ahs(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function ihs(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function ohs(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 lhs(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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 chs(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.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 dhs(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function spe(t,s){const r=dhs(t);if(r)try{const{data:n,error:a}=await K.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),ge.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),ge.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),ge.error("Failed to download file")}}function zXe(){return Tt({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await K.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function uhs(){const t=ds();return Bt({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 K.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 hhs(){const{user:t}=Qs(),[s,r]=M.useState("items"),[n,a]=M.useState(!1),[o,l]=M.useState(null),[i,d]=M.useState(""),[u,f]=M.useState(""),[g,v]=M.useState(""),[_,b]=M.useState(null),[w,j]=M.useState(!1),[N,S]=M.useState(null),[A,I]=M.useState(""),[L,F]=M.useState(""),[$,q]=M.useState(null),[H,U]=M.useState(""),[Q,se]=M.useState("file"),[te,Y]=M.useState(""),[ce,oe]=M.useState(""),[le,de]=M.useState(""),[xe,be]=M.useState(!0),[ye,ve]=M.useState(null),[ke,Ge]=M.useState(!1),[Ne,Ae]=M.useState(!1),Pe=M.useRef(null),Fe=M.useRef(null),{data:Ie,isLoading:Ve}=FXe(),{data:dt,isLoading:Le}=Qus(),{data:Rt,isLoading:fe}=ths(),{data:Qe,isLoading:at}=zXe(),rt=nhs(),je=ahs(),mt=ihs(),He=ohs(),ct=lhs(),We=chs(),Ze=uhs(),[ht,Ke]=M.useState({}),qe=bt=>{bt?(l(bt),d(bt.name),f(bt.description||""),v(bt.icon||"")):(l(null),d(""),f(""),v("")),a(!0)},Je=async()=>{if(!i.trim()){ge.error("Please enter a category name");return}try{o?(await je.mutateAsync({id:o.id,name:i,description:u||null,icon:g||null}),ge.success("Category updated successfully")):(await rt.mutateAsync({name:i,description:u||null,icon:g||null,sort_order:((Ie==null?void 0:Ie.length)||0)+1}),ge.success("Category created successfully")),a(!1)}catch(bt){console.error("Error saving category:",bt),ge.error("Failed to save category")}},Lt=async()=>{if(_)try{await mt.mutateAsync(_),ge.success("Category deleted successfully"),b(null)}catch(bt){console.error("Error deleting category:",bt),ge.error("Failed to delete category")}},zt=bt=>{var ws;bt?(S(bt),I(bt.name),F(bt.description||""),q(bt.category_id),U(bt.points_cost.toString()),se(bt.item_type),Y(bt.file_url||""),oe(bt.preview_image_url||""),de(((ws=bt.max_quantity)==null?void 0:ws.toString())||""),be(bt.is_active)):(S(null),I(""),F(""),q(null),U(""),se("file"),Y(""),oe(""),de(""),be(!0)),j(!0)},is=async(bt,ws)=>{ws==="file"?Ge(!0):Ae(!0);try{const ir=bt.name.split(".").pop(),Rr=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ir}`,oa=`${ws==="file"?"items":"previews"}/${Rr}`,{error:ri}=await K.storage.from("reward-store").upload(oa,bt);if(ri)throw ri;const{data:{publicUrl:no}}=K.storage.from("reward-store").getPublicUrl(oa);ws==="file"?Y(no):oe(no),ge.success("File uploaded successfully")}catch(ir){console.error("Error uploading file:",ir),ge.error("Failed to upload file")}finally{ws==="file"?Ge(!1):Ae(!1)}},Kt=async()=>{if(!A.trim()){ge.error("Please enter an item name");return}if(!H||parseInt(H)<0){ge.error("Please enter a valid points cost");return}try{const bt={name:A,description:L||null,category_id:$,points_cost:parseInt(H),item_type:Q,file_url:te||null,preview_image_url:ce||null,max_quantity:le?parseInt(le):null,current_quantity:le?parseInt(le):null,is_active:xe,created_by:t==null?void 0:t.id};N?(await ct.mutateAsync({id:N.id,...bt,current_quantity:N.max_quantity!==(le?parseInt(le):null)?le?parseInt(le):null:N.current_quantity}),ge.success("Item updated successfully")):(await He.mutateAsync(bt),ge.success("Item created successfully")),j(!1)}catch(bt){console.error("Error saving item:",bt),ge.error("Failed to save item")}},Qt=async()=>{if(ye)try{await We.mutateAsync(ye),ge.success("Item deleted successfully"),ve(null)}catch(bt){console.error("Error deleting item:",bt),ge.error("Failed to delete item")}},fs=async(bt,ws)=>{const ir=ht[bt];if(ir===void 0||ir===ws.toString())return;const Rr=parseInt(ir);if(isNaN(Rr)||Rr<0){ge.error("Please enter a valid positive number");return}try{await Ze.mutateAsync({id:bt,points:Rr}),ge.success("Points updated successfully"),Ke(oa=>{const ri={...oa};return delete ri[bt],ri})}catch(oa){console.error("Error updating points:",oa),ge.error("Failed to update points")}};return Ve||Le||fe||at?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-64"}),e.jsx(gs,{className:"h-96"})]})}):e.jsxs(Ms,{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(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(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:(dt==null?void 0:dt.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(dt==null?void 0:dt.filter(bt=>bt.is_active).length)||0," active"]})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Oh,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Ie==null?void 0:Ie.length)||0})]})}),e.jsx(De,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Gn,{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:[dt&&dt.length>0?Math.round(dt.reduce((bt,ws)=>bt+ws.points_cost,0)/dt.length):0," pts"]})]})})]}),e.jsxs(Ia,{value:s,onValueChange:r,children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"items",children:"Items"}),e.jsx(Ts,{value:"categories",children:"Categories"}),e.jsx(Ts,{value:"purchases",children:"Purchases"}),e.jsx(Ts,{value:"point-settings",children:"Point Settings"})]}),e.jsx(Vs,{value:"items",className:"mt-4",children:e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Store Items"}),e.jsx(_r,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(Z,{onClick:()=>zt(),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Oe,{children:!dt||dt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(uo,{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(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:dt.map(bt=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[bt.preview_image_url?e.jsx("img",{src:bt.preview_image_url,alt:bt.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(uo,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:bt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:bt.description||"No description"})]})]})}),e.jsx(lt,{children:bt.category?e.jsx(nt,{variant:"outline",children:bt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{className:"text-center",children:e.jsxs(nt,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),bt.points_cost]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[bt.item_type==="file"?e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Po,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:bt.item_type})]})}),e.jsx(lt,{className:"text-center",children:bt.max_quantity!==null?e.jsxs("span",{className:bt.current_quantity===0?"text-red-500":"",children:[bt.current_quantity,"/",bt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(lt,{className:"text-center",children:e.jsx(nt,{variant:bt.is_active?"default":"secondary",children:bt.is_active?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>zt(bt),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>ve(bt.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},bt.id))})]})})]})}),e.jsx(Vs,{value:"categories",className:"mt-4",children:e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Categories"}),e.jsx(_r,{children:"Organize your store items into categories"})]}),e.jsxs(Z,{onClick:()=>qe(),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Oe,{children:!Ie||Ie.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Oh,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:Ie.map(bt=>e.jsxs(ks,{children:[e.jsxs(lt,{className:"font-medium",children:[bt.icon&&e.jsx("span",{className:"mr-2",children:bt.icon}),bt.name]}),e.jsx(lt,{className:"text-muted-foreground",children:bt.description||"—"}),e.jsx(lt,{className:"text-center",children:(dt==null?void 0:dt.filter(ws=>ws.category_id===bt.id).length)||0}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>qe(bt),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>b(bt.id),children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})})]})})]},bt.id))})]})})]})}),e.jsx(Vs,{value:"purchases",className:"mt-4",children:e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(vm,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(_r,{children:"View all reward redemptions by agents"})]}),e.jsx(Oe,{children:!Rt||Rt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(vm,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:Rt.map(bt=>{var ws,ir,Rr,oa;return e.jsxs(ks,{children:[e.jsx(lt,{className:"text-muted-foreground",children:js(new Date(bt.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(lt,{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(mo,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ws=bt.user)==null?void 0:ws.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((ir=bt.user)==null?void 0:ir.email)||"—"})]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Rr=bt.item)!=null&&Rr.preview_image_url?e.jsx("img",{src:bt.item.preview_image_url,alt:bt.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(uo,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((oa=bt.item)==null?void 0:oa.name)||"Deleted item"})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(nt,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),bt.points_spent]})})]},bt.id)})})]})})]})})]})]}),e.jsx(bs,{open:n,onOpenChange:a,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:o?"Edit Category":"Add Category"}),e.jsx(Kr,{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(_e,{htmlFor:"categoryName",children:"Name"}),e.jsx(Re,{id:"categoryName",value:i,onChange:bt=>d(bt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Lr,{id:"categoryDescription",value:u,onChange:bt=>f(bt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(Re,{id:"categoryIcon",value:g,onChange:bt=>v(bt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Z,{onClick:Je,disabled:rt.isPending||je.isPending,children:rt.isPending||je.isPending?"Saving...":"Save"})]})]})}),e.jsx(bs,{open:w,onOpenChange:j,children:e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:N?"Edit Item":"Add Item"}),e.jsx(Kr,{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(_e,{htmlFor:"itemName",children:"Name *"}),e.jsx(Re,{id:"itemName",value:A,onChange:bt=>I(bt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Lr,{id:"itemDescription",value:L,onChange:bt=>F(bt.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(_e,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(tr,{value:$||"none",onValueChange:bt=>q(bt==="none"?null:bt),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select category"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No category"}),Ie==null?void 0:Ie.map(bt=>e.jsxs(At,{value:bt.id,children:[bt.icon&&`${bt.icon} `,bt.name]},bt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(Re,{id:"itemPointsCost",type:"number",min:"0",value:H,onChange:bt=>U(bt.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(_e,{htmlFor:"itemType",children:"Type"}),e.jsxs(tr,{value:Q,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"file",children:"File Download"}),e.jsx(At,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(Re,{id:"itemMaxQuantity",type:"number",min:"1",value:le,onChange:bt=>de(bt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:te,onChange:bt=>Y(bt.target.value),placeholder:Q==="file"?"Upload a file or paste URL":"Paste external link"}),Q==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{type:"button",variant:"outline",size:"icon",onClick:()=>{var bt;return(bt=Pe.current)==null?void 0:bt.click()},disabled:ke,children:e.jsx(xi,{className:"h-4 w-4"})}),e.jsx("input",{ref:Pe,type:"file",className:"hidden",onChange:bt=>{var ir;const ws=(ir=bt.target.files)==null?void 0:ir[0];ws&&is(ws,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:ce,onChange:bt=>oe(bt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(Z,{type:"button",variant:"outline",size:"icon",onClick:()=>{var bt;return(bt=Fe.current)==null?void 0:bt.click()},disabled:Ne,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("input",{ref:Fe,type:"file",accept:"image/*",className:"hidden",onChange:bt=>{var ir;const ws=(ir=bt.target.files)==null?void 0:ir[0];ws&&is(ws,"preview")}})]}),ce&&e.jsx("img",{src:ce,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"itemIsActive",checked:xe,onCheckedChange:be}),e.jsx(_e,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(Z,{onClick:Kt,disabled:He.isPending||ct.isPending,children:He.isPending||ct.isPending?"Saving...":"Save"})]})]})}),e.jsx(uc,{open:!!_,onOpenChange:()=>b(null),children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete Category"}),e.jsx(Xl,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:Lt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(uc,{open:!!ye,onOpenChange:()=>ve(null),children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete Item"}),e.jsx(Xl,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:Qt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(De,{className:"mt-4",children:[e.jsx($t,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pl,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Vt,{children:"Point Reward Settings"}),e.jsx(_r,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Oe,{children:!Qe||Qe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Pl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:Qe.map(bt=>e.jsxs(ks,{children:[e.jsx(lt,{children:e.jsx("p",{className:"font-medium",children:bt.action_name})}),e.jsx(lt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:bt.description})}),e.jsx(lt,{className:"text-center",children:e.jsx(Re,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:ht[bt.id]??bt.points.toString(),onChange:ws=>Ke(ir=>({...ir,[bt.id]:ws.target.value}))})}),e.jsx(lt,{className:"text-right",children:e.jsx(Z,{size:"sm",variant:"outline",disabled:ht[bt.id]===void 0||ht[bt.id]===bt.points.toString()||Ze.isPending,onClick:()=>fs(bt.id,bt.points),children:e.jsx(zh,{className:"h-4 w-4"})})})]},bt.id))})]})})]})]})}const n6e=()=>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"})]}),a6e=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function mhs(){const t=ds(),[s,r]=M.useState(!1),[n,a]=M.useState(!1),[o,l]=M.useState(!1),[i,d]=M.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:f}=Tt({queryKey:["canva-integration"],queryFn:async()=>{const{data:S,error:A}=await K.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(A)throw A;return S}}),{data:g}=Tt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:S,error:A}=await K.from("brokerages").select("id, name").order("name");if(A)throw A;return S}}),{data:v}=Tt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:S,error:A}=await K.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(A)throw A;return S}}),_=async()=>{var S;r(!0);try{const{data:A}=await K.auth.getSession(),I=(S=A==null?void 0:A.session)==null?void 0:S.access_token;if(!I)throw new Error("Not authenticated");const $=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),q=await $.json();if(!$.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to get authorization URL");if(q!=null&&q.authUrl){localStorage.setItem("canva_code_verifier",q.codeVerifier),localStorage.setItem("canva_oauth_state",q.state);const H=window.open(q.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!H){ge.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const U=se=>{var te,Y;se.origin===window.location.origin&&(((te=se.data)==null?void 0:te.type)==="canva-oauth-success"?(window.removeEventListener("message",U),ge.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((Y=se.data)==null?void 0:Y.type)==="canva-oauth-error"&&(window.removeEventListener("message",U),ge.error("Canva connection failed: "+(se.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",U);const Q=setInterval(()=>{H.closed&&(clearInterval(Q),window.removeEventListener("message",U),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(A){console.error("Canva connect error:",A);const I=(A==null?void 0:A.message)||"";I.includes("CANVA_CLIENT_ID")?ge.error("Canva app credentials not configured yet."):ge.error(I||"Failed to start Canva connection"),r(!1)}},b=Bt({mutationFn:async S=>{var H;const{data:A}=await K.auth.getSession(),I=(H=A==null?void 0:A.session)==null?void 0:H.access_token;if(!I)throw new Error("Not authenticated");const $=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:S})}),q=await $.json();if(!$.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),ge.success("Canva disconnected")},onError:S=>{ge.error(S.message||"Failed to disconnect Canva")}}),w=Bt({mutationFn:async S=>{const{error:A}=await K.from("canva_brokerage_folders").insert({brokerage_id:S.brokerage_id,folder_id:S.folder_id.trim(),folder_name:S.folder_name.trim(),folder_type:S.folder_type,description:S.description.trim()||null,sort_order:(v==null?void 0:v.length)||0});if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),ge.success("Folder added"),l(!1),d({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>ge.error("Failed to add folder")}),j=Bt({mutationFn:async S=>{const{error:A}=await K.from("canva_brokerage_folders").delete().eq("id",S);if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),ge.success("Folder removed")},onError:()=>ge.error("Failed to remove folder")}),N=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx($t,{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(n6e,{})}),e.jsxs("div",{children:[e.jsxs(Vt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",N&&e.jsx(nt,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(nt,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(_r,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{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(hi,{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(hi,{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(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect Canva?"}),e.jsx(Xl,{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(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>b.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(Oh,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",v&&v.length>0&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:v.length})]}),n?e.jsx(Tg,{className:"h-4 w-4"}):e.jsx(tl,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[v&&v.length>0?v.map(S=>{var A,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:S.folder_name}),e.jsx(nt,{variant:"outline",className:"text-xs shrink-0",children:((A=a6e.find(L=>L.value===S.folder_type))==null?void 0:A.label)||S.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=S.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:S.folder_id})]})]}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>j.mutate(S.id),children:e.jsx(Vr,{className:"h-3.5 w-3.5"})})]},S.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(Z,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx(Ys,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(Z,{className:"mt-4",onClick:_,disabled:s||f,children:[s?e.jsx(Ao,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(n6e,{})}),"Connect Canva",e.jsx(Ai,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(_e,{children:"Brokerage"}),e.jsxs(tr,{value:i.brokerage_id,onValueChange:S=>d(A=>({...A,brokerage_id:S})),children:[e.jsx(Js,{children:e.jsx(rr,{placeholder:"Select a brokerage…"})}),e.jsx(er,{children:g==null?void 0:g.map(S=>e.jsx(At,{value:S.id,children:S.name},S.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Canva Folder ID"}),e.jsx(Re,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:S=>d(A=>({...A,folder_id:S.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Folder Display Name"}),e.jsx(Re,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:S=>d(A=>({...A,folder_name:S.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Folder Type"}),e.jsxs(tr,{value:i.folder_type,onValueChange:S=>d(A=>({...A,folder_type:S})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:a6e.map(S=>e.jsx(At,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(_e,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(Re,{placeholder:"What's in this folder?",value:i.description,onChange:S=>d(A=>({...A,description:S.target.value}))})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(Z,{onClick:()=>w.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||w.isPending,children:[w.isPending?e.jsx(Ao,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function phs(){return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(pu,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(mhs,{})]})})}const fhs={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 aE(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function ghs(){var Q,se,te,Y,ce;const t=ds(),[s,r]=M.useState("Test Push"),[n,a]=M.useState("Testing web push notification"),[o,l]=M.useState("/community"),[i,d]=M.useState(!1),[u,f]=M.useState(!1),[g,v]=M.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=M.useState(null),[w,j]=M.useState(null),{data:N,isLoading:S}=Tt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:oe,error:le}=await K.from("push_notification_settings").select("*").order("setting_key");if(le)throw le;return oe}}),{data:A,isLoading:I}=Tt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:oe,error:le}=await K.from("push_subscriptions").select("*",{count:"exact",head:!0});if(le)throw le;return{totalSubscriptions:oe||0}}}),L=Bt({mutationFn:async({settingKey:oe,isEnabled:le})=>{const{error:de}=await K.from("push_notification_settings").update({is_enabled:le}).eq("setting_key",oe);if(de)throw de},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),ge.success("Notification setting updated")},onError:oe=>{ge.error("Failed to update setting: "+oe.message)}}),F=M.useMemo(()=>{var oe,le;return g.isSupported?`perm=${g.permission??"unknown"} · controller=${g.controllerPresent?"yes":"no"} · sw=${((oe=g.serviceWorker)==null?void 0:oe.activeState)??"unknown"} · sub=${(le=g.subscription)!=null&&le.endpoint?"yes":"no"}`:"Push not supported in this browser."},[g]);M.useEffect(()=>{let oe=!0;const le=async()=>{var ye,ve,ke,Ge,Ne,Ae,Pe;const xe="serviceWorker"in navigator&&"PushManager"in window,be={isSupported:xe,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ye=navigator.serviceWorker)!=null&&ye.controller)};if(!xe){oe&&v(be);return}try{const{data:Fe,error:Ie}=await K.functions.invoke("get-vapid-public-key",{body:{}});if(Ie)throw Ie;be.vapidPublicKey=Fe==null?void 0:Fe.vapidPublicKey;const dt=(await navigator.serviceWorker.getRegistrations()).find(Le=>{var fe,Qe,at;return(((fe=Le.active)==null?void 0:fe.scriptURL)||((Qe=Le.waiting)==null?void 0:Qe.scriptURL)||((at=Le.installing)==null?void 0:at.scriptURL)||"").includes("/sw.js")});if(dt){be.pushWorkerScriptUrl=((ve=dt.active)==null?void 0:ve.scriptURL)||((ke=dt.waiting)==null?void 0:ke.scriptURL)||((Ge=dt.installing)==null?void 0:Ge.scriptURL),be.serviceWorker={scope:dt.scope,activeState:(Ne=dt.active)==null?void 0:Ne.state};const Le=await dt.pushManager.getSubscription();if(Le){const Rt=Le.toJSON();be.subscription={endpoint:Rt.endpoint,p256dh:(Ae=Rt.keys)==null?void 0:Ae.p256dh,auth:(Pe=Rt.keys)==null?void 0:Pe.auth}}}}catch(Fe){be.error=(Fe==null?void 0:Fe.message)||String(Fe)}oe&&v(be)};le();const de=window.setInterval(le,4e3);return()=>{oe=!1,window.clearInterval(de)}},[]);const $=async()=>{if(typeof Notification>"u"){ge.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){ge.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),ge.success("Triggered a local notification (not push).")}catch(oe){ge.error(`Local notification failed: ${(oe==null?void 0:oe.message)||String(oe)}`)}},q=async()=>{d(!0),b(null);try{const{data:oe,error:le}=await K.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(le)throw le;b({sent:oe==null?void 0:oe.sent,failed:oe==null?void 0:oe.failed,expiredCleaned:oe==null?void 0:oe.expiredCleaned,vapidPublicKey:oe==null?void 0:oe.vapidPublicKey}),(oe==null?void 0:oe.sent)>0?ge.success(`Test notification sent to ${oe.sent} subscriber(s)`):(oe==null?void 0:oe.failed)>0?ge.warning(`Notification failed for ${oe.failed} subscriber(s). ${oe.expired||0} expired subscriptions cleaned up.`):ge.info("No active subscriptions to send to")}catch(oe){console.error("Error sending test notification:",oe),b({error:(oe==null?void 0:oe.message)||String(oe)}),ge.error("Failed to send test notification: "+(oe.message||"Unknown error"))}finally{d(!1)}},H=async()=>{f(!0),j(null);try{const{data:oe,error:le}=await K.functions.invoke("generate-vapid-keys",{body:{}});if(le)throw le;const de=oe==null?void 0:oe.publicKey,xe=oe==null?void 0:oe.privateKey;if(!de||!xe)throw new Error("generate-vapid-keys did not return keys");j({publicKey:de,privateKey:xe}),ge.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(oe){console.error("Error generating VAPID keys:",oe),ge.error("Failed to generate VAPID keys: "+((oe==null?void 0:oe.message)||"Unknown error"))}finally{f(!1)}},U=Bt({mutationFn:async()=>{const{error:oe}=await K.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(oe)throw oe},onSuccess:()=>{ge.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:oe=>{ge.error("Failed to clear subscriptions: "+oe.message)}});return e.jsx(Ms,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(xr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(_r,{children:"Current active push notification subscriptions"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:I?"...":(A==null?void 0:A.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Pl,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(_r,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Oe,{children:S?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(oe=>{const le=fhs[oe.setting_key]||{label:oe.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:le.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:le.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:oe.description})]})]}),e.jsx(qr,{checked:oe.is_enabled,onCheckedChange:de=>L.mutate({settingKey:oe.setting_key,isEnabled:de}),disabled:L.isPending})]},oe.id)})})})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(af,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(_r,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Client push debug"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:F}),g.error&&e.jsx("div",{className:"mt-2 text-destructive",children:g.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:g.vapidPublicKey?aE(g.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: ",(Q=g.serviceWorker)!=null&&Q.scope?aE(g.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((se=g.serviceWorker)==null?void 0:se.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=g.subscription)!=null&&te.endpoint?aE(g.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Y=g.subscription)!=null&&Y.p256dh?aE(g.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ce=g.subscription)!=null&&ce.auth?aE(g.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(Z,{variant:"outline",onClick:$,children:"Local notification test"}),e.jsx(Z,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(Re,{id:"test-title",value:s,onChange:oe=>r(oe.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Lr,{id:"test-body",value:n,onChange:oe=>a(oe.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(Re,{id:"test-url",value:o,onChange:oe=>l(oe.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(Z,{onClick:q,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),_&&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"}),_.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",_.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",_.sent??0," sent, ",_.failed??0," failed, ",_.expiredCleaned??0," expired cleaned"]}),_.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:_.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Cr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(_r,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(Z,{variant:"destructive",onClick:()=>U.mutate(),disabled:U.isPending,children:[e.jsx(Cr,{className:"h-4 w-4 mr-2"}),U.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(Z,{variant:"outline",onClick:H,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),w&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.privateKey})]})]})]})]})]})]})})}function xhs(){const{toast:t}=La(),[s,r]=M.useState([]),[n,a]=M.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=M.useState(!0),{sortKey:i,sortDirection:d,handleSort:u,sortData:f}=NL("presentation_count","desc"),g=f(s,{name:b=>{var w;return((w=b.name)==null?void 0:w.toLowerCase())||""},presentations:b=>b.presentation_count,views:b=>b.total_views,leads:b=>b.total_leads,cta_clicks:b=>b.total_cta_clicks,conversion:b=>b.total_views>0?b.total_leads/b.total_views*100:0});M.useEffect(()=>{v()},[]);const v=async()=>{try{l(!0);const{data:b,error:w}=await K.rpc("get_admin_presentation_stats");if(w)throw w;if(!b||b.length===0){l(!1);return}const j=b.map(L=>L.owner_user_id),{data:N,error:S}=await K.from("profiles").select("id, name, email, avatar_url").in("id",j);if(S)throw S;const A=new Map((N==null?void 0:N.map(L=>[L.id,L]))||[]),I=b.map(L=>{const F=A.get(L.owner_user_id);return{owner_user_id:L.owner_user_id,name:(F==null?void 0:F.name)||"Unknown",email:(F==null?void 0:F.email)||"",avatar_url:(F==null?void 0:F.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,F)=>L+F.presentation_count,0),totalViews:I.reduce((L,F)=>L+F.total_views,0),totalLeads:I.reduce((L,F)=>L+F.total_leads,0),totalCtaClicks:I.reduce((L,F)=>L+F.total_cta_clicks,0),agentsUsing:I.length})}catch(b){console.error("Error loading presentation stats:",b),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},_=[{label:"Agents Using",value:n.agentsUsing,icon:xr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:lf,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:Na,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:pc,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Z1,color:"text-rose-600"}];return e.jsx(Ms,{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:_.map(b=>e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:b.label}),e.jsx(b.icon,{className:`h-4 w-4 ${b.color}`})]}),e.jsx(Oe,{children:o?e.jsx(gs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:b.value.toLocaleString()})})]},b.label))}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Vc,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,w)=>e.jsx(gs,{className:"h-12 w-full"},w))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(Qo,{sortKey:"name",currentSortKey:i,currentDirection:d,onSort:u,children:"Agent"}),e.jsx(Qo,{sortKey:"presentations",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(Qo,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Views"}),e.jsx(Qo,{sortKey:"leads",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Leads"}),e.jsx(Qo,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(Qo,{sortKey:"conversion",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(Ln,{children:g.map(b=>{var j,N;const w=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(ks,{children:[e.jsx(lt,{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:b.avatar_url?e.jsx("img",{src:b.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((N=(j=b.name)==null?void 0:j.charAt(0))==null?void 0:N.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:b.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:b.email})]})]})}),e.jsx(lt,{className:"text-center font-medium",children:b.presentation_count}),e.jsx(lt,{className:"text-center",children:b.total_views.toLocaleString()}),e.jsx(lt,{className:"text-center",children:b.total_leads>0?e.jsx(nt,{variant:"secondary",children:b.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(lt,{className:"text-center",children:b.total_cta_clicks}),e.jsx(lt,{className:"text-center",children:e.jsxs("span",{className:Number(w)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[w,"%"]})})]},b.owner_user_id)})})]})})]})]})})}function yhs(){const{toast:t}=La(),[s,r]=M.useState([]),[n,a]=M.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=M.useState(!0);M.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:f}=await K.rpc("get_admin_guest_book_stats");if(f)throw f;if(!u||u.length===0){l(!1);return}const g=u.map(j=>j.agent_id),{data:v,error:_}=await K.from("profiles").select("id, name, email, avatar_url").in("id",g);if(_)throw _;const b=new Map((v==null?void 0:v.map(j=>[j.id,j]))||[]),w=u.map(j=>{const N=b.get(j.agent_id);return{agent_id:j.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(j.open_house_count),total_visitors:Number(j.total_visitors),total_leads:Number(j.total_leads),active_count:Number(j.active_count)}});w.sort((j,N)=>N.total_visitors-j.total_visitors),r(w),a({totalOpenHouses:w.reduce((j,N)=>j+N.open_house_count,0),totalVisitors:w.reduce((j,N)=>j+N.total_visitors,0),totalLeads:w.reduce((j,N)=>j+N.total_leads,0),activeOpenHouses:w.reduce((j,N)=>j+N.active_count,0),agentsUsing:w.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:xr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Hn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:hi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:Na,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:pc,color:"text-rose-600"}];return e.jsx(Ms,{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:d.map(u=>e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Vt,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Oe,{children:o?e.jsx(gs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:u.value.toLocaleString()})})]},u.label))}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Vc,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,f)=>e.jsx(gs,{className:"h-12 w-full"},f))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:s.map(u=>{var g,v;const f=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(ks,{children:[e.jsx(lt,{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:((v=(g=u.name)==null?void 0:g.charAt(0))==null?void 0:v.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(lt,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(lt,{className:"text-center",children:u.active_count>0?e.jsx(nt,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(lt,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(lt,{className:"text-center",children:u.total_leads>0?e.jsx(nt,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(lt,{className:"text-center",children:e.jsxs("span",{className:Number(f)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[f,"%"]})})]},u.agent_id)})})]})})]})]})})}function vhs(){const[t]=Gc(),s=Or(),[r,n]=M.useState("loading"),[a,o]=M.useState("Processing connection...");return M.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),f=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),ge.error("Failed to connect: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),ge.error("Failed to connect: No authorization code");return}try{const{data:g,error:v}=await K.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:f}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Accounts connected successfully!"),ge.success(g.message||"Social accounts connected!");else throw new Error((g==null?void 0:g.error)||"Failed to connect accounts")}catch(g){console.error("Callback error:",g),n("error"),o(g.message||"Failed to complete connection"),ge.error(g.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(De,{className:"w-full max-w-md",children:[e.jsxs($t,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(Rs,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(bc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Vt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(_r,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(Z,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function _hs(){const t=ds(),[s,r]=M.useState(""),[n,a]=M.useState(""),[o,l]=M.useState([]),i=M.useRef(null),{data:d,isLoading:u}=Tt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:j,error:N}=await K.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(N)throw N;return j}}),f={total:(d==null?void 0:d.length)||0,sent:(d==null?void 0:d.filter(j=>j.status==="sent").length)||0,converted:(d==null?void 0:d.filter(j=>j.status==="converted").length)||0,conversionRate:d!=null&&d.length?Math.round(d.filter(j=>j.status==="converted").length/d.length*100):0},g=Bt({mutationFn:async j=>{const{data:N,error:S}=await K.functions.invoke("send-prospect-email",{body:{emails:j}});if(S)throw S;return N},onSuccess:j=>{t.invalidateQueries({queryKey:["prospect-emails"]}),ge.success(`${j.sent} email${j.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:j=>{ge.error("Failed to send: "+j.message)}}),v=Bt({mutationFn:async()=>{var A,I;const{data:{user:j}}=await K.auth.getUser();if(!(j!=null&&j.email))throw new Error("Could not get your email");const{data:N,error:S}=await K.functions.invoke("send-prospect-email",{body:{emails:[{email:j.email,first_name:(I=(A=j.user_metadata)==null?void 0:A.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(S)throw S;return N},onSuccess:()=>{ge.success("Test email sent to your inbox!")},onError:j=>{ge.error("Failed to send test: "+j.message)}}),_=()=>{if(!s.trim()){ge.error("Please enter an email address");return}if(d==null?void 0:d.find(N=>N.email.toLowerCase()===s.trim().toLowerCase())){ge.error("This email has already been prospected");return}g.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},b=j=>{var A;const N=(A=j.target.files)==null?void 0:A[0];if(!N)return;const S=new FileReader;S.onload=I=>{var H,U;const F=((H=I.target)==null?void 0:H.result).split(` `).filter(Q=>Q.trim()),$=[],q=(U=F[0])!=null&&U.toLowerCase().includes("email")?1:0;for(let Q=q;Qce.trim().replace(/"/g,"")),te=se[0],Y=se[1];te&&te.includes("@")&&$.push({email:te,first_name:Y||void 0})}l($),ge.success(`${$.length} entries loaded from CSV`)},S.readAsText(N),i.current&&(i.current.value="")},w=()=>{if(o.length===0){ge.error("No entries to send");return}const j=new Set((d==null?void 0:d.map(S=>S.email.toLowerCase()))||[]),N=o.filter(S=>!j.has(S.email.toLowerCase()));if(N.length===0){ge.error("All emails have already been prospected");return}N.lengthv.mutate(),disabled:v.isPending,className:"gap-2 ml-4 shrink-0",children:[v.isPending?e.jsx(Rs,{className:"h-3 w-3 animate-spin"}):e.jsx(Ar,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Oe,{children:e.jsxs(Ia,{defaultValue:"single",children:[e.jsxs(Aa,{className:"mb-4",children:[e.jsxs(Ts,{value:"single",children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(Ts,{value:"bulk",children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(Vs,{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(_e,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(Re,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:j=>r(j.target.value),onKeyDown:j=>j.key==="Enter"&&_()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(_e,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(Re,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:j=>a(j.target.value),onKeyDown:j=>j.key==="Enter"&&_()})]}),e.jsxs(Z,{onClick:_,disabled:g.isPending,className:"gap-2",children:[g.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(Pa,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(Vs,{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:b,className:"hidden"}),e.jsxs(Z,{variant:"outline",onClick:()=>{var j;return(j=i.current)==null?void 0:j.click()},className:"gap-2",children:[e.jsx(Un,{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(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(xr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Vr,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((j,N)=>e.jsxs("div",{className:"text-muted-foreground",children:[j.email,j.first_name?` — ${j.first_name}`:""]},N)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(Z,{onClick:w,disabled:g.isPending,className:"gap-2",children:[g.isPending?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(Pa,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Ar,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(_r,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((j,N)=>e.jsx(gs,{className:"h-12 w-full"},N))}):d&&d.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:d.map(j=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:j.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:js(new Date(j.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:j.status==="converted"?e.jsxs(nt,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(Ma,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.converted_at?js(new Date(j.converted_at),"MMM d, yyyy"):"—"})]},j.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Mm,{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 fce(t){const s=ds(),{toast:r}=La(),n=Tt({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:d,error:u}=await K.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return d},enabled:!!t}),a=Tt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const{data:d,error:u}=await K.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(u)throw u;return d},enabled:!!t}),o=Bt({mutationFn:async d=>{const{data:{user:u}}=await K.auth.getUser();if(!u)throw new Error("Not authenticated");const f={first_name:d.first_name||"",last_name:d.last_name||null,email:d.email||null,phone:d.phone||null,current_brokerage:d.current_brokerage||null,license_number:d.license_number||null,experience_years:d.experience_years??null,annual_production:d.annual_production||null,source:d.source||"manual",notes:d.notes||null,stage_id:d.stage_id||null,brokerage_id:t,created_by:u.id,address:d.address||null,city:d.city||null,state:d.state||null,zip_code:d.zip_code||null,last_year_volume:d.last_year_volume||null,last_year_transactions:d.last_year_transactions??null,avg_sale_price:d.avg_sale_price||null,specialties:d.specialties||null,linkedin_url:d.linkedin_url||null,website_url:d.website_url||null,instagram_handle:d.instagram_handle||null,facebook_url:d.facebook_url||null,birthday:d.birthday||null,spouse_name:d.spouse_name||null,interests:d.interests||null,referred_by:d.referred_by||null},{data:g,error:v}=await K.from("recruit_prospects").insert(f).select().single();if(v)throw v;return g},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),l=Bt({mutationFn:async({id:d,...u})=>{const{data:f,error:g}=await K.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",d).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),i=Bt({mutationFn:async d=>{const{error:u}=await K.from("recruit_prospects").delete().eq("id",d);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 bhs(t){const s=ds(),{toast:r}=La(),n=Tt({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await K.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Bt({mutationFn:async o=>{const{data:{user:l}}=await K.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:d}=await K.from("recruit_activities").insert({...o,created_by:l.id}).select().single();if(d)throw d;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 i6e=(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 BXe({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=M.useState(i6e(n,r)),d=f=>g=>i(v=>({...v,[f]:g.target.value})),u=f=>{f.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(i6e(n,r)),s(!1)};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(Ia,{defaultValue:"basic",className:"w-full",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-4",children:[e.jsx(Ts,{value:"basic",children:"Basic Info"}),e.jsx(Ts,{value:"production",children:"Production"}),e.jsx(Ts,{value:"social",children:"Social & Web"}),e.jsx(Ts,{value:"personal",children:"Personal"})]}),e.jsxs(Vs,{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(_e,{children:"First Name *"}),e.jsx(Re,{required:!0,value:l.first_name,onChange:d("first_name")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Last Name"}),e.jsx(Re,{value:l.last_name,onChange:d("last_name")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Email"}),e.jsx(Re,{type:"email",value:l.email,onChange:d("email")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Phone"}),e.jsx(Re,{value:l.phone,onChange:d("phone")})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Current Brokerage"}),e.jsx(Re,{value:l.current_brokerage,onChange:d("current_brokerage")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"License #"}),e.jsx(Re,{value:l.license_number,onChange:d("license_number")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Experience (years)"}),e.jsx(Re,{type:"number",min:"0",value:l.experience_years,onChange:d("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Address"}),e.jsx(Re,{placeholder:"Street address",value:l.address,onChange:d("address")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"City"}),e.jsx(Re,{value:l.city,onChange:d("city")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"State"}),e.jsx(Re,{value:l.state,onChange:d("state")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Zip"}),e.jsx(Re,{value:l.zip_code,onChange:d("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Pipeline Stage"}),e.jsxs(tr,{value:l.stage_id,onValueChange:f=>i(g=>({...g,stage_id:f})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:r.map(f=>e.jsx(At,{value:f.id,children:f.name},f.id))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Referred By"}),e.jsx(Re,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:d("referred_by")})]})]}),e.jsxs(Vs,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Annual Production Volume"}),e.jsx(Re,{placeholder:"e.g. $5M, 20 transactions",value:l.annual_production,onChange:d("annual_production")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Last Year Volume"}),e.jsx(Re,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:d("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Last Year Transactions"}),e.jsx(Re,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:d("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Avg Sale Price"}),e.jsx(Re,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:d("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Specialties / Niche"}),e.jsx(Re,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:d("specialties")})]})]}),e.jsxs(Vs,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"LinkedIn URL"}),e.jsx(Re,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:d("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Website URL"}),e.jsx(Re,{type:"url",placeholder:"https://...",value:l.website_url,onChange:d("website_url")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Instagram Handle"}),e.jsx(Re,{placeholder:"@handle",value:l.instagram_handle,onChange:d("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Facebook URL"}),e.jsx(Re,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:d("facebook_url")})]})]}),e.jsxs(Vs,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Birthday"}),e.jsx(Re,{type:"date",value:l.birthday,onChange:d("birthday")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Spouse / Partner Name"}),e.jsx(Re,{value:l.spouse_name,onChange:d("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Interests / Hobbies"}),e.jsx(Re,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:d("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Notes"}),e.jsx(Lr,{value:l.notes,onChange:d("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const d0e=[{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 whs(t){return Tt({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 jhs(t){return Tt({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 khs(){const t=ds(),{toast:s}=La();return Bt({mutationFn:async r=>{const{data:{user:n}}=await K.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await K.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 $Xe(){const t=ds();return Bt({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await K.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 qXe(t){return Tt({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 Nhs(){const t=ds(),{toast:s}=La();return Bt({mutationFn:async r=>{const{data:{user:n}}=await K.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await K.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 Shs(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function Chs({prospectId:t,prospectName:s,brokerageId:r}){var H;const{data:n=[],isLoading:a}=jhs(t),{data:o=[]}=qXe(r),l=khs(),i=XN(),d=$Xe(),[u,f]=M.useState("idle"),[g,v]=M.useState(0),[_,b]=M.useState(0),[w,j]=M.useState(""),[N,S]=M.useState(""),[A,I]=M.useState(!1),L=((H=o.find(U=>U.id===w))==null?void 0:H.script_text)||"",F=()=>{f("idle"),v(0),b(0),j(""),S("")},$=M.useCallback(async(U,Q)=>{f("uploading");try{const se=`Recruiting: ${s}`,{videoId:te,libraryId:Y}=await EL(se),{uploadUrl:ce,apiKey:oe}=await PL(te),le=new XMLHttpRequest;le.upload.onprogress=Ne=>{Ne.lengthComputable&&v(Ne.loaded/Ne.total*100)},await new Promise((Ne,Ae)=>{le.onload=()=>le.status>=200&&le.status<300?Ne():Ae(new Error("Upload failed")),le.onerror=()=>Ae(new Error("Upload failed")),le.open("PUT",ce),le.setRequestHeader("AccessKey",oe),le.send(U)}),f("processing");let de=0;const xe=Date.now(),be=9e4,ye=`https://iframe.mediadelivery.net/embed/${Y}/${te}`;for(;de<4&&(await new Promise(Ae=>setTimeout(Ae,3e3)),!(Date.now()-xe>be));){const Ne=await y3(te);if(de=Ne.status,b(Ne.encodeProgress||0),de===5||de===6)throw new Error("Video processing failed")}const ve=await y3(te),ke=(ve.storageSize||U.size)/(1024*1024),Ge=await i.mutateAsync({bunny_video_id:te,playback_url:ve.directPlayUrl||ye,thumbnail_url:ve.thumbnailUrl,preview_url:ve.previewUrl||null,duration_seconds:ve.length||Q,file_size_mb:ke,title:se,status:de>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ge.id,brokerage_id:r,message:N||void 0}),f("done"),ge.success("Video recorded and linked to prospect!"),setTimeout(()=>{I(!1),F()},1500)}catch(se){ge.error(se.message||"Failed to upload video"),f("record")}},[t,s,r,N,i,l]),q=U=>{U&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${U}`),ge.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(bs,{open:A,onOpenChange:U=>{!U&&(u==="uploading"||u==="processing")||(I(U),U||F())},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>f("script"),children:[e.jsx(Ys,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(tr,{value:w,onValueChange:j,children:[e.jsx(Js,{className:"mt-1",children:e.jsx(rr,{placeholder:"No script — speak freely"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No script"}),o.map(U=>{var Q;return e.jsx(At,{value:U.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[U.title,e.jsx(nt,{variant:"outline",className:"text-[9px] ml-1",children:(Q=d0e.find(se=>se.value===U.category))==null?void 0:Q.label})]})},U.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(_e,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Lr,{value:N,onChange:U=>S(U.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(Z,{onClick:()=>f("record"),className:"w-full",children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(pce,{maxDurationSeconds:60,onRecordingComplete:$,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(wo,{value:g,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(g),"%"]})]}),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(wo,{value:_,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(_),"%"]})]}),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(dl,{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(U=>{var Q,se;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:(Q=U.video)!=null&&Q.thumbnail_url?e.jsx("img",{src:U.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:((se=U.video)==null?void 0:se.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[U.view_count>0?e.jsxs(nt,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(Na,{className:"h-2.5 w-2.5 mr-0.5"}),U.view_count]}):U.sent_at?e.jsxs(nt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Pa,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(nt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Tn,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:js(new Date(U.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>q(U.share_token),children:e.jsx(Ni,{className:"h-3 w-3"})}),!U.sent_at&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:U.id,sent_via:"email"}),children:e.jsx(Pa,{className:"h-3 w-3"})})]})]},U.id)})})]})}const o6e=[{value:"call",label:"Phone Call",icon:ga},{value:"email",label:"Email",icon:Ar},{value:"text",label:"Text Message",icon:ho},{value:"meeting",label:"Meeting",icon:nn},{value:"note",label:"Note",icon:Un}];function Gm({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 cR({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(un,{className:"h-3 w-3 opacity-50"})]}):null}function Bl({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:t}),e.jsx(Re,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function UXe({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:d}=bhs((t==null?void 0:t.id)||null),[u,f]=M.useState({type:"note",title:"",description:""}),[g,v]=M.useState(!1),[_,b]=M.useState(!1),[w,j]=M.useState({});if(!t)return null;const N=()=>{var Q,se;j({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:((Q=t.experience_years)==null?void 0:Q.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:((se=t.last_year_transactions)==null?void 0:se.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||""}),b(!0)},S=()=>{const Q={id:t.id};for(const[se,te]of Object.entries(w))se==="experience_years"||se==="last_year_transactions"?Q[se]=te?parseInt(te):null:Q[se]=te||null;o(Q),b(!1)},A=()=>b(!1),I=Q=>se=>j(te=>({...te,[Q]:se})),L=()=>{u.title.trim()&&(d.mutate({prospect_id:t.id,activity_type:u.type,title:u.title,description:u.description||null}),f({type:"note",title:"",description:""}),v(!1))},F=s.find(Q=>Q.id===t.stage_id),$=t.address||t.city||t.state,q=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,H=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,U=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(uL,{open:n,onOpenChange:Q=>{Q||b(!1),a(Q)},children:e.jsx(lM,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Fi,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(hL,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(mL,{className:"text-xl",children:[t.first_name," ",t.last_name]}),F&&e.jsx(nt,{variant:"outline",style:{borderColor:F.color,color:F.color},className:"mt-1",children:F.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:A,children:e.jsx(Vr,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"default",size:"icon",onClick:S,children:e.jsx(zh,{className:"h-4 w-4"})})]}):e.jsx(Z,{variant:"ghost",size:"icon",onClick:N,title:"Edit prospect",children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Delete prospect?"}),e.jsx(Xl,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{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(Ar,{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(ga,{className:"h-3.5 w-3.5"})," ",t.phone]}),$&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Pi,{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(_e,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(tr,{value:t.stage_id||"",onValueChange:Q=>o({id:t.id,stage_id:Q}),children:[e.jsx(Js,{className:"mt-1",children:e.jsx(rr,{})}),e.jsx(er,{children:s.map(Q=>e.jsx(At,{value:Q.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:Q.color}}),Q.name]})},Q.id))})]})]}),e.jsxs(Ia,{defaultValue:"details",className:"w-full",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(Ts,{value:"details",className:"text-xs",children:"Details"}),e.jsx(Ts,{value:"production",className:"text-xs",children:"Production"}),e.jsx(Ts,{value:"social",className:"text-xs",children:"Social"}),e.jsx(Ts,{value:"personal",className:"text-xs",children:"Personal"})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs(Vs,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Bl,{label:"First Name",value:w.first_name,onChange:I("first_name")}),e.jsx(Bl,{label:"Last Name",value:w.last_name,onChange:I("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Bl,{label:"Email",value:w.email,onChange:I("email"),type:"email"}),e.jsx(Bl,{label:"Phone",value:w.phone,onChange:I("phone")})]}),e.jsx(Bl,{label:"Current Brokerage",value:w.current_brokerage,onChange:I("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Bl,{label:"License #",value:w.license_number,onChange:I("license_number")}),e.jsx(Bl,{label:"Experience (years)",value:w.experience_years,onChange:I("experience_years"),type:"number"})]}),e.jsx(Bl,{label:"Address",value:w.address,onChange:I("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Bl,{label:"City",value:w.city,onChange:I("city")}),e.jsx(Bl,{label:"State",value:w.state,onChange:I("state")}),e.jsx(Bl,{label:"Zip",value:w.zip_code,onChange:I("zip_code")})]}),e.jsx(Bl,{label:"Source",value:w.source,onChange:I("source")}),e.jsx(Bl,{label:"Referred By",value:w.referred_by,onChange:I("referred_by")}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Notes"}),e.jsx(Lr,{value:w.notes,onChange:Q=>j(se=>({...se,notes:Q.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(Vs,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Bl,{label:"Annual Production",value:w.annual_production,onChange:I("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Bl,{label:"Last Year Volume",value:w.last_year_volume,onChange:I("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Bl,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:I("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Bl,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:I("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Bl,{label:"Specialties / Niche",value:w.specialties,onChange:I("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(Vs,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Bl,{label:"LinkedIn URL",value:w.linkedin_url,onChange:I("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Bl,{label:"Website URL",value:w.website_url,onChange:I("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Bl,{label:"Instagram Handle",value:w.instagram_handle,onChange:I("instagram_handle"),placeholder:"@handle"}),e.jsx(Bl,{label:"Facebook URL",value:w.facebook_url,onChange:I("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(Vs,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(Bl,{label:"Birthday",value:w.birthday,onChange:I("birthday"),type:"date"}),e.jsx(Bl,{label:"Spouse / Partner",value:w.spouse_name,onChange:I("spouse_name")}),e.jsx(Bl,{label:"Interests / Hobbies",value:w.interests,onChange:I("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Vs,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gm,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Gm,{label:"License #",value:t.license_number}),e.jsx(Gm,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Gm,{label:"Referred By",value:t.referred_by}),e.jsx(Gm,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx(Vs,{value:"production",className:"mt-3",children:q?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gm,{label:"Annual Production",value:t.annual_production}),e.jsx(Gm,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Gm,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Gm,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Gm,{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(Vs,{value:"social",className:"mt-3",children:H?e.jsxs("div",{className:"space-y-2",children:[e.jsx(cR,{label:"LinkedIn",url:t.linkedin_url,icon:Cm}),e.jsx(cR,{label:"Website",url:t.website_url,icon:up}),t.instagram_handle&&e.jsx(cR,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:zd}),e.jsx(cR,{label:"Facebook",url:t.facebook_url,icon:Fd})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(Vs,{value:"personal",className:"mt-3",children:U?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gm,{label:"Birthday",value:t.birthday?js(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:uo}),e.jsx(Gm,{label:"Spouse / Partner",value:t.spouse_name,icon:Oi}),e.jsx("div",{className:"col-span-2",children:e.jsx(Gm,{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(Chs,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(Jl,{}),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(Z,{size:"sm",variant:"outline",onClick:()=>v(!g),children:[e.jsx(Ys,{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(tr,{value:u.type,onValueChange:Q=>f(se=>({...se,type:Q})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:o6e.map(Q=>e.jsx(At,{value:Q.value,children:Q.label},Q.value))})]}),e.jsx(Re,{placeholder:"Subject / Title",value:u.title,onChange:Q=>f(se=>({...se,title:Q.target.value}))}),e.jsx(Lr,{placeholder:"Details (optional)",value:u.description,onChange:Q=>f(se=>({...se,description:Q.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"Cancel"}),e.jsx(Z,{size:"sm",onClick:L,disabled:!u.title.trim(),children:"Save"})]})]}),e.jsxs("div",{className:"space-y-3",children:[i.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}),i.map(Q=>{const se=o6e.find(Y=>Y.value===Q.activity_type),te=(se==null?void 0:se.icon)||Un;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(te,{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:Q.title}),Q.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:Q.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:js(new Date(Q.created_at),"MMM d, yyyy h:mm a")})]})]},Q.id)})]})]})]})})})})}const l6e=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes"];function VXe({open:t,onOpenChange:s,brokerageId:r,stages:n}){var U;const{toast:a}=La(),o=ds(),l=M.useRef(null),[i,d]=M.useState([]),[u,f]=M.useState([]),[g,v]=M.useState({}),[_,b]=M.useState(((U=n[0])==null?void 0:U.id)||""),[w,j]=M.useState(!1),[N,S]=M.useState("upload"),[A,I]=M.useState(0),L=()=>{d([]),f([]),v({}),S("upload"),I(0)},F=Q=>{var Y;const se=(Y=Q.target.files)==null?void 0:Y[0];if(!se)return;const te=new FileReader;te.onload=ce=>{var ye;const le=((ye=ce.target)==null?void 0:ye.result).split(/\r?\n/).filter(ve=>ve.trim());if(le.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const de=$(le[0]);f(de);const xe={};de.forEach((ve,ke)=>{const Ge=ve.toLowerCase().replace(/[^a-z]/g,"_").replace(/_+/g,"_"),Ne=l6e.find(Ae=>Ge.includes(Ae)||Ae.includes(Ge)||Ae==="first_name"&&(Ge.includes("first")||Ge==="name")||Ae==="last_name"&&Ge.includes("last")||Ae==="current_brokerage"&&(Ge.includes("brokerage")||Ge.includes("company"))||Ae==="license_number"&&Ge.includes("license")||Ae==="experience_years"&&(Ge.includes("experience")||Ge.includes("years"))||Ae==="annual_production"&&(Ge.includes("production")||Ge.includes("volume")));Ne&&(xe[String(ke)]=Ne)}),v(xe);const be=le.slice(1).map(ve=>{const ke=$(ve),Ge={};return de.forEach((Ne,Ae)=>{Ge[String(Ae)]=ke[Ae]||""}),Ge});d(be),S("map")},te.readAsText(se)},$=Q=>{const se=[];let te="",Y=!1;for(const ce of Q)ce==='"'?Y=!Y:ce===","&&!Y?(se.push(te.trim()),te=""):te+=ce;return se.push(te.trim()),se},q=async()=>{j(!0);try{const{data:{user:Q}}=await K.auth.getUser();if(!Q)throw new Error("Not authenticated");const se=i.map(Y=>{const ce={brokerage_id:r,created_by:Q.id,stage_id:_,source:"csv_import",first_name:"Unknown"};return Object.entries(g).forEach(([oe,le])=>{var xe;const de=(xe=Y[oe])==null?void 0:xe.trim();de&&(le==="experience_years"?ce[le]=parseInt(de)||null:ce[le]=de)}),ce});let te=0;for(let Y=0;Y{const Q=`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`,se=new Blob([Q],{type:"text/csv"}),te=URL.createObjectURL(se),Y=document.createElement("a");Y.href=te,Y.download="recruit-prospects-template.csv",Y.click(),URL.revokeObjectURL(te)};return e.jsx(bs,{open:t,onOpenChange:Q=>{Q||L(),s(Q)},children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(x0,{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:F}),e.jsxs(Z,{onClick:()=>{var Q;return(Q=l.current)==null?void 0:Q.click()},children:[e.jsx(xi,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(Z,{variant:"link",className:"text-xs",onClick:H,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(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{})}),e.jsx(er,{children:n.map(Q=>e.jsx(At,{value:Q.id,children:Q.name},Q.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Ln,{children:u.map((Q,se)=>{var te;return e.jsxs(ks,{children:[e.jsx(lt,{className:"font-medium text-xs",children:Q}),e.jsx(lt,{children:e.jsxs(tr,{value:g[String(se)]||"skip",onValueChange:Y=>v(ce=>({...ce,[String(se)]:Y==="skip"?"":Y})),children:[e.jsx(Js,{className:"h-8 text-xs",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"skip",children:"— Skip —"}),l6e.map(Y=>e.jsx(At,{value:Y,children:Y.replace(/_/g," ")},Y))]})]})}),e.jsx(lt,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((te=i[0])==null?void 0:te[String(se)])||"—"})]},se)})})]})}),!Object.values(g).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(Yo,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>{L()},children:"Back"}),e.jsx(Z,{onClick:q,disabled:w||!Object.values(g).includes("first_name"),children:w?"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(ma,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[A," prospects imported successfully!"]}),e.jsx(Z,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function Mhs({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=fce(t),[i,d]=M.useState(!1),[u,f]=M.useState(),[g,v]=M.useState(null),[_,b]=M.useState(!1),[w,j]=M.useState(!1),[N,S]=M.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 A=H=>r.filter(U=>U.stage_id===H),I=(H,U)=>{S(U),H.dataTransfer.effectAllowed="move"},L=H=>{H.preventDefault(),H.dataTransfer.dropEffect="move"},F=(H,U)=>{H.preventDefault(),N&&(o.mutate({id:N,stage_id:U}),S(null))},$=H=>{f(H),d(!0)},q=H=>{v(H),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(Z,{variant:"outline",onClick:()=>j(!0),children:[e.jsx(xi,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(Z,{onClick:()=>{f(void 0),d(!0)},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Fi,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(H=>{const U=A(H.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:L,onDrop:Q=>F(Q,H.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:H.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:H.name}),e.jsx(nt,{variant:"secondary",className:"text-xs h-5 px-1.5",children:U.length})]}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>$(H.id),children:e.jsx(Ys,{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:U.map(Q=>e.jsx(De,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:H.color},draggable:!0,onDragStart:se=>I(se,Q.id),onClick:()=>q(Q),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Rh,{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(mo,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[Q.first_name," ",Q.last_name]})]}),Q.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(_a,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Q.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Q.email&&e.jsx(Ar,{className:"h-3 w-3 text-muted-foreground"}),Q.phone&&e.jsx(ga,{className:"h-3 w-3 text-muted-foreground"}),Q.experience_years!=null&&e.jsxs(nt,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[Q.experience_years,"yr"]})]})]})]})},Q.id))})]},H.id)})}),e.jsx(woe,{orientation:"horizontal"})]}),e.jsx(BXe,{open:i,onOpenChange:d,stages:s,defaultStageId:u,onSubmit:H=>a.mutate(H),isSubmitting:a.isPending}),e.jsx(UXe,{prospect:g,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:H=>{o.mutate(H),v(U=>U?{...U,...H}:null)},onDelete:H=>l.mutate(H)}),e.jsx(VXe,{open:w,onOpenChange:j,brokerageId:t,stages:s})]})}function Ths({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=fce(t),[i,d]=M.useState(!1),[u,f]=M.useState(null),[g,v]=M.useState(!1),[_,b]=M.useState(!1),[w,j]=M.useState(""),[N,S]=M.useState("all"),[A,I]=M.useState(null),[L,F]=M.useState("asc"),$=Q=>{A===Q?F(se=>se==="asc"?"desc":"asc"):(I(Q),F("asc"))},q=({column:Q})=>A!==Q?e.jsx($c,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):L==="asc"?e.jsx(Rd,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Ku,{className:"h-3.5 w-3.5 ml-1 text-primary"}),H=Q=>s.find(se=>se.id===Q),U=M.useMemo(()=>{let Q=r.filter(se=>{var ce,oe;const te=!w||`${se.first_name} ${se.last_name}`.toLowerCase().includes(w.toLowerCase())||((ce=se.email)==null?void 0:ce.toLowerCase().includes(w.toLowerCase()))||((oe=se.current_brokerage)==null?void 0:oe.toLowerCase().includes(w.toLowerCase())),Y=N==="all"||se.stage_id===N;return te&&Y});return A&&(Q=[...Q].sort((se,te)=>{var le,de;let Y=null,ce=null;switch(A){case"name":Y=`${se.first_name} ${se.last_name||""}`.toLowerCase(),ce=`${te.first_name} ${te.last_name||""}`.toLowerCase();break;case"stage":Y=((le=H(se.stage_id))==null?void 0:le.sort_order)??999,ce=((de=H(te.stage_id))==null?void 0:de.sort_order)??999;break;case"brokerage":Y=(se.current_brokerage||"").toLowerCase(),ce=(te.current_brokerage||"").toLowerCase();break;case"experience":Y=se.experience_years??-1,ce=te.experience_years??-1;break;case"production":Y=(se.annual_production||"").toLowerCase(),ce=(te.annual_production||"").toLowerCase();break;case"source":Y=(se.source||"").toLowerCase(),ce=(te.source||"").toLowerCase();break;default:return 0}if(Y===ce)return 0;if(Y==null)return 1;if(ce==null)return-1;const oe=Yj(Q.target.value),className:"pl-8"})]}),e.jsxs(tr,{value:N,onValueChange:S,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"All stages"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All stages"}),s.map(Q=>e.jsx(At,{value:Q.id,children:Q.name},Q.id))]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Z,{variant:"outline",onClick:()=>b(!0),children:[e.jsx(xi,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(Z,{onClick:()=>d(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{children:[e.jsx(kt,{className:"cursor-pointer select-none",onClick:()=>$("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(q,{column:"name"})]})}),e.jsx(kt,{className:"cursor-pointer select-none",onClick:()=>$("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(q,{column:"stage"})]})}),e.jsx(kt,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>$("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(q,{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:()=>$("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(q,{column:"experience"})]})}),e.jsx(kt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(q,{column:"production"})]})}),e.jsx(kt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("source"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Source ",e.jsx(q,{column:"source"})]})}),e.jsx(kt,{className:"w-[50px]"})]})}),e.jsx(Ln,{children:U.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:8,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):U.map(Q=>{const se=H(Q.stage_id);return e.jsxs(ks,{className:"cursor-pointer",onClick:()=>{f(Q),v(!0)},children:[e.jsxs(lt,{className:"font-medium",children:[Q.first_name," ",Q.last_name]}),e.jsx(lt,{children:se?e.jsxs(nt,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:se.color,color:se.color,backgroundColor:`${se.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:se.color}}),se.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(lt,{className:"hidden md:table-cell",children:Q.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(_a,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:Q.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Q.email&&e.jsx(Ar,{className:"h-3.5 w-3.5 text-muted-foreground"}),Q.phone&&e.jsx(ga,{className:"h-3.5 w-3.5 text-muted-foreground"}),!Q.email&&!Q.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(lt,{className:"hidden lg:table-cell",children:Q.experience_years!=null?`${Q.experience_years} yr`:"—"}),e.jsx(lt,{className:"hidden lg:table-cell",children:Q.annual_production||"—"}),e.jsx(lt,{className:"hidden lg:table-cell",children:Q.source?e.jsx(nt,{variant:"secondary",className:"text-xs",children:Q.source}):"—"}),e.jsx(lt,{children:e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:te=>{te.stopPropagation(),l.mutate(Q.id)},children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})})]},Q.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[U.length," of ",r.length," prospects"]}),e.jsx(BXe,{open:i,onOpenChange:d,stages:s,onSubmit:Q=>a.mutate(Q),isSubmitting:a.isPending}),e.jsx(UXe,{prospect:u,stages:s,brokerageId:t,open:g,onOpenChange:v,onUpdate:Q=>{o.mutate(Q),f(se=>se?{...se,...Q}:null)},onDelete:Q=>l.mutate(Q)}),e.jsx(VXe,{open:_,onOpenChange:b,brokerageId:t,stages:s})]})}function Ahs({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=fce(t),a=M.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"),d=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?(d/o*100).toFixed(1):"0",f=new Date,g=o>0?Math.round(r.reduce((N,S)=>N+zg(f,new Date(S.created_at)),0)/o):0,v=s.map(N=>({...N,count:r.filter(S=>S.stage_id===N.id).length})),_={};r.forEach(N=>{const S=N.source||"unknown";_[S]=(_[S]||0)+1});const b=Object.entries(_).sort((N,S)=>S[1]-N[1]),w=new Date;w.setDate(w.getDate()-30);const j=r.filter(N=>new Date(N.created_at)>=w).length;return{total:o,signed:d,conversionRate:u,avgDays:g,byStage:v,bySrc:b,recentCount:j}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(xr,{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(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx(Vc,{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(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(Tn,{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(De,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:e.jsx(Mm,{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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Oe,{className:"space-y-3",children:a.byStage.map(o=>{const l=a.total>0?o.count/a.total*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{children:o.name})]}),e.jsx("span",{className:"font-medium",children:o.count})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${l}%`,backgroundColor:o.color}})})]},o.id)})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(nt,{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 c6e=[{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 Ehs({brokerageId:t}){const{toast:s}=La(),[r,n]=M.useState(null),[a,o]=M.useState(null),l=(d,u)=>{navigator.clipboard.writeText(d),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(c6e.map(d=>d.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(d=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(Ar,{className:"h-4 w-4"})," ",d]}),c6e.filter(u=>u.category===d).map(u=>e.jsxs(De,{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($t,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(nt,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Oe,{className:"pt-0 space-y-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subject Line:"}),e.jsx("p",{className:"text-sm mb-3",children:u.subject}),e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Body:"}),e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:u.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Z,{size:"sm",variant:"outline",onClick:f=>{f.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(ma,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Ni,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(Z,{size:"sm",onClick:f=>{f.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(ma,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Ni,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},d))]})}const d6e={call:ga,email:Ar,text:ho,meeting:nn,note:Un};function Phs({brokerageId:t}){const{data:s,isLoading:r}=Tt({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await K.from("recruit_prospects").select("id, created_by").eq("brokerage_id",t);if(a)throw a;const o=(n==null?void 0:n.map(_=>_.id))||[];if(o.length===0)return{recruiters:[],recentActivities:[]};const{data:l,error:i}=await K.from("recruit_activities").select("*").in("prospect_id",o).order("created_at",{ascending:!1});if(i)throw i;const d=[...new Set([...n.map(_=>_.created_by),...(l||[]).map(_=>_.created_by)])],{data:u}=await K.from("profiles").select("id, name, email").in("id",d),f=Object.fromEntries((u||[]).map(_=>[_.id,_])),g=Wse(new Date,30);return{recruiters:d.map(_=>{var S,A;const b=(l||[]).filter(I=>I.created_by===_),w=b.filter(I=>new Date(I.created_at)>=g),j={};w.forEach(I=>{j[I.activity_type]=(j[I.activity_type]||0)+1});const N=n.filter(I=>I.created_by===_).length;return{id:_,name:((S=f[_])==null?void 0:S.name)||"Unknown",email:((A=f[_])==null?void 0:A.email)||"",totalActivities:b.length,recentActivities:w.length,byType:j,prospectsCreated:N}}).sort((_,b)=>b.recentActivities-_.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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Oe,{className:"space-y-4",children:s.recruiters.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-sm",children:a+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mo,{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=d6e[o]||Un;return e.jsxs(nt,{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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Recent Activity"})}),e.jsx(Oe,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=d6e[n.activity_type]||Un;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:js(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 Ihs({brokerageId:t}){const{toast:s}=La(),r=ds(),[n,a]=M.useState(!1),[o,l]=M.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:d}=Tt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:j,error:N}=await K.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(N)throw N;return j}}),u=[...new Set(i.map(j=>j.referred_by))],{data:f=[]}=Tt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:j}=await K.from("profiles").select("id, name, email").in("id",u);return j||[]},enabled:u.length>0}),g=Object.fromEntries(f.map(j=>[j.id,j])),v=Bt({mutationFn:async j=>{const{data:{user:N}}=await K.auth.getUser();if(!N)throw new Error("Not authenticated");const{error:S}=await K.from("recruit_referrals").insert({brokerage_id:t,referred_by:N.id,referee_first_name:j.first_name,referee_last_name:j.last_name||null,referee_email:j.email||null,referee_phone:j.phone||null,referee_current_brokerage:j.current_brokerage||null,notes:j.notes||null});if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),_=Bt({mutationFn:async({id:j,status:N,incentive_status:S})=>{const A={updated_at:new Date().toISOString()};N&&(A.status=N),S&&(A.incentive_status=S);const{error:I}=await K.from("recruit_referrals").update(A).eq("id",j);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),b=j=>j==="approved"||j==="signed"?e.jsx(ma,{className:"h-3 w-3"}):j==="rejected"?e.jsx(bc,{className:"h-3 w-3"}):e.jsx(Tn,{className:"h-3 w-3"}),w=j=>j==="approved"||j==="signed"||j==="paid"?"bg-green-500/10 text-green-600 border-green-200":j==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return d?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(Z,{onClick:()=>a(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(pc,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(j=>{var N;return e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[j.referee_first_name," ",j.referee_last_name]}),e.jsxs(nt,{variant:"outline",className:w(j.status),children:[b(j.status)," ",j.status]}),j.incentive_status&&e.jsxs(nt,{variant:"outline",className:w(j.incentive_status),children:[e.jsx(uo,{className:"h-3 w-3 mr-1"})," ",j.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[j.referee_email&&e.jsx("p",{children:j.referee_email}),j.referee_phone&&e.jsx("p",{children:j.referee_phone}),j.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",j.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((N=g[j.referred_by])==null?void 0:N.name)||"Unknown"," • ",js(new Date(j.created_at),"MMM d, yyyy")]})]}),j.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:j.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(tr,{value:j.status,onValueChange:S=>_.mutate({id:j.id,status:S}),children:[e.jsx(Js,{className:"h-7 text-xs w-[110px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"pending",children:"Pending"}),e.jsx(At,{value:"contacted",children:"Contacted"}),e.jsx(At,{value:"approved",children:"Approved"}),e.jsx(At,{value:"signed",children:"Signed"}),e.jsx(At,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(tr,{value:j.incentive_status||"pending",onValueChange:S=>_.mutate({id:j.id,incentive_status:S}),children:[e.jsx(Js,{className:"h-7 text-xs w-[100px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"pending",children:"Unpaid"}),e.jsx(At,{value:"paid",children:"Paid"}),e.jsx(At,{value:"n/a",children:"N/A"})]})]})]})]})},j.id)})}),e.jsx(bs,{open:n,onOpenChange:a,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),v.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"First Name *"}),e.jsx(Re,{required:!0,value:o.first_name,onChange:j=>l(N=>({...N,first_name:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Last Name"}),e.jsx(Re,{value:o.last_name,onChange:j=>l(N=>({...N,last_name:j.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Email"}),e.jsx(Re,{type:"email",value:o.email,onChange:j=>l(N=>({...N,email:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Phone"}),e.jsx(Re,{value:o.phone,onChange:j=>l(N=>({...N,phone:j.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Current Brokerage"}),e.jsx(Re,{value:o.current_brokerage,onChange:j=>l(N=>({...N,current_brokerage:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Notes"}),e.jsx(Lr,{value:o.notes,onChange:j=>l(N=>({...N,notes:j.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:v.isPending,children:"Submit"})]})]})]})})]})}function Lhs({brokerageId:t}){const{toast:s}=La(),r=ds(),[n,a]=M.useState(!1),{data:o}=Tt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:v,error:_}=await K.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(_)throw _;return v}}),{data:l=[]}=Tt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:v,error:_}=await K.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(_)throw _;return v}}),i=Bt({mutationFn:async v=>{const{error:_}=await K.from("brokerages").update({recruit_form_enabled:v}).eq("id",t);if(_)throw _},onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-recruit-form",t]}),s({title:o!=null&&o.recruit_form_enabled?"Form disabled":"Form enabled"})}}),d=Bt({mutationFn:async({id:v,status:_})=>{const{error:b}=await K.from("recruit_interest_submissions").update({status:_}).eq("id",v);if(b)throw b},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-interest-submissions",t]})}),u=`${window.location.origin}/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,f=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},g=v=>v==="contacted"||v==="converted"?"bg-green-500/10 text-green-600":v==="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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Enable Public Form"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow agents to express interest in joining via a public link"})]}),e.jsx(qr,{checked:(o==null?void 0:o.recruit_form_enabled)||!1,onCheckedChange:v=>i.mutate(v)})]}),(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(Z,{size:"sm",variant:"outline",onClick:f,children:n?e.jsx(ma,{className:"h-3.5 w-3.5"}):e.jsx(Ni,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(un,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Oe,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(pc,{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(v=>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:[v.first_name," ",v.last_name]}),e.jsx(nt,{variant:"outline",className:g(v.status),children:v.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[v.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ar,{className:"h-3 w-3"}),v.email]}),v.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ga,{className:"h-3 w-3"}),v.phone]}),v.current_brokerage&&e.jsxs("span",{children:["From: ",v.current_brokerage]}),v.experience_years&&e.jsxs("span",{children:[v.experience_years,"yr exp"]})]}),v.why_interested&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 italic",children:['"',v.why_interested,'"']}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:js(new Date(v.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(tr,{value:v.status,onValueChange:_=>d.mutate({id:v.id,status:_}),children:[e.jsx(Js,{className:"h-7 text-xs w-[110px]",children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"new",children:"New"}),e.jsx(At,{value:"contacted",children:"Contacted"}),e.jsx(At,{value:"converted",children:"Converted"}),e.jsx(At,{value:"dismissed",children:"Dismissed"})]})]})]},v.id))})})]})]})}function Dhs({brokerageId:t}){const{toast:s}=La(),r=ds(),[n,a]=M.useState(!1),[o,l]=M.useState({prospect_id:"",title:"",description:"",due_date:js(hl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=M.useState("pending"),{data:u=[]}=Tt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:L,error:F}=await K.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(F)throw F;return L}}),{data:f=[],isLoading:g}=Tt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const L=u.map(q=>q.id);if(!L.length)return[];const{data:F,error:$}=await K.from("recruit_follow_ups").select("*").in("prospect_id",L).order("due_date");if($)throw $;return F},enabled:u.length>0}),v=Object.fromEntries(u.map(L=>[L.id,L])),_=Bt({mutationFn:async L=>{const{data:{user:F}}=await K.auth.getUser();if(!F)throw new Error("Not authenticated");const{error:$}=await K.from("recruit_follow_ups").insert({prospect_id:L.prospect_id,assigned_to:F.id,title:L.title,description:L.description||null,due_date:new Date(L.due_date).toISOString()});if($)throw $},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:js(hl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),b=Bt({mutationFn:async({id:L,completed:F})=>{const{error:$}=await K.from("recruit_follow_ups").update({completed_at:F?new Date().toISOString():null}).eq("id",L);if($)throw $},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),w=f.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),j=w.filter(L=>!L.completed_at&&Wx(new Date(L.due_date))&&!Ld(new Date(L.due_date))),N=w.filter(L=>!L.completed_at&&Ld(new Date(L.due_date))),S=w.filter(L=>!L.completed_at&&!Wx(new Date(L.due_date))&&!Ld(new Date(L.due_date))),A=w.filter(L=>!!L.completed_at),I=L=>{const F=v[L.prospect_id],$=!L.completed_at&&Wx(new Date(L.due_date))&&!Ld(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx($o,{checked:!!L.completed_at,onCheckedChange:q=>b.mutate({id:L.id,completed:q}),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:[F&&e.jsxs(nt,{variant:"secondary",className:"text-[10px]",children:[F.first_name," ",F.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${$?"text-destructive font-medium":""}`,children:[$?e.jsx(Yo,{className:"h-3 w-3"}):e.jsx(nn,{className:"h-3 w-3"}),js(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(nt,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},L.id)};return g?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(Z,{size:"sm",variant:i===L?"default":"outline",onClick:()=>d(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&j.length+N.length+S.length>0&&`(${j.length+N.length+S.length})`]},L))}),e.jsxs(Z,{size:"sm",onClick:()=>a(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(Yo,{className:"h-3.5 w-3.5"})," Overdue (",j.length,")"]}),j.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(Tn,{className:"h-3.5 w-3.5"})," Today (",N.length,")"]}),N.map(I)]}),i!=="completed"&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(nn,{className:"h-3.5 w-3.5"})," Upcoming (",S.length,")"]}),S.map(I)]}),i!=="pending"&&A.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(ma,{className:"h-3.5 w-3.5"})," Completed (",A.length,")"]}),A.map(I)]}),w.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(bs,{open:n,onOpenChange:a,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:L=>{L.preventDefault(),_.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(_e,{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(F=>({...F,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(_e,{children:"Task *"}),e.jsx(Re,{required:!0,value:o.title,onChange:L=>l(F=>({...F,title:L.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Details"}),e.jsx(Lr,{value:o.description,onChange:L=>l(F=>({...F,description:L.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Due Date *"}),e.jsx(Re,{type:"datetime-local",required:!0,value:o.due_date,onChange:L=>l(F=>({...F,due_date:L.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:_.isPending,children:"Schedule"})]})]})]})})]})}const Ohs=[{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 Rhs({brokerageId:t}){const{toast:s}=La(),r=ds(),[n,a]=M.useState(null),{data:o,isLoading:l}=Tt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:j,error:N}=await K.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(N)throw N;return j}}),[i,d]=M.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:Ohs,testimonials:[],gallery_images:[]});M.useEffect(()=>{o&&d({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=Bt({mutationFn:async()=>{const j={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),updated_at:new Date().toISOString()};if(i.id){const{error:N}=await K.from("recruit_landing_page_settings").update(j).eq("id",i.id);if(N)throw N}else{const{error:N}=await K.from("recruit_landing_page_settings").insert(j);if(N)throw N}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),f=async(j,N)=>{const S=j.name.split(".").pop(),A=`${t}/${N}-${Date.now()}.${S}`,{error:I}=await K.storage.from("recruit-landing").upload(A,j);if(I)throw I;const{data:{publicUrl:L}}=K.storage.from("recruit-landing").getPublicUrl(A);return L},g=async(j,N)=>{var A;const S=(A=j.target.files)==null?void 0:A[0];if(S){a(N);try{const I=await f(S,N);d(L=>({...L,[N]:I})),s({title:"Image uploaded!"})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},v=async j=>{var S;const N=(S=j.target.files)==null?void 0:S[0];if(N){a("gallery");try{const A=await f(N,"gallery");d(I=>({...I,gallery_images:[...I.gallery_images,A]})),s({title:"Gallery image added!"})}catch(A){s({title:"Upload failed",description:A.message,variant:"destructive"})}finally{a(null)}}},_=async(j,N)=>{var A;const S=(A=j.target.files)==null?void 0:A[0];if(S){a(`testimonial-${N}`);try{const I=await f(S,`testimonial-${N}`);d(L=>{const F=[...L.testimonials];return F[N]={...F[N],photo_url:I},{...L,testimonials:F}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:b}=Tt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:j,error:N}=await K.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(N)throw N;return j}}),w=`${window.location.origin}/join-brokerage/${(b==null?void 0:b.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:[(b==null?void 0:b.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Live page:"}),e.jsx("code",{className:"text-xs flex-1 truncate",children:w}),e.jsx(Z,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(un,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Branding"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{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(Z,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(xi,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>g(j,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:j=>d(N=>({...N,primary_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:i.primary_color,onChange:j=>d(N=>({...N,primary_color:j.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:j=>d(N=>({...N,accent_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:i.accent_color,onChange:j=>d(N=>({...N,accent_color:j.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Headline"}),e.jsx(Re,{value:i.hero_headline,onChange:j=>d(N=>({...N,hero_headline:j.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Subtext"}),e.jsx(Lr,{value:i.hero_subtext,onChange:j=>d(N=>({...N,hero_subtext:j.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(_e,{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(Z,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(xi,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>g(j,"hero_image_url")})]}),i.hero_image_url&&e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>d(j=>({...j,hero_image_url:null})),children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsx(Vt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>d(j=>({...j,benefits:[...j.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(Ys,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.benefits.map((j,N)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Rh,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(Re,{value:j.icon,onChange:S=>{const A=[...i.benefits];A[N]={...j,icon:S.target.value},d(I=>({...I,benefits:A}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Re,{value:j.title,onChange:S=>{const A=[...i.benefits];A[N]={...j,title:S.target.value},d(I=>({...I,benefits:A}))},placeholder:"Benefit title"}),e.jsx(Re,{value:j.description,onChange:S=>{const A=[...i.benefits];A[N]={...j,description:S.target.value},d(I=>({...I,benefits:A}))},placeholder:"Short description"})]}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>d(S=>({...S,benefits:S.benefits.filter((A,I)=>I!==N)})),children:e.jsx(Cr,{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(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsx(Vt,{className:"text-base",children:"Testimonials"}),e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>d(j=>({...j,testimonials:[...j.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(Ys,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.testimonials.map((j,N)=>{var S;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[j.photo_url?e.jsx("img",{src:j.photo_url,alt:j.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((S=j.name)==null?void 0:S[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${N}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:A=>_(A,N)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Re,{value:j.name,onChange:A=>{const I=[...i.testimonials];I[N]={...j,name:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(Re,{value:j.role,onChange:A=>{const I=[...i.testimonials];I[N]={...j,role:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(Lr,{value:j.quote,onChange:A=>{const I=[...i.testimonials];I[N]={...j,quote:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>d(A=>({...A,testimonials:A.testimonials.filter((I,L)=>L!==N)})),children:e.jsx(Cr,{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(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsx(Vt,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Z,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(Xo,{className:"h-3.5 w-3.5 mr-1"}),n==="gallery"?"Uploading...":"Add Photo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:v})]})]}),e.jsx(Oe,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((j,N)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:j,alt:`Gallery ${N+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(Z,{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:()=>d(S=>({...S,gallery_images:S.gallery_images.filter((A,I)=>I!==N)})),children:e.jsx(Cr,{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(Z,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(zh,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function Fhs(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function zhs({video:t}){return t.cta_clicked_at?e.jsx(nt,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(nt,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(Na,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(nt,{variant:"secondary",children:[e.jsx(Pa,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(nt,{variant:"outline",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Draft"]})}function Bhs({brokerageId:t}){const{data:s=[],isLoading:r}=whs(t),{data:n=[]}=qXe(t),a=Nhs(),o=Shs(),l=$Xe(),[i,d]=M.useState(""),[u,f]=M.useState(!1),[g,v]=M.useState({title:"",script_text:"",category:"general"}),_=s.filter(S=>{var I,L,F,$;return i?`${((I=S.prospect)==null?void 0:I.first_name)||""} ${((L=S.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||(($=(F=S.video)==null?void 0:F.title)==null?void 0:$.toLowerCase().includes(i.toLowerCase())):!0}),b={total:s.length,sent:s.filter(S=>S.sent_at).length,viewed:s.filter(S=>S.view_count>0).length,ctaClicked:s.filter(S=>S.cta_clicked_at).length},w=M.useCallback(S=>{if(!S)return;const A=`${window.location.origin}/recruit-video/${S}`;navigator.clipboard.writeText(A),ge.success("Share link copied")},[]),j=M.useCallback((S,A)=>{l.mutate({id:S,sent_via:A})},[l]),N=()=>{!g.title.trim()||!g.script_text.trim()||a.mutate({brokerage_id:t,...g},{onSuccess:()=>{v({title:"",script_text:"",category:"general"}),f(!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:b.total,icon:Cn,color:"text-primary"},{label:"Sent",value:b.sent,icon:Pa,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:Na,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:Ma,color:"text-emerald-500"}].map(S=>e.jsx(De,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${S.color}`,children:e.jsx(S.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})]})},S.label))}),e.jsxs(Ia,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsxs(Ts,{value:"videos",children:[e.jsx(Cn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(Ts,{value:"scripts",children:[e.jsx(Un,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(Ts,{value:"analytics",children:[e.jsx(ol,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(Vs,{value:"videos",children:e.jsxs(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Vt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or title...",value:i,onChange:S=>d(S.target.value),className:"pl-9"})]})]})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.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:_.map(S=>{var A,I,L,F,$,q;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:[(A=S.video)!=null&&A.thumbnail_url?e.jsx("img",{src:S.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Cn,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1 rounded",children:Fhs(((I=S.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=S.prospect)==null?void 0:L.first_name," ",(F=S.prospect)==null?void 0:F.last_name]}),e.jsx(zhs,{video:S})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:(($=S.video)==null?void 0:$.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[js(new Date(S.created_at),"MMM d, yyyy"),((q=S.prospect)==null?void 0:q.current_brokerage)&&` · ${S.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(S.share_token),title:"Copy share link",children:e.jsx(Ni,{className:"h-4 w-4"})}),!S.sent_at&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(S.id,"email"),title:"Mark as sent",children:e.jsx(Pa,{className:"h-4 w-4"})}),S.share_token&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${S.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(un,{className:"h-4 w-4"})})]})]},S.id)})})})]})}),e.jsx(Vs,{value:"scripts",children:e.jsxs(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Vt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(bs,{open:u,onOpenChange:f,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{size:"sm",children:[e.jsx(Ys,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Re,{value:g.title,onChange:S=>v(A=>({...A,title:S.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Category"}),e.jsxs(tr,{value:g.category,onValueChange:S=>v(A=>({...A,category:S})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:d0e.map(S=>e.jsx(At,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Script"}),e.jsx(Lr,{value:g.script_text,onChange:S=>v(A=>({...A,script_text:S.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(Z,{onClick:N,disabled:!g.title.trim()||!g.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Oe,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Un,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(S=>{var I;const A=((I=d0e.find(L=>L.value===S.category))==null?void 0:I.label)||S.category;return e.jsx(De,{className:"relative group",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{variant:"outline",className:"text-[10px] mb-2",children:A}),e.jsx("h4",{className:"font-medium text-sm",children:S.title})]}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(S.id),children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:S.script_text}),S.is_global&&e.jsx(nt,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},S.id)})})})]})}),e.jsx(Vs,{value:"analytics",children:e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:b.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:b.sent,pct:b.total?Math.round(b.sent/b.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:b.viewed,pct:b.sent?Math.round(b.viewed/b.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:b.ctaClicked,pct:b.viewed?Math.round(b.ctaClicked/b.viewed*100):0,color:"bg-emerald-500"}].map(S=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:S.label}),e.jsxs("span",{className:"font-medium",children:[S.count," (",S.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${S.color} rounded-full transition-all`,style:{width:`${S.pct}%`}})})]},S.label))}),s.filter(S=>S.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(S=>S.view_count>0).sort((S,A)=>A.view_count-S.view_count).slice(0,5).map(S=>{var A,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:[(A=S.prospect)==null?void 0:A.first_name," ",(I=S.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(Na,{className:"h-3.5 w-3.5"})," ",S.view_count]}),S.cta_clicked_at&&e.jsx(Ma,{className:"h-4 w-4 text-emerald-500"})]})]},S.id)})})]})]})]})})]})]})}function $hs({brokerageId:t}){const{toast:s}=La(),r=ds(),{stages:n,prospects:a}=fce(t),[o,l]=M.useState(!1),[i,d]=M.useState({title:"",target_count:"10",target_stage_id:"",period_start:js(new Date,"yyyy-MM-dd"),period_end:js(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:f}=Tt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:b,error:w}=await K.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(w)throw w;return b}}),g=Bt({mutationFn:async b=>{const{data:{user:w}}=await K.auth.getUser();if(!w)throw new Error("Not authenticated");const{error:j}=await K.from("recruit_goals").insert({brokerage_id:t,title:b.title,target_count:parseInt(b.target_count),target_stage_id:b.target_stage_id||null,period_start:b.period_start,period_end:b.period_end,created_by:w.id});if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:b=>s({title:"Error",description:b.message,variant:"destructive"})}),v=Bt({mutationFn:async b=>{const{error:w}=await K.from("recruit_goals").delete().eq("id",b);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),_=b=>{const w=n.find(N=>N.id===b.target_stage_id);return{count:a.filter(N=>tne(new Date(N.created_at),{start:new Date(b.period_start),end:new Date(b.period_end)})?b.target_stage_id?N.stage_id===b.target_stage_id:!0:!1).length,stage:w}};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.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," goal",u.length!==1?"s":""]}),e.jsxs(Z,{size:"sm",onClick:()=>l(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(Mm,{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(b=>{const{count:w,stage:j}=_(b),N=Math.min(100,w/b.target_count*100),S=tne(new Date,{start:new Date(b.period_start),end:new Date(b.period_end)});return e.jsxs(De,{className:S?"":"opacity-60",children:[e.jsx($t,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[js(new Date(b.period_start),"MMM d")," – ",js(new Date(b.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[S?e.jsx(nt,{className:"text-[10px]",children:"Active"}):e.jsx(nt,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>v.mutate(b.id),children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[j&&e.jsxs(nt,{variant:"outline",className:"text-[10px]",style:{borderColor:j.color,color:j.color},children:["Stage: ",j.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:w}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",b.target_count]})]}),e.jsx(wo,{value:N,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[N.toFixed(0),"% complete"]})]})]},b.id)})}),e.jsx(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault(),g.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Goal Title *"}),e.jsx(Re,{required:!0,value:i.title,onChange:b=>d(w=>({...w,title:b.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Target Count *"}),e.jsx(Re,{type:"number",min:"1",required:!0,value:i.target_count,onChange:b=>d(w=>({...w,target_count:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{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:b=>d(w=>({...w,target_stage_id:b.target.value})),children:[e.jsx("option",{value:"",children:"All stages (total prospects)"}),n.map(b=>e.jsx("option",{value:b.id,children:b.name},b.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(_e,{children:"Start Date"}),e.jsx(Re,{type:"date",required:!0,value:i.period_start,onChange:b=>d(w=>({...w,period_start:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"End Date"}),e.jsx(Re,{type:"date",required:!0,value:i.period_end,onChange:b=>d(w=>({...w,period_end:b.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Z,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Z,{type:"submit",disabled:g.isPending,children:"Create Goal"})]})]})]})})]})}function qhs(){var i;const[t,s]=M.useState(""),[r,n]=M.useState("board"),{data:a=[],isLoading:o}=Tt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:d,error:u}=await K.from("brokerages").select("id, name").order("name");if(u)throw u;return d}}),l=t||((i=a[0])==null?void 0:i.id)||"";return o?e.jsx(Ms,{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(Ms,{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(tr,{value:l,onValueChange:s,children:[e.jsxs(Js,{className:"w-[280px]",children:[e.jsx(_a,{className:"mr-2 h-4 w-4"}),e.jsx(rr,{placeholder:"Select brokerage"})]}),e.jsx(er,{children:a.map(d=>e.jsx(At,{value:d.id,children:d.name},d.id))})]})]}),l?e.jsxs(Ia,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(Aa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(Ts,{value:"pipeline",children:"Pipeline"}),e.jsxs(Ts,{value:"video-outreach",children:[e.jsx(Cn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(Ts,{value:"follow-ups",children:"Follow-ups"}),e.jsx(Ts,{value:"referrals",children:"Referrals"}),e.jsx(Ts,{value:"interest",children:"Interest Form"}),e.jsx(Ts,{value:"landing-page",children:"Landing Page"}),e.jsx(Ts,{value:"goals",children:"Goals"}),e.jsx(Ts,{value:"metrics",children:"Metrics"}),e.jsx(Ts,{value:"templates",children:"Email Templates"}),e.jsx(Ts,{value:"activity",children:"Recruiter Activity"})]}),e.jsxs(Vs,{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(Z,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(hp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(Z,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(gP,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(Mhs,{brokerageId:l}):e.jsx(Ths,{brokerageId:l})]}),e.jsx(Vs,{value:"video-outreach",children:e.jsx(Bhs,{brokerageId:l})}),e.jsx(Vs,{value:"follow-ups",children:e.jsx(Dhs,{brokerageId:l})}),e.jsx(Vs,{value:"referrals",children:e.jsx(Ihs,{brokerageId:l})}),e.jsx(Vs,{value:"interest",children:e.jsx(Lhs,{brokerageId:l})}),e.jsx(Vs,{value:"landing-page",children:e.jsx(Rhs,{brokerageId:l})}),e.jsx(Vs,{value:"goals",children:e.jsx($hs,{brokerageId:l})}),e.jsx(Vs,{value:"metrics",children:e.jsx(Ahs,{brokerageId:l})}),e.jsx(Vs,{value:"templates",children:e.jsx(Ehs,{brokerageId:l})}),e.jsx(Vs,{value:"activity",children:e.jsx(Phs,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(_a,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function Uhs(){const[t,s]=M.useState(""),{data:r,isLoading:n}=Tt({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await K.from("brokerages").select("id, name");if(!i)return[];const{data:d}=await K.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await K.from("brokerage_content_categories").select("id, brokerage_id"),f=d||[],g=u||[],v=i.map(_=>{const b=f.filter(N=>N.brokerage_id===_.id),w=g.filter(N=>N.brokerage_id===_.id),j=b.length>0?b.reduce((N,S)=>S.created_at>N?S.created_at:N,b[0].created_at):null;return{brokerage_id:_.id,brokerage_name:_.name,total_items:b.length,videos:b.filter(N=>N.content_type==="video").length,pdfs:b.filter(N=>N.content_type==="pdf").length,links:b.filter(N=>N.content_type==="link"||N.content_type==="canva_link").length,events:b.filter(N=>N.content_type==="event").length,graphics:b.filter(N=>N.content_type==="graphic").length,latest_item_date:j,categories:w.length}});return v.sort((_,b)=>b.total_items-_.total_items),v}}),a=(r||[]).filter(i=>i.brokerage_name.toLowerCase().includes(t.toLowerCase())),o=a.reduce((i,d)=>i+d.total_items,0),l=a.filter(i=>i.total_items>0).length;return e.jsx(Ms,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(pu,{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(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with content uploaded"})]})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all brokerages"})]})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-2",children:e.jsx(Vt,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"registered"})]})]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(De,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Pn,{children:[e.jsx(In,{children:e.jsxs(ks,{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(Un,{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(Al,{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(jc,{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(Xo,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(kt,{className:"text-center",children:"Categories"}),e.jsx(kt,{children:"Last Upload"})]})}),e.jsx(Ln,{children:n?e.jsx(ks,{children:e.jsx(lt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(ks,{children:e.jsx(lt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(ks,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_a,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(lt,{className:"text-center",children:i.total_items>0?e.jsx(nt,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(lt,{className:"text-center",children:i.videos||"–"}),e.jsx(lt,{className:"text-center",children:i.pdfs||"–"}),e.jsx(lt,{className:"text-center",children:i.links||"–"}),e.jsx(lt,{className:"text-center",children:i.events||"–"}),e.jsx(lt,{className:"text-center",children:i.graphics||"–"}),e.jsx(lt,{className:"text-center",children:i.categories||"–"}),e.jsx(lt,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:js(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function Vhs(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 Hhs=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function d_(t){const s=[];for(let r=0,n=t.length;rKm||t.height>Km)&&(t.width>Km&&t.height>Km?t.width>t.height?(t.height*=Km/t.width,t.width=Km):(t.width*=Km/t.height,t.height=Km):t.width>Km?(t.height*=Km/t.width,t.width=Km):(t.width*=Km/t.height,t.height=Km))}function mie(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 Yhs(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function Xhs(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),Yhs(a)}const Em=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||Em(r,s)};function Qhs(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function Jhs(t,s){return HXe(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function ems(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?Qhs(r):Jhs(r,n);return document.createTextNode(`${a}{${o}}`)}function u6e(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=Hhs();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(ems(l,r,a,n)),s.appendChild(i)}function tms(t,s,r){u6e(t,s,":before",r),u6e(t,s,":after",r)}const h6e="application/font-woff",m6e="image/jpeg",sms={woff:h6e,woff2:h6e,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:m6e,jpeg:m6e,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function rms(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function Qwe(t){const s=rms(t).toLowerCase();return sms[s]||""}function nms(t){return t.split(/,/)[1]}function u0e(t){return t.search(/^(data:)/)!==-1}function ams(t,s){return`data:${s};base64,${t}`}async function GXe(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(d){l(d)}},i.readAsDataURL(a)})}const rpe={};function ims(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 Jwe(t,s,r){const n=ims(t,s,r.includeQueryParams);if(rpe[n]!=null)return rpe[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await GXe(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),nms(i)));a=ams(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 rpe[n]=a,a}async function oms(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):mie(s)}async function lms(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 mie(i)}const r=t.poster,n=Qwe(r),a=await Jwe(r,n,s);return mie(a)}async function cms(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await gce(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function dms(t,s){return Em(t,HTMLCanvasElement)?oms(t):Em(t,HTMLVideoElement)?lms(t,s):Em(t,HTMLIFrameElement)?cms(t,s):t.cloneNode(KXe(t))}const ums=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",KXe=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function hms(t,s,r){var n,a;if(KXe(s))return s;let o=[];return ums(t)&&t.assignedNodes?o=d_(t.assignedNodes()):Em(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=d_(t.contentDocument.body.childNodes):o=d_(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Em(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>gce(i,r)).then(d=>{d&&s.appendChild(d)}),Promise.resolve()),s}function mms(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):HXe(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`),Em(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 pms(t,s){Em(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Em(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function fms(t,s){if(Em(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function gms(t,s,r){return Em(s,Element)&&(mms(t,s,r),tms(t,s,r),pms(t,s),fms(t,s)),s}async function xms(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;odms(n,s)).then(n=>hms(t,n,s)).then(n=>gms(t,n,s)).then(n=>xms(n,s))}const ZXe=/url\((['"]?)([^'"]+?)\1\)/g,yms=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,vms=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function _ms(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function bms(t){const s=[];return t.replace(ZXe,(r,n,a)=>(s.push(a),r)),s.filter(r=>!u0e(r))}async function wms(t,s,r,n,a){try{const o=r?Vhs(s,r):s,l=Qwe(s);let i;return a||(i=await Jwe(o,l,n)),t.replace(_ms(s),`$1${i}$3`)}catch{}return t}function jms(t,{preferredFontFormat:s}){return s?t.replace(vms,r=>{for(;;){const[n,,a]=yms.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function YXe(t){return t.search(ZXe)!==-1}async function XXe(t,s,r){if(!YXe(t))return t;const n=jms(t,r);return bms(n).reduce((o,l)=>o.then(i=>wms(i,l,s,r)),Promise.resolve(n))}async function a4(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await XXe(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function kms(t,s){await a4("background",t,s)||await a4("background-image",t,s),await a4("mask",t,s)||await a4("-webkit-mask",t,s)||await a4("mask-image",t,s)||await a4("-webkit-mask-image",t,s)}async function Nms(t,s){const r=Em(t,HTMLImageElement);if(!(r&&!u0e(t.src))&&!(Em(t,SVGImageElement)&&!u0e(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await Jwe(n,Qwe(n),s);await new Promise((o,l)=>{t.onload=o,t.onerror=s.onImageErrorHandler?(...d)=>{try{o(s.onImageErrorHandler(...d))}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 Sms(t,s){const n=d_(t.childNodes).map(a=>QXe(a,s));await Promise.all(n).then(()=>t)}async function QXe(t,s){Em(t,Element)&&(await kms(t,s),await Nms(t,s),await Sms(t,s))}function Cms(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 p6e={};async function f6e(t){let s=p6e[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},p6e[t]=s,s}async function g6e(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),GXe(i,s.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(o).then(()=>r)}function x6e(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 d=a.exec(n);if(d===null)break;s.push(d[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 d=o.exec(n);if(d===null){if(d=i.exec(n),d===null)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;s.push(d[0])}return s}async function Mms(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{d_(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const d=o.href,u=f6e(d).then(f=>g6e(f,s)).then(f=>x6e(f).forEach(g=>{try{a.insertRule(g,g.startsWith("@import")?i+=1:a.cssRules.length)}catch(v){console.error("Error inserting rule from remote css",{rule:g,error:v})}})).catch(f=>{console.error("Error loading remote css",f.toString())});n.push(u)}})}catch(o){const l=t.find(i=>i.href==null)||document.styleSheets[0];a.href!=null&&n.push(f6e(a.href).then(i=>g6e(i,s)).then(i=>x6e(i).forEach(d=>{l.insertRule(d,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{d_(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function Tms(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>YXe(s.style.getPropertyValue("src")))}async function Ams(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=d_(t.ownerDocument.styleSheets),n=await Mms(r,s);return Tms(n)}function JXe(t){return t.trim().replace(/["']/g,"")}function Ems(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(JXe(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function Pms(t,s){const r=await Ams(t,s),n=Ems(t);return(await Promise.all(r.filter(o=>n.has(JXe(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return XXe(o.cssText,l,s)}))).join(` `)}async function Ims(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await Pms(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 Lms(t,s={}){const{width:r,height:n}=WXe(t,s),a=await gce(t,s,!0);return await Ims(a,s),await QXe(a,s),Cms(a,s),await Xhs(a,r,n)}async function Dms(t,s={}){const{width:r,height:n}=WXe(t,s),a=await Lms(t,s),o=await mie(a),l=document.createElement("canvas"),i=l.getContext("2d"),d=s.pixelRatio||Khs(),u=s.canvasWidth||r,f=s.canvasHeight||n;return l.width=u*d,l.height=f*d,s.skipAutoScale||Zhs(l),l.style.width=`${u}`,l.style.height=`${f}`,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 Oms(t,s={}){return(await Dms(t,s)).toDataURL()}const U3=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),xce={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},dR={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},Rms=({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})]})]}),eQe=ut.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,d=(g=t.photos)==null?void 0:g[a],u=xce[s],f=[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:[d&&e.jsx("img",{src:d,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:U3(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",U3(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:f})}),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(Rms,{branding:n,dim:l})]})]})]})});eQe.displayName="LuxuryDarkTemplate";const Fms=({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})]})]}),tQe=ut.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var _;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(_=t.photos)==null?void 0:_[a],u=xce[s],f=r==="instagram-story",g=r==="facebook-post",v=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:g?"row":"column"},children:[e.jsxs("div",{style:{width:g?"55%":"100%",height:g?"100%":f?"50%":"52%",position:"relative",overflow:"hidden",flexShrink:0},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",top:l.w*.04,left:0,background:v,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*(g?.055:.065),fontWeight:800,lineHeight:1.1,color:v,marginBottom:l.w*.012},children:U3(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:`${v}10`,border:`2px solid ${v}`,borderRadius:l.w*.01,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,color:v,display:"inline-block",marginBottom:l.w*.015},children:"SAT & SUN • 1–4 PM"}),e.jsx(Fms,{branding:n,dim:l,accentColor:v})]})]})});tQe.displayName="ModernCleanTemplate";const zms=({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})]})]}),sQe=ut.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var v;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(v=t.photos)==null?void 0:v[a],u=xce[s],f={"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)"},g=[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:[d&&e.jsx("img",{src:d,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:f[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:U3(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:g}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.015,background:f["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(zms,{branding:n,dim:l})]})]})]})});sQe.displayName="BoldColorfulTemplate";const Bms=({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})]})]}),rQe=ut.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,d=(g=t.photos)==null?void 0:g[a],u=xce[s],f=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:f?"column":"row",height:"100%"},children:[e.jsxs("div",{style:{width:f?"100%":"42%",height:f?"40%":"100%",display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05,order:f?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*(f?.06:.055),fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,fontStyle:"italic"},children:U3(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",U3(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(Bms,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:f?"100%":"58%",height:f?"60%":"100%",position:"relative",overflow:"hidden",order:f?1:2},children:[d&&e.jsx("img",{src:d,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"}})]})]})})});rQe.displayName="EditorialTemplate";const $ms=[{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:"📉"}],y6e=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(zd,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(zd,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(Fd,{className:"h-4 w-4"})}],qms=[{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:"📰"}],v6e=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),_6e={"luxury-dark":eQe,"modern-clean":tQe,"bold-colorful":sQe,editorial:rQe};function Ums(){const[t,s]=M.useState(""),[r,n]=M.useState("address"),[a,o]=M.useState(!1),[l,i]=M.useState([]),[d,u]=M.useState(null),[f,g]=M.useState(0),[v,_]=M.useState("just-listed"),[b,w]=M.useState(["instagram-square"]),[j,N]=M.useState("luxury-dark"),[S,A]=M.useState(!1),[I,L]=M.useState(""),[F,$]=M.useState(""),[q,H]=M.useState(""),[U,Q]=M.useState(!1),[se,te]=M.useState(!1),[Y,ce]=M.useState([]),[oe,le]=M.useState("search"),de=M.useRef({});M.useEffect(()=>{(async()=>{const{data:{user:Fe}}=await K.auth.getUser();if(!Fe)return;const{data:Ie}=await K.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Fe.id).single();if(Ie){L(Ie.name||""),H(Ie.avatar_url||"");const Ve=Ie.brokerages;$((Ve==null?void 0:Ve.name)||"")}})()},[]);const xe=async()=>{var Pe;if(t.trim()){o(!0),i([]);try{const{data:Fe,error:Ie}=await K.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(Ie)throw Ie;if(Fe.error)throw new Error(Fe.error);i(Fe.listings||[]),((Pe=Fe.listings)==null?void 0:Pe.length)===0&&ge.info("No listings found. Try a different search.")}catch(Fe){ge.error(Fe.message||"Search failed")}finally{o(!1)}}},be=Pe=>{var Fe;u(Pe),g(0),le("customize"),Pe.soldDate||(Fe=Pe.status)!=null&&Fe.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},ye=Pe=>{w(Fe=>Fe.includes(Pe)?Fe.filter(Ie=>Ie!==Pe):[...Fe,Pe])},ve=M.useCallback(async()=>{if(!(!d||b.length===0)){Q(!0),ce([]),le("generate");try{await new Promise(Fe=>setTimeout(Fe,500));const Pe=[];for(const Fe of b){const Ie=`${j}-${Fe}`,Ve=de.current[Ie];if(!Ve)continue;const dt=dR[Fe],Le=await Oms(Ve,{width:dt.width,height:dt.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Pe.push({format:Fe,imageUrl:Le})}ce(Pe),ge.success(`Generated ${Pe.length} social post${Pe.length>1?"s":""}!`)}catch(Pe){ge.error(Pe.message||"Generation failed")}finally{Q(!1)}}},[d,b,j,f,S,I,F,q,v]),ke=async()=>{if(!(!d||b.length===0)){Q(!0),ce([]),le("generate");try{const Pe={...d,photos:d.photos.length>0?[d.photos[f]]:[]},Fe=[];for(const Ie of b){const{data:Ve,error:dt}=await K.functions.invoke("generate-listing-social-post",{body:{listing:Pe,postType:v,format:Ie,branding:S?{enabled:!0,agentName:I,brokerage:F}:{enabled:!1}}});if(dt)throw dt;if(Ve.error)throw new Error(Ve.error);Fe.push({format:Ie,imageUrl:Ve.imageUrl})}ce(Fe),ge.success(`Generated ${Fe.length} AI post${Fe.length>1?"s":""}!`)}catch(Pe){ge.error(Pe.message||"AI generation failed")}finally{Q(!1)}}},Ge=()=>se?ke():ve(),Ne=(Pe,Fe)=>{var Ve;const Ie=document.createElement("a");Ie.href=Pe,Ie.download=`${((Ve=d==null?void 0:d.address)==null?void 0:Ve.replace(/\s+/g,"-"))||"listing"}-${v}-${Fe}.png`,document.body.appendChild(Ie),Ie.click(),document.body.removeChild(Ie)},Ae=d?{listing:d,postType:v,format:"instagram-square",branding:S?{enabled:!0,agentName:I,brokerage:F,agentPhotoUrl:q||void 0}:{enabled:!1},selectedPhotoIndex:f}:null;return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(pu,{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:()=>le("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${oe==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(xn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(ei,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>d&&le("customize"),disabled:!d,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${oe==="customize"?"bg-primary text-primary-foreground":d?"bg-muted text-muted-foreground hover:text-foreground":"bg-muted text-muted-foreground/50 cursor-not-allowed"}`,children:[e.jsx(gn,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(ei,{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 ${oe==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(Xo,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),oe==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(oqe,{})]}),e.jsx(_r,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Ia,{value:r,onValueChange:Pe=>n(Pe),children:e.jsxs(Aa,{children:[e.jsxs(Ts,{value:"address",children:[e.jsx(Pi,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(Ts,{value:"mls",children:[e.jsx(pp,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:t,onChange:Pe=>s(Pe.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Pe=>Pe.key==="Enter"&&xe()}),e.jsxs(Z,{onClick:xe,disabled:a||!t.trim(),children:[a?e.jsx(Rs,{className:"h-4 w-4 animate-spin"}):e.jsx(xn,{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((Pe,Fe)=>{var Ie;return e.jsx(De,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>be(Pe),children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-32 h-28 flex-shrink-0 bg-muted rounded-l-lg overflow-hidden",children:(Ie=Pe.photos)!=null&&Ie[0]?e.jsx("img",{src:Pe.photos[0],alt:Pe.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(Hn,{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:v6e(Pe.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Pe.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Pe.city,", ",Pe.state," ",Pe.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Pe.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(RE,{className:"h-3 w-3"})," ",Pe.bedrooms]}),Pe.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(f0,{className:"h-3 w-3"})," ",Pe.bathrooms]}),Pe.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(QE,{className:"h-3 w-3"})," ",Pe.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"outline",className:"text-[10px]",children:Pe.mlsNumber}),e.jsx(nt,{variant:"outline",className:"text-[10px]",children:Pe.status})]})]})]})})},Pe.mlsNumber||Fe)})})]})]}),oe==="customize"&&d&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(De,{className:"lg:col-span-1",children:[e.jsx($t,{className:"pb-3",children:e.jsx(Vt,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Oe,{className:"space-y-3",children:[d.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:d.photos[f],alt:"Listing photo",className:"w-full h-full object-cover"})}),d.photos.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx(Z,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>g(Pe=>Math.max(0,Pe-1)),disabled:f===0,children:e.jsx(ec,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[f+1," of ",d.photos.length]}),e.jsx(Z,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>g(Pe=>Math.min(d.photos.length-1,Pe+1)),disabled:f===d.photos.length-1,children:e.jsx(ei,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:v6e(d.price)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.city,", ",d.state," ",d.zip]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[d.bedrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bedrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Beds"})]}),d.bathrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bathrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Baths"})]}),d.sqft>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.sqft.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sq Ft"})]})]}),e.jsxs(Z,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{le("search"),u(null)},children:[e.jsx(k0,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(De,{className:"lg:col-span-2",children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(gn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(_r,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(El,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:se?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:se?"Uses AI credits for unique designs":"Instant, no credits used"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Use AI"}),e.jsx(qr,{checked:se,onCheckedChange:te}),se&&e.jsx(t0,{className:"h-4 w-4 text-purple-500"})]})]}),!se&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(El,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:qms.map(Pe=>e.jsxs("button",{onClick:()=>N(Pe.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${j===Pe.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Pe.preview}),e.jsx("span",{className:"text-sm font-medium",children:Pe.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Pe.description})]},Pe.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:$ms.map(Pe=>e.jsxs("button",{onClick:()=>_(Pe.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${v===Pe.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Pe.icon})," ",Pe.label]},Pe.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:y6e.map(Pe=>e.jsxs("button",{onClick:()=>ye(Pe.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${b.includes(Pe.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Pe.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Pe.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Pe.dimensions})]})]},Pe.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(mo,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(qr,{checked:S,onCheckedChange:A})]}),S&&e.jsxs("div",{className:"space-y-3 pl-6 border-l-2 border-primary/20",children:[q&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:q,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(_e,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(Re,{value:I,onChange:Pe=>L(Pe.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(Re,{value:F,onChange:Pe=>$(Pe.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!se&&Ae&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{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*(dR[b[0]||"instagram-square"].height/dR[b[0]||"instagram-square"].width)},children:(()=>{const Pe=_6e[j],Fe=b[0]||"instagram-square";return e.jsx(Pe,{...Ae,format:Fe})})()})})]}),e.jsx(Z,{onClick:Ge,disabled:b.length===0||U,size:"lg",className:"w-full gap-2",children:U?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-5 w-5 animate-spin"})," Generating ",b.length," post",b.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[se?e.jsx(t0,{className:"h-5 w-5"}):e.jsx(gn,{className:"h-5 w-5"}),"Generate ",b.length," Social Post",b.length>1?"s":"",se&&e.jsx(nt,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),oe==="generate"&&e.jsxs("div",{className:"space-y-4",children:[U&&e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(Rs,{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:se?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),Y.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(Z,{variant:"outline",size:"sm",onClick:()=>le("customize"),children:[e.jsx(k0,{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:Y.map((Pe,Fe)=>{const Ie=y6e.find(Ve=>Ve.value===Pe.format);return e.jsxs(De,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Pe.imageUrl,alt:`${Pe.format} social post`,className:"w-full rounded"})}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[Ie==null?void 0:Ie.icon,e.jsx("span",{className:"text-sm font-medium",children:Ie==null?void 0:Ie.label})]}),e.jsx(nt,{variant:"outline",className:"text-[10px]",children:Ie==null?void 0:Ie.dimensions})]}),e.jsxs(Z,{size:"sm",className:"w-full gap-1.5",onClick:()=>Ne(Pe.imageUrl,Pe.format),children:[e.jsx(Ei,{className:"h-3.5 w-3.5"})," Download"]})]})]},Fe)})})]})]}),oe==="generate"&&!se&&d&&Ae&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(Pe=>{const Fe=_6e[j],Ie=dR[Pe];return e.jsx("div",{style:{width:Ie.width,height:Ie.height},children:e.jsx(Fe,{ref:Ve=>{de.current[`${j}-${Pe}`]=Ve},...Ae,format:Pe})},`${j}-${Pe}`)})})]})})}function Vms(){return Tt({queryKey:["lms-courses-admin"],queryFn:async()=>{const{data:t,error:s}=await K.from("lms_courses").select("*, modules:lms_modules(count), access:lms_course_access(*)").order("sort_order");if(s)throw s;return t}})}function Hms(t){return Tt({queryKey:["lms-course-admin",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.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 Wms(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.from("lms_courses").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function nQe(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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 Gms(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("lms_courses").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function Kms(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 Zms(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.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 Yms(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("lms_modules").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function Xms(){const t=ds();return Bt({mutationFn:async s=>{const{data:r,error:n}=await K.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 Qms(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.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 Jms(){const t=ds();return Bt({mutationFn:async({courseId:s,accessRules:r})=>{const{error:n}=await K.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 K.from("lms_course_access").insert(a);if(o)throw o}},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]})}})}function eps(){return Tt({queryKey:["lms-courses-agent"],queryFn:async()=>{const{data:t,error:s}=await K.from("lms_courses").select("*, modules:lms_modules(id)").eq("is_published",!0).order("sort_order");if(s)throw s;return t}})}function tps(t){return Tt({queryKey:["lms-course-agent",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.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 aQe(t){return Tt({queryKey:["lms-progress",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("lms_progress").select("*").eq("course_id",t);if(r)throw r;return s},enabled:!!t})}function sps(){const t=ds();return Bt({mutationFn:async({courseId:s,moduleId:r,userId:n})=>{const{data:a,error:o}=await K.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 rps(){const{user:t}=Qs(),s=Or(),{data:r,isLoading:n}=Vms(),a=Wms(),o=nQe(),l=Gms(),[i,d]=M.useState(!1),[u,f]=M.useState(""),[g,v]=M.useState(""),[_,b]=M.useState(!0),w=async()=>{if(!(!u.trim()||!t))try{const S=await a.mutateAsync({title:u.trim(),description:g.trim()||void 0,is_sequential:_,created_by:t.id});ge.success("Course created"),d(!1),f(""),v(""),b(!0),s(`/admin/lms/${S.id}`)}catch{ge.error("Failed to create course")}},j=async S=>{try{await o.mutateAsync({id:S.id,is_published:!S.is_published}),ge.success(S.is_published?"Course unpublished":"Course published")}catch{ge.error("Failed to update course")}},N=async S=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(S),ge.success("Course deleted")}catch{ge.error("Failed to delete")}};return e.jsxs(Ms,{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(Yu,{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(Z,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(ol,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(Z,{onClick:()=>d(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"New Course"]})]})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[1,2,3].map(S=>e.jsx(De,{className:"animate-pulse",children:e.jsxs($t,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]})},S))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(S=>{var F,$;const A=(($=(F=S.modules)==null?void 0:F[0])==null?void 0:$.count)??0,I=S.access||[],L=I.length===0?"No access set":I.some(q=>q.access_type==="all")?"All agents":`${I.length} rule(s)`;return e.jsxs(De,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${S.id}`),children:[e.jsx($t,{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(Vt,{className:"text-base truncate",children:S.title}),S.description&&e.jsx(_r,{className:"mt-1 line-clamp-2",children:S.description})]}),e.jsx(nt,{variant:S.is_published?"default":"secondary",className:"ml-2 shrink-0",children:S.is_published?"Published":"Draft"})]})}),e.jsxs(Oe,{className:"pt-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nu,{className:"h-3.5 w-3.5"}),A," module",A!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[S.is_sequential?e.jsx(b0,{className:"h-3.5 w-3.5"}):e.jsx(sN,{className:"h-3.5 w-3.5"}),S.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xr,{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(Z,{size:"sm",variant:"ghost",onClick:q=>{q.stopPropagation(),j(S)},children:[S.is_published?e.jsx(Nm,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Na,{className:"h-3.5 w-3.5 mr-1"}),S.is_published?"Unpublish":"Publish"]}),e.jsx(Z,{size:"sm",variant:"ghost",className:"text-destructive",onClick:q=>{q.stopPropagation(),N(S.id)},children:e.jsx(Cr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Ai,{className:"h-4 w-4 text-muted-foreground"})]})]})]},S.id)})}):e.jsx(De,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(nu,{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(Z,{onClick:()=>d(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(bs,{open:i,onOpenChange:d,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create New Course"}),e.jsx(Kr,{children:"Set up a new training course for your agents"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Course Title"}),e.jsx(Re,{value:u,onChange:S=>f(S.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{value:g,onChange:S=>v(S.target.value),placeholder:"What will agents learn?",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order"})]}),e.jsx(qr,{checked:_,onCheckedChange:b})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(Z,{onClick:w,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function nps(){const{courseId:t}=Uo(),s=Or(),{data:r,isLoading:n}=Hms(t),a=nQe(),o=Kms(),l=Zms(),i=Yms(),d=Xms(),u=Qms(),f=Jms(),{data:g}=Tt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:We}=await K.from("brokerages").select("id, name").order("name");return We||[]}}),[v,_]=M.useState(null),[b,w]=M.useState(!1),[j,N]=M.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[S,A]=M.useState(null),[I,L]=M.useState({title:"",resource_type:"link",url:""}),[F,$]=M.useState(new Set),[q,H]=M.useState(null),[U,Q]=M.useState(0),[se,te]=M.useState(!1),Y=M.useRef(null),ce=M.useRef(null),[oe,le]=M.useState(!1),[de,xe]=M.useState(""),[be,ye]=M.useState(""),[ve,ke]=M.useState(""),[Ge,Ne]=M.useState(!1);if(n)return e.jsx(Ms,{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(Ms,{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(Z,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Ae=r.modules||[],Pe=r.access||[],Fe=Pe.some(We=>We.access_type==="all"),Ie=Pe.filter(We=>We.access_type==="brokerage").map(We=>We.brokerage_id),Ve=(g||[]).filter(We=>We.name.toLowerCase().includes(de.toLowerCase())),dt=We=>{const Ze=new Set(F);Ze.has(We)?Ze.delete(We):Ze.add(We),$(Ze)},Le=async()=>{if(!q)return null;te(!0),Q(0);try{const{data:We,error:Ze}=await K.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(Ze)throw new Error(Ze.message);const{videoId:ht,libraryId:Ke}=We,{data:qe,error:Je}=await K.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ht,libraryId:Ke}});if(Je)throw new Error(Je.message);const Lt=new XMLHttpRequest;return await new Promise((zt,is)=>{Lt.upload.onprogress=Kt=>{Kt.lengthComputable&&Q(Math.round(Kt.loaded/Kt.total*100))},Lt.onload=()=>Lt.status>=200&&Lt.status<300?zt():is(new Error(`Upload failed: ${Lt.status}`)),Lt.onerror=()=>is(new Error("Upload failed")),Lt.open("PUT",qe.uploadUrl),Lt.setRequestHeader("AccessKey",qe.apiKey),Lt.send(q)}),`https://iframe.mediadelivery.net/embed/${Ke}/${ht}`}catch(We){return console.error("Bunny upload error:",We),ge.error("Video upload failed"),null}finally{te(!1),Q(0)}},Rt=async()=>{if(j.title.trim())try{let We=j.video_url.trim()||void 0;if(q){const Ze=await Le();if(!Ze)return;We=Ze}await o.mutateAsync({course_id:r.id,title:j.title.trim(),description:j.description.trim()||void 0,video_url:We,text_content:j.text_content.trim()||void 0,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):void 0,sort_order:Ae.length}),ge.success("Module added"),w(!1),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),H(null)}catch{ge.error("Failed to add module")}},fe=async()=>{if(v)try{let We=j.video_url.trim()||null;if(q){const Ze=await Le();if(!Ze)return;We=Ze}await l.mutateAsync({id:v.id,title:j.title.trim(),description:j.description.trim()||null,video_url:We,text_content:j.text_content.trim()||null,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):null}),ge.success("Module updated"),_(null),H(null)}catch{ge.error("Failed to update")}},Qe=async We=>{if(confirm("Delete this module?"))try{await i.mutateAsync(We),ge.success("Module deleted")}catch{ge.error("Failed to delete")}},at=async We=>{if(I.title.trim())try{await d.mutateAsync({module_id:We,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),ge.success("Resource added"),A(null),L({title:"",resource_type:"link",url:""})}catch{ge.error("Failed to add resource")}},rt=async()=>{try{await f.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),ge.success("Access updated: All brokerages / all agents")}catch{ge.error("Failed to update access")}},je=async We=>{const Ze=Pe.filter(Je=>Je.access_type==="brokerage").map(Je=>Je.brokerage_id),ht=Ze.includes(We);let Ke;ht?Ke=Ze.filter(Je=>Je!==We):Ke=[...Ze,We];const qe=Ke.map(Je=>({access_type:"brokerage",brokerage_id:Je}));try{await f.mutateAsync({courseId:r.id,accessRules:qe}),ge.success(ht?"Brokerage removed":"Brokerage added")}catch{ge.error("Failed to update access")}},mt=async()=>{try{await f.mutateAsync({courseId:r.id,accessRules:[]}),ge.success("Access cleared")}catch{ge.error("Failed")}},He=async(We,Ze)=>{const ht=Ze==="up"?We-1:We+1;if(!(ht<0||ht>=Ae.length))try{await Promise.all([l.mutateAsync({id:Ae[We].id,sort_order:ht}),l.mutateAsync({id:Ae[ht].id,sort_order:We})])}catch{ge.error("Failed to reorder")}},ct=async()=>{try{await a.mutateAsync({id:r.id,title:be,description:ve||null}),ge.success("Course updated"),Ne(!1)}catch{ge.error("Failed to update")}};return e.jsxs(Ms,{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(Z,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(Ba,{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(nt,{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(b0,{className:"h-3.5 w-3.5"}):e.jsx(sN,{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(Z,{variant:"outline",size:"sm",onClick:()=>{ye(r.title),ke(r.description||""),Ne(!0)},children:[e.jsx(Ga,{className:"h-3.5 w-3.5 mr-1"})," Edit"]}),e.jsxs(Z,{variant:r.is_published?"secondary":"default",size:"sm",onClick:()=>a.mutateAsync({id:r.id,is_published:!r.is_published}).then(()=>ge.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(Nm,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Na,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(Ia,{defaultValue:"modules",className:"w-full",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"modules",children:"Modules"}),e.jsx(Ts,{value:"access",children:"Access & Permissions"}),e.jsx(Ts,{value:"settings",children:"Settings"})]}),e.jsxs(Vs,{value:"modules",className:"mt-6 space-y-4",children:[Ae.map((We,Ze)=>e.jsxs(De,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>dt(We.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:ht=>{ht.stopPropagation(),He(Ze,"up")},disabled:Ze===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Tg,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:ht=>{ht.stopPropagation(),He(Ze,"down")},disabled:Ze===Ae.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(tl,{className:"h-3.5 w-3.5"})})]})}),e.jsx(nt,{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:We.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[We.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Cn,{className:"h-3 w-3"})," Video"]}),We.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Un,{className:"h-3 w-3"})," Text"]}),We.duration_minutes&&e.jsxs("span",{children:[We.duration_minutes," min"]}),We.resources&&We.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Al,{className:"h-3 w-3"})," ",We.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{size:"sm",variant:"ghost",onClick:ht=>{var Ke;ht.stopPropagation(),_(We),N({title:We.title,description:We.description||"",video_url:We.video_url||"",text_content:We.text_content||"",duration_minutes:((Ke=We.duration_minutes)==null?void 0:Ke.toString())||""})},children:e.jsx(Ga,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{size:"sm",variant:"ghost",className:"text-destructive",onClick:ht=>{ht.stopPropagation(),Qe(We.id)},children:e.jsx(Cr,{className:"h-3.5 w-3.5"})})]})]}),F.has(We.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[We.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:We.description}),We.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:We.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:We.video_url})]}),We.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:We.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(Z,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{A(We.id),L({title:"",resource_type:"link",url:""})},children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),We.resources&&We.resources.length>0?e.jsx("div",{className:"space-y-1",children:We.resources.map(ht=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(nt,{variant:"outline",className:"text-[10px]",children:ht.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:ht.title}),ht.url&&e.jsx("a",{href:ht.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(Z,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(ht.id),children:e.jsx(Vr,{className:"h-3 w-3"})})]},ht.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},We.id)),e.jsxs(Z,{variant:"outline",className:"w-full border-dashed",onClick:()=>{w(!0),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(Vs,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:It("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Fe?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:rt,children:[e.jsx("div",{className:It("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Fe?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(up,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:"All Brokerages / All Agents"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Every agent on the platform can access this course"})]}),e.jsx(qr,{checked:Fe,onCheckedChange:rt})]}),!Fe&&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:Ie.length===0?"No brokerages selected — agents won't see this course":`${Ie.length} brokerage${Ie.length!==1?"s":""} selected`})]}),Ie.length>0&&e.jsx(Z,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:mt,children:"Clear all"})]}),e.jsx(Re,{placeholder:"Search brokerages...",value:de,onChange:We=>xe(We.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:Ve.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):Ve.map(We=>{const Ze=Ie.includes(We.id);return e.jsxs("div",{className:It("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ze?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>je(We.id),children:[e.jsx("div",{className:It("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Ze?"bg-primary border-primary":"border-muted-foreground/30"),children:Ze&&e.jsx("svg",{className:"h-3 w-3 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx(_a,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:We.name}),Ze&&e.jsx(nt,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},We.id)})})]})]})]})}),e.jsxs(Vs,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-start gap-6",children:[r.thumbnail_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:r.thumbnail_url,alt:"Course thumbnail",className:"w-48 h-28 object-cover rounded-lg border"}),e.jsx("button",{onClick:()=>a.mutateAsync({id:r.id,thumbnail_url:null}).then(()=>ge.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(Vr,{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(_0,{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 We=>{var ht;const Ze=(ht=We.target.files)==null?void 0:ht[0];if(!(!Ze||!r)){le(!0);try{const Ke=Ze.name.split(".").pop(),qe=`${r.id}/thumbnail.${Ke}`,{error:Je}=await K.storage.from("lms-thumbnails").upload(qe,Ze,{upsert:!0});if(Je)throw Je;const{data:Lt}=K.storage.from("lms-thumbnails").getPublicUrl(qe),zt=`${Lt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:zt}),ge.success("Thumbnail uploaded")}catch{ge.error("Failed to upload thumbnail")}finally{le(!1),ce.current&&(ce.current.value="")}}}}),e.jsxs(Z,{variant:"outline",size:"sm",disabled:oe,onClick:()=>{var We;return(We=ce.current)==null?void 0:We.click()},children:[oe?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(xi,{className:"h-4 w-4 mr-2"}),oe?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Course Settings"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order before advancing"})]}),e.jsx(qr,{checked:r.is_sequential,onCheckedChange:We=>a.mutateAsync({id:r.id,is_sequential:We}).then(()=>ge.success("Updated"))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this course visible to agents with access"})]}),e.jsx(qr,{checked:r.is_published,onCheckedChange:We=>a.mutateAsync({id:r.id,is_published:We}).then(()=>ge.success("Updated"))})]})]})]})]})]})]}),e.jsx(bs,{open:b||!!v,onOpenChange:We=>{We||(w(!1),_(null))},children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:v?"Edit Module":"Add Module"}),e.jsx(Kr,{children:"Configure the module content"})]}),e.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-auto",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Re,{value:j.title,onChange:We=>N(Ze=>({...Ze,title:We.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{value:j.description,onChange:We=>N(Ze=>({...Ze,description:We.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:It("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",q?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var We;return(We=Y.current)==null?void 0:We.click()},children:[e.jsx("input",{ref:Y,type:"file",accept:"video/*",className:"hidden",onChange:We=>{var ht;const Ze=(ht=We.target.files)==null?void 0:ht[0];Ze&&(H(Ze),N(Ke=>({...Ke,video_url:""})))}}),q?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:q.name}),e.jsx(Z,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:We=>{We.stopPropagation(),H(null)},children:e.jsx(Vr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(xi,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),se&&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(Rs,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",U,"%"]})]}),e.jsx(wo,{value:U,className:"h-1.5"})]}),!q&&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(Re,{value:j.video_url,onChange:We=>N(Ze=>({...Ze,video_url:We.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Text Content"}),e.jsx(Lr,{value:j.text_content,onChange:We=>N(Ze=>({...Ze,text_content:We.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Duration (minutes)"}),e.jsx(Re,{type:"number",value:j.duration_minutes,onChange:We=>N(Ze=>({...Ze,duration_minutes:We.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>{w(!1),_(null),H(null)},children:"Cancel"}),e.jsxs(Z,{onClick:v?fe:Rt,disabled:!j.title.trim()||se,children:[se?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zh,{className:"h-4 w-4 mr-2"}),se?"Uploading...":v?"Save Changes":"Add Module"]})]})]})}),e.jsx(bs,{open:!!S,onOpenChange:We=>{We||A(null)},children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Add Resource"}),e.jsx(Kr,{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(_e,{children:"Title"}),e.jsx(Re,{value:I.title,onChange:We=>L(Ze=>({...Ze,title:We.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Type"}),e.jsxs(tr,{value:I.resource_type,onValueChange:We=>L(Ze=>({...Ze,resource_type:We})),children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"link",children:"Link"}),e.jsx(At,{value:"pdf",children:"PDF"}),e.jsx(At,{value:"template",children:"Template"}),e.jsx(At,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"URL"}),e.jsx(Re,{value:I.url,onChange:We=>L(Ze=>({...Ze,url:We.target.value})),placeholder:"https://..."})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>A(null),children:"Cancel"}),e.jsx(Z,{onClick:()=>S&&at(S),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(bs,{open:Ge,onOpenChange:Ne,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Course"}),e.jsx(Kr,{children:"Update the course title and description"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Re,{value:be,onChange:We=>ye(We.target.value)})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{value:ve,onChange:We=>ke(We.target.value),rows:3})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>Ne(!1),children:"Cancel"}),e.jsx(Z,{onClick:ct,disabled:!be.trim(),children:"Save"})]})]})})]})}function aps(){return Tt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await K.rpc("get_lms_stats");if(s)throw s;return t}})}function ips(){return Tt({queryKey:["lms-stats-courses"],queryFn:async()=>{const{data:t,error:s}=await K.rpc("get_lms_course_stats");if(s)throw s;return t||[]}})}function ops(t){return Tt({queryKey:["lms-stats-agents",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.rpc("get_lms_agent_progress",{p_course_id:t});if(r)throw r;return s||[]},enabled:!!t})}function lps(){const t=Or(),{data:s,isLoading:r}=aps(),{data:n,isLoading:a}=ips(),[o,l]=M.useState(null),{data:i,isLoading:d}=ops(o),[u,f]=M.useState(""),g=n==null?void 0:n.find(b=>b.course_id===o),v=i==null?void 0:i.filter(b=>{var w,j;return!u||((w=b.agent_name)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))||((j=b.email)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))}),_=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:nu,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:Ma,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:xr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:so,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:Vc,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:ol,color:"text-rose-500"}];return e.jsx(Ms,{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(Z,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(Ba,{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(Yu,{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:_.map(b=>e.jsx(De,{className:It("transition-all",r&&"animate-pulse"),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b.icon,{className:It("h-4 w-4",b.color)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:b.label})]}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r?"—":b.value})]})},b.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(ol,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>e.jsx(De,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-16 bg-muted rounded"})})},b))}):n!=null&&n.length?e.jsx("div",{className:"space-y-2",children:n.map(b=>{const w=o===b.course_id;return e.jsx(De,{className:It("cursor-pointer transition-all hover:shadow-md",w?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(w?null:b.course_id),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground truncate",children:b.course_title}),e.jsx(nt,{variant:b.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:b.is_published?"Live":"Draft"})]})}),e.jsx(ei,{className:It("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",w&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.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:b.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:b.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:[b.avg_completion_pct,"%"]})]}),e.jsx(wo,{value:b.avg_completion_pct,className:"h-2"})]})]})},b.course_id)})}):e.jsx(De,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No courses created yet"})})})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(J1,{className:"h-5 w-5 text-primary"}),g?`Agent Progress — ${g.course_title}`:"Agent Progress"]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:u,onChange:b=>f(b.target.value),placeholder:"Search agents...",className:"pl-9"})]}),d?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(b=>e.jsx(De,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-12 bg-muted rounded"})})},b))}):v!=null&&v.length?e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:v.map((b,w)=>{const j=b.completion_pct>=100;return e.jsx(De,{className:It("transition-all",j&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:It("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",w===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":w===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":w===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:w+1}),e.jsxs(mn,{className:"h-9 w-9 shrink-0",children:[e.jsx(ba,{src:b.avatar_url||void 0}),e.jsx(pn,{className:"text-xs bg-primary/10 text-primary",children:(b.agent_name||b.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:b.agent_name||b.email}),j&&e.jsxs(nt,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(Ma,{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:[b.modules_completed,"/",b.total_modules," modules"]}),b.last_activity&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),js(new Date(b.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:It("text-sm font-bold",j?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[b.completion_pct,"%"]}),e.jsx(wo,{value:b.completion_pct,className:"h-1.5 mt-1"})]})]})})},b.user_id)})}):e.jsx(De,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:u?"No agents match your search":"No agents have started this course yet"})})})]}):e.jsx(De,{className:"border-dashed",children:e.jsxs(Oe,{className:"py-16 text-center",children:[e.jsx(xr,{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 cps(){const{user:t}=Qs(),s=Or(),{data:r,isLoading:n}=eps();return e.jsx(Ms,{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(Yu,{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(De,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-3"})]})},a))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(a=>e.jsx(dps,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(De,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(nu,{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 dps({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=aQe(t.id),o=(a==null?void 0:a.filter(d=>d.completed).length)??0,l=n>0?Math.round(o/n*100):0;return e.jsxs(De,{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(Yu,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors line-clamp-1",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nu,{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(b0,{className:"h-3.5 w-3.5"}):e.jsx(sN,{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(wo,{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(ei,{className:"h-3.5 w-3.5"})]})})]})]})}function ups(){const{courseId:t}=Uo(),s=Or(),{user:r}=Qs(),{data:n,isLoading:a}=tps(t),{data:o}=aQe(t),l=sps(),[i,d]=M.useState(null),u=(n==null?void 0:n.modules)||[],f=new Set((o==null?void 0:o.filter(S=>S.completed).map(S=>S.module_id))||[]),g=f.size,v=u.length>0?Math.round(g/u.length*100):0;M.useEffect(()=>{if(u.length>0&&!i){const S=u.find(A=>!f.has(A.id));d((S==null?void 0:S.id)||u[0].id)}},[u,i,f]);const _=u.find(S=>S.id===i),b=u.findIndex(S=>S.id===i),w=(S,A)=>{if(!(n!=null&&n.is_sequential)||A===0)return!1;for(let I=0;I{if(!(!_||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:_.id,userId:r.id}),ge.success("Module completed! 🎉"),b{const A=S.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(A)return`https://www.youtube.com/embed/${A[1]}`;const I=S.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const L=S.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`:S};return a?e.jsx(Ms,{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(Ms,{title:n.title,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(Ba,{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:[g,"/",u.length," completed"]}),e.jsxs("span",{children:[v,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(wo,{value:v,className:"h-2"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] gap-4 items-start",children:[e.jsx(De,{className:"lg:sticky lg:top-4",children:e.jsxs(Oe,{className:"p-0",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Modules"})}),e.jsx(Fi,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((S,A)=>{const I=w(S,A),L=f.has(S.id),F=S.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&d(S.id),className:It("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",F?"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(Pu,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx(Ma,{className:"h-4 w-4 text-green-500"}):e.jsx(qc,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:It("font-medium truncate",F&&"text-primary"),children:[A+1,". ",S.title]}),S.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(Tn,{className:"h-3 w-3"})," ",S.duration_minutes," min"]})]})]},S.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:_?e.jsxs(e.Fragment,{children:[_.video_url&&e.jsx(De,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:N(_.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(De,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:_.title}),_.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:_.description})]}),f.has(_.id)?e.jsxs(nt,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(Ma,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(Z,{size:"sm",onClick:j,disabled:l.isPending,children:[e.jsx(Ma,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),_.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:_.text_content}),_.resources&&_.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:_.resources.map(S=>e.jsxs("a",{href:S.url||S.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[S.resource_type==="pdf"?e.jsx(Un,{className:"h-4 w-4 text-red-500 shrink-0"}):S.resource_type==="template"?e.jsx(Yu,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(Al,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:S.title}),e.jsx(un,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},S.id))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4",children:[e.jsxs(Z,{variant:"outline",size:"sm",disabled:b===0,onClick:()=>b>0&&d(u[b-1].id),children:[e.jsx(Ba,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),bd(u[b+1].id),children:["Next ",e.jsx(ei,{className:"h-3.5 w-3.5 ml-1"})]}):v===100&&e.jsx(nt,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(De,{children:e.jsx(Oe,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Ms,{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(Z,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function hps(){const{slug:t}=Uo(),{toast:s}=La(),[r,n]=M.useState(!1),[a,o]=M.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:d}=Tt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:A,error:I}=await K.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(I)throw I;return A},enabled:!!t}),{data:u}=Tt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:A,error:I}=await K.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(I&&I.code!=="PGRST116")throw I;return A},enabled:!!(l!=null&&l.id)}),f=Bt({mutationFn:async()=>{const{error:A}=await K.from("recruit_interest_submissions").insert({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});if(A)throw A},onSuccess:()=>n(!0),onError:A=>s({title:"Error",description:A.message,variant:"destructive"})});if(i)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(d||!l||!l.recruit_form_enabled)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"max-w-md w-full mx-4 text-center",children:[e.jsx(_a,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"This page is not available."})]})});const g=u,v=(g==null?void 0:g.primary_color)||"#406E71",_=(g==null?void 0:g.accent_color)||"#2a4c64",b=(g==null?void 0:g.benefits)||[],w=(g==null?void 0:g.testimonials)||[],j=(g==null?void 0:g.gallery_images)||[],N=(g==null?void 0:g.hero_headline)||`Join ${l.name}`,S=(g==null?void 0:g.hero_subtext)||"Take your real estate career to the next level.";return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${v}, ${_})`},children:e.jsxs("div",{className:"max-w-md w-full mx-4 bg-white rounded-2xl shadow-2xl p-8 text-center space-y-4",children:[e.jsx("div",{className:"h-16 w-16 rounded-full flex items-center justify-center mx-auto",style:{backgroundColor:`${v}20`},children:e.jsx(ma,{className:"h-8 w-8",style:{color:v}})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Thank You!"}),e.jsxs("p",{className:"text-gray-600",children:["Your interest in joining ",l.name," has been submitted. A recruiter will be in touch soon."]})]})}):e.jsxs("div",{className:"min-h-screen",style:{"--recruit-primary":v,"--recruit-accent":_},children:[e.jsxs("section",{className:"relative min-h-[70vh] flex items-center justify-center text-white overflow-hidden",style:{background:g!=null&&g.hero_image_url?`linear-gradient(135deg, ${v}dd, ${_}cc)`:`linear-gradient(135deg, ${v}, ${_})`},children:[(g==null?void 0:g.hero_image_url)&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center mix-blend-overlay opacity-40",style:{backgroundImage:`url(${g.hero_image_url})`}}),e.jsxs("div",{className:"relative z-10 text-center max-w-3xl mx-auto px-6 py-20",children:[(g==null?void 0:g.logo_url)&&e.jsx("img",{src:g.logo_url,alt:l.name,className:"h-16 w-auto mx-auto mb-8 drop-shadow-lg"}),e.jsx("h1",{className:"text-4xl md:text-6xl font-bold mb-6 leading-tight drop-shadow-md",children:N}),e.jsx("p",{className:"text-lg md:text-xl opacity-90 mb-10 max-w-2xl mx-auto leading-relaxed",children:S}),e.jsxs("a",{href:"#apply",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-lg font-semibold shadow-lg transition-all hover:scale-105",style:{backgroundColor:"white",color:v},children:["Apply Now ",e.jsx(tl,{className:"h-5 w-5"})]})]})]}),b.length>0&&e.jsx("section",{className:"py-20 px-6 bg-white",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-center mb-4",style:{color:_},children:"Why Join Us?"}),e.jsx("p",{className:"text-center text-gray-500 mb-12 max-w-2xl mx-auto",children:"Here's what makes our brokerage different."}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8",children:b.map((A,I)=>e.jsxs("div",{className:"text-center p-6 rounded-2xl border border-gray-100 hover:shadow-lg transition-shadow",children:[e.jsx("div",{className:"text-4xl mb-4",children:A.icon}),e.jsx("h3",{className:"text-xl font-bold mb-2",style:{color:_},children:A.title}),e.jsx("p",{className:"text-gray-600",children:A.description})]},I))})]})}),j.length>0&&e.jsx("section",{className:"py-20 px-6",style:{backgroundColor:`${v}08`},children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx(xr,{className:"h-6 w-6",style:{color:v}}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:_},children:"Our Team & Culture"})]}),e.jsx("p",{className:"text-center text-gray-500 mb-12",children:"See what it's like to be part of our team."}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:j.map((A,I)=>e.jsx("img",{src:A,alt:`Team ${I+1}`,className:"w-full h-48 md:h-56 object-cover rounded-xl shadow-md hover:shadow-xl transition-shadow"},I))})]})}),w.length>0&&e.jsx("section",{className:"py-20 px-6 bg-white",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx(d5,{className:"h-6 w-6",style:{color:v}}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:_},children:"What Our Agents Say"})]}),e.jsx("p",{className:"text-center text-gray-500 mb-12",children:"Hear from agents who made the move."}),e.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:w.map((A,I)=>{var L;return e.jsxs("div",{className:"p-6 rounded-2xl border border-gray-100 shadow-sm",children:[e.jsxs("p",{className:"text-gray-700 italic mb-4 leading-relaxed",children:['"',A.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-3",children:[A.photo_url?e.jsx("img",{src:A.photo_url,alt:A.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full flex items-center justify-center text-white text-sm font-bold",style:{backgroundColor:v},children:((L=A.name)==null?void 0:L[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",style:{color:_},children:A.name}),A.role&&e.jsx("p",{className:"text-xs text-gray-500",children:A.role})]})]})]},I)})})]})}),e.jsx("section",{id:"apply",className:"py-20 px-6",style:{backgroundColor:`${v}08`},children:e.jsxs("div",{className:"max-w-lg mx-auto",children:[e.jsx("h2",{className:"text-3xl font-bold text-center mb-2",style:{color:_},children:"Ready to Join?"}),e.jsx("p",{className:"text-center text-gray-500 mb-8",children:"Fill out the form below and a recruiter will be in touch."}),e.jsxs("form",{onSubmit:A=>{A.preventDefault(),f.mutate()},className:"bg-white rounded-2xl shadow-xl p-8 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"First Name *"}),e.jsx(Re,{required:!0,value:a.first_name,onChange:A=>o(I=>({...I,first_name:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Last Name"}),e.jsx(Re,{value:a.last_name,onChange:A=>o(I=>({...I,last_name:A.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Email *"}),e.jsx(Re,{type:"email",required:!0,value:a.email,onChange:A=>o(I=>({...I,email:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Phone"}),e.jsx(Re,{value:a.phone,onChange:A=>o(I=>({...I,phone:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Current Brokerage"}),e.jsx(Re,{value:a.current_brokerage,onChange:A=>o(I=>({...I,current_brokerage:A.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"License #"}),e.jsx(Re,{value:a.license_number,onChange:A=>o(I=>({...I,license_number:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Years of Experience"}),e.jsx(Re,{type:"number",min:"0",value:a.experience_years,onChange:A=>o(I=>({...I,experience_years:A.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Annual Production"}),e.jsx(Re,{placeholder:"e.g. $5M, 20 transactions",value:a.annual_production,onChange:A=>o(I=>({...I,annual_production:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Why are you interested?"}),e.jsx(Lr,{value:a.why_interested,onChange:A=>o(I=>({...I,why_interested:A.target.value})),rows:3,placeholder:"Tell us what you're looking for..."})]}),e.jsx(Z,{type:"submit",className:"w-full h-12 text-base font-semibold rounded-xl",style:{backgroundColor:v},disabled:f.isPending,children:f.isPending?"Submitting...":"Submit Interest"})]})]})}),e.jsx("footer",{className:"py-8 text-center text-sm text-white",style:{backgroundColor:_},children:e.jsxs("p",{children:["© ",new Date().getFullYear()," ",l.name,". All rights reserved."]})})]})}function mps(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 pps(){var v,_,b,w;const{shareToken:t}=Uo(),s=M.useRef(!1),{data:r,isLoading:n,error:a}=Tt({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:j,error:N}=await K.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:S}=await K.from("profiles").select("name, avatar_url, title").eq("id",(L=j.video)==null?void 0:L.owner_user_id).single(),{data:A}=await K.from("brokerages").select("name").eq("id",j.brokerage_id).single(),{data:I}=await K.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",j.brokerage_id).maybeSingle();return{rv:j,profile:S,brokerage:A,settings:I}},enabled:!!t});if(M.useEffect(()=>{var j;!((j=r==null?void 0:r.rv)!=null&&j.id)||s.current||(s.current=!0,K.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(v=r==null?void 0:r.rv)==null?void 0:v.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:d}=r,u=(d==null?void 0:d.primary_color)||"#3b82f6",f=((_=o.prospect)==null?void 0:_.first_name)||"there",g=(b=o.video)!=null&&b.playback_url?mps(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(Gh,{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:[(d==null?void 0:d.logo_url)&&e.jsx("img",{src:d.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 ",f,", ",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})]}),g&&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:g,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((w=l==null?void 0:l.name)==null?void 0:w.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(Z,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:u},onClick:()=>{K.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(nn,{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 fps(){const t=Or(),s=ds(),{isAdmin:r}=Qs(),[n,a]=M.useState(!1),[o,l]=M.useState(null),[i,d]=M.useState(null),{data:u,isLoading:f}=Tt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:L},error:F}=await K.auth.getUser();if(F)throw F;if(!L)return[];const{data:$,error:q}=await K.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(q)throw q;return $}}),g=Bt({mutationFn:async L=>{const{data:{user:F},error:$}=await K.auth.getUser();if($)throw $;if(!F)throw new Error("Not authenticated");const{error:q}=await K.from("social_accounts").delete().eq("id",L).eq("user_id",F.id);if(q)throw q},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),ge.success("Account disconnected successfully")},onError:()=>{ge.error("Failed to disconnect account")}}),v=async()=>{a(!0);try{const{data:L,error:F}=await K.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(F)throw F;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),ge.error("Failed to start connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:L,error:F}=await K.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(F)throw F;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),ge.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:L,error:F}=await K.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(F)throw F;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),ge.error("Failed to start Google connection. Please try again."),a(!1)}},w=(u==null?void 0:u.filter(L=>L.platform==="facebook"))||[],j=(u==null?void 0:u.filter(L=>L.platform==="instagram"))||[],N=(u==null?void 0:u.filter(L=>L.platform==="linkedin"))||[],S=(u==null?void 0:u.filter(L=>L.platform==="google_business"))||[],A=((u==null?void 0:u.length)||0)>0,I=async(L,F)=>{l(L),d(null);try{const{data:$,error:q}=await K.functions.invoke("meta-api-test",{body:{testType:"all",accountId:L}});if(q)throw q;d($.results||[]),ge.success($.summary||"API tests completed")}catch($){console.error("Meta API test error:",$),ge.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Ms,{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(nt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(gn,{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(Z,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(Ba,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(De,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:e.jsx(Tn,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(nt,{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:[A&&e.jsx(De,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Oe,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(hi,{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(De,{children:[e.jsx($t,{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(Fd,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-lg",children:"Facebook"}),e.jsx(_r,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ao,{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(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:L.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(Fd,{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(nt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect Facebook?"}),e.jsx(Xl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>g.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(Z,{onClick:v,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx(Ys,{className:"h-4 w-4"}),w.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(De,{children:[e.jsx($t,{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(zd,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-lg",children:"Instagram"}),e.jsx(_r,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ao,{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(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:L.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(zd,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(nt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect Instagram?"}),e.jsx(Xl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>g.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(Z,{onClick:v,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx(Ys,{className:"h-4 w-4"}),j.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(De,{children:[e.jsx($t,{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(Cm,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-lg",children:"LinkedIn"}),e.jsx(_r,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ao,{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(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:L.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(Cm,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(nt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect LinkedIn?"}),e.jsx(Xl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>g.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(Z,{onClick:_,disabled:n,className:"w-full gap-2",variant:N.length>0?"outline":"default",children:[n?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx(Ys,{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(De,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(nt,{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(nt,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx($t,{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(Pi,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-lg",children:"Google Business"}),e.jsx(_r,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ao,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:L.profile_picture_url||""}),e.jsx(pn,{children:e.jsx(Pi,{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(nt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(uc,{children:[e.jsx(Sh,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})}),e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Disconnect Google Business?"}),e.jsx(Xl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:()=>g.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(Z,{onClick:r?b:void 0,disabled:!r||n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(Ao,{className:"h-4 w-4 animate-spin"}):e.jsx(Ys,{className:"h-4 w-4"}),S.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(w.length>0||j.length>0)&&e.jsxs(De,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx($t,{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(W1,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(_r,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',e.jsx("strong",{children:"public_profile"}),", ",e.jsx("strong",{children:"pages_show_list"}),", ",e.jsx("strong",{children:"pages_read_engagement"}),", ",e.jsx("strong",{children:"instagram_basic"}),", ",e.jsx("strong",{children:"pages_manage_posts"}),", and ",e.jsx("strong",{children:"instagram_content_publish"}),"."]}),e.jsxs("div",{className:"space-y-3",children:[w.map(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(Fd,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:L.page_name||"Facebook Page"})]}),e.jsx(Z,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(W1,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),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(zd,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",L.platform_username||"Instagram"]})]}),e.jsx(Z,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(W1,{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,F)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[L.status==="success"?e.jsx(Ma,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(Rs,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(bc,{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})]})]},F))})]}),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(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-lg",children:"How it works"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"1"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Connect your accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link your Facebook, Instagram, or LinkedIn account"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"2"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Browse Social Swag"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Find the perfect image and caption for your post"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Post with one click"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "Create Post" to share directly to your accounts'})]})]})]})})]})]})]})})}function gps(){const[t]=Gc(),s=Or(),[r,n]=M.useState("loading"),[a,o]=M.useState("Processing your connection...");return M.useEffect(()=>{(async()=>{var g;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),f=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),ge.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),ge.error("No authorization code received");return}try{const{data:v,error:_}=await K.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:f,callbackPath:"/social-connections/callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((g=v.accounts)==null?void 0:g.length)||0} account(s)!`),ge.success("Social accounts connected successfully!");else throw new Error((v==null?void 0:v.error)||"Unknown error")}catch(v){console.error("OAuth callback error:",v),n("error"),o(v instanceof Error?v.message:"Failed to connect accounts"),ge.error("Failed to connect: "+(v instanceof Error?v.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsxs($t,{className:"text-center",children:[r==="loading"&&e.jsx(Rs,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(bc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Vt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(_r,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(Z,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function xps(){const[t]=Gc(),s=Or(),[r,n]=M.useState("loading"),[a,o]=M.useState("Connecting your Google Business Profile...");return M.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),f=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),ge.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),ge.error("No authorization code received");return}try{const{data:g,error:v}=await K.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:f}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Successfully connected Google Business Profile!"),ge.success("Google Business Profile connected!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("Google OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect Google Business Profile"),ge.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(De,{className:"w-full max-w-md",children:[e.jsxs($t,{className:"text-center",children:[r==="loading"&&e.jsx(Rs,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(bc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Vt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(_r,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(Z,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function yps(){const[t]=Gc(),s=Or(),[r,n]=M.useState("loading"),[a,o]=M.useState("Connecting your LinkedIn account...");return M.useEffect(()=>{(async()=>{var g;const i=t.get("code"),d=t.get("state"),u=t.get("error"),f=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,f),n("error"),o(f||"Failed to connect LinkedIn account"),ge.error(f||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),ge.error("No authorization code received");return}try{const{data:v,error:_}=await K.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:d,callbackPath:"/social-connections/linkedin-callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((g=v.accounts)==null?void 0:g.length)||1} LinkedIn account`),ge.success("LinkedIn connected successfully!");else throw new Error((v==null?void 0:v.error)||"Failed to connect LinkedIn account")}catch(v){console.error("LinkedIn callback error:",v),n("error"),o(v instanceof Error?v.message:"Failed to connect LinkedIn account"),ge.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(De,{className:"w-full max-w-md",children:[e.jsxs($t,{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(Rs,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(hi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(bc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Vt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Cm,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(_r,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(Z,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function vps(){const t=Or(),[s,r]=M.useState(null),{data:n,isLoading:a}=RXe(s||void 0,!0),{data:o,isLoading:l}=Xwe(!0),{cartItems:i}=Ioe(),d=i.reduce((f,g)=>f+g.quantity,0),u=f=>{t(`/marketplace/${f.id}`)};return a||l?e.jsx(Ms,{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(f=>e.jsx(gs,{className:"h-10 w-24 flex-shrink-0"},f))}),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(f=>e.jsx(gs,{className:"h-72 w-full"},f))})]})}):e.jsx(Ms,{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(Z,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(vm,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&e.jsx(nt,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:d})]})]}),o&&o.length>0&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[e.jsx(Z,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(f=>e.jsx(Z,{variant:s===f.id?"default":"outline",size:"sm",onClick:()=>r(f.id),children:f.name},f.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(f=>{var g;return e.jsxs(De,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>u(f),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[f.images&&f.images.length>0?e.jsx("img",{src:((g=f.images.find(v=>v.is_primary))==null?void 0:g.image_url)||f.images[0].image_url,alt:f.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"})}),f.category&&e.jsx(nt,{className:"absolute top-2 left-2",variant:"secondary",children:f.category.name})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:f.name}),f.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:f.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(f.base_price).toFixed(2)]}),f.variants&&f.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[f.variants.length," options"]})]})]})]},f.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 iQe=M.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));iQe.displayName="Breadcrumb";const oQe=M.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:It("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));oQe.displayName="BreadcrumbList";const are=M.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:It("inline-flex items-center gap-1.5",t),...s}));are.displayName="BreadcrumbItem";const h0e=M.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?Dve:"a";return e.jsx(a,{ref:n,className:It("transition-colors hover:text-foreground",s),...r})});h0e.displayName="BreadcrumbLink";const lQe=M.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:It("font-normal text-foreground",t),...s}));lQe.displayName="BreadcrumbPage";const m0e=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:It("[&>svg]:size-3.5",s),...r,children:t??e.jsx(ei,{})});m0e.displayName="BreadcrumbSeparator";function _ps(){var te,Y;const{productId:t}=Uo(),s=Or(),{data:r,isLoading:n}=Aus(t||""),{addToCart:a,cartItems:o}=Ioe(),[l,i]=M.useState(null),[d,u]=M.useState(1),[f,g]=M.useState(0),[v,_]=M.useState(null),[b,w]=M.useState(!1),[j,N]=M.useState(!1),S=(te=r==null?void 0:r.variants)==null?void 0:te.find(ce=>ce.id===l),A=((Y=r==null?void 0:r.variants)==null?void 0:Y.filter(ce=>ce.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),L=S?Number(S.price_adjustment):0,F=I+L,$=Number((r==null?void 0:r.shipping_fee)||0),q=o.reduce((ce,oe)=>ce+oe.quantity,0),H=async ce=>{if(!ce.target.files||ce.target.files.length===0)return;w(!0);const oe=ce.target.files[0],le=oe.name.split(".").pop(),de=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${le}`;try{const{error:xe}=await K.storage.from("marketplace").upload(de,oe);if(xe)throw xe;const{data:{publicUrl:be}}=K.storage.from("marketplace").getPublicUrl(de);_(be),ge.success("Artwork uploaded successfully")}catch(xe){ge.error("Failed to upload artwork: "+xe.message)}finally{w(!1)}},U=()=>{if(r){if(A.length>0&&!l){ge.error("Please select an option");return}a(r,S||void 0,d,v||void 0),N(!0),ge.success("Added to cart!"),setTimeout(()=>N(!1),2e3)}},Q=()=>{r!=null&&r.images&&g(ce=>(ce+1)%r.images.length)},se=()=>{r!=null&&r.images&&g(ce=>(ce-1+r.images.length)%r.images.length)};return n?e.jsx(Ms,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(gs,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"h-8 w-3/4"}),e.jsx(gs,{className:"h-6 w-1/4"}),e.jsx(gs,{className:"h-24 w-full"}),e.jsx(gs,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ms,{title:r.name,children:[e.jsx(iQe,{className:"mb-6",children:e.jsxs(oQe,{children:[e.jsx(are,{children:e.jsx(h0e,{asChild:!0,children:e.jsx(yo,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(m0e,{}),e.jsx(are,{children:e.jsx(h0e,{asChild:!0,children:e.jsx(yo,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(m0e,{}),e.jsx(are,{children:e.jsx(lQe,{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[f].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(Z,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:se,children:e.jsx(ec,{className:"h-6 w-6"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:Q,children:e.jsx(ei,{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,oe)=>e.jsx("button",{onClick:()=>g(oe),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${oe===f?"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(De,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:r.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[r.category&&e.jsx(nt,{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:["$",F.toFixed(2)]}),$>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",$.toFixed(2)," shipping"]})]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})}),A.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:A.map(ce=>e.jsxs(Z,{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(_e,{children:"Upload Your Artwork (Optional)"}),v?e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:v,alt:"Your artwork",className:"h-24 w-auto rounded-lg border"}),e.jsx(Z,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>_(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:H,className:"hidden",id:"artwork-upload",disabled:b}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(xi,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:b?"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(_e,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{variant:"outline",size:"icon",onClick:()=>u(ce=>Math.max(1,ce-1)),children:"-"}),e.jsx(Re,{type:"number",value:d,onChange:ce=>u(Math.max(1,parseInt(ce.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(Z,{variant:"outline",size:"icon",onClick:()=>u(ce=>ce+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(Z,{size:"lg",className:"flex-1",onClick:U,disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(vm,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(Z,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(vm,{className:"h-5 w-5"}),q>0&&e.jsx(nt,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:q})]})]}),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(Ms,{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(Z,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function bps(){const t=Or(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=Ioe(),[u,f]=M.useState(!1),[g,v]=M.useState(""),_=async()=>{if(s.length===0){ge.error("Your cart is empty");return}f(!0);try{const{data:b,error:w}=await K.functions.invoke("marketplace-checkout",{body:{items:s.map(j=>{var N;return{product_id:j.product.id,variant_id:((N=j.variant)==null?void 0:N.id)||null,quantity:j.quantity,artwork_url:j.artworkUrl||null}}),notes:g.trim()||null}});if(w)throw w;if(b!=null&&b.url)d(),window.open(b.url,"_blank");else throw new Error("No checkout URL received")}catch(b){ge.error("Checkout failed: "+b.message)}finally{f(!1)}};return s.length===0?e.jsx(Ms,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(qx,{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(Z,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ms,{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(b=>{var w,j;return e.jsx(De,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:b.product.images&&b.product.images.length>0?e.jsx("img",{src:((w=b.product.images.find(N=>N.is_primary))==null?void 0:w.image_url)||b.product.images[0].image_url,alt:b.product.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(qx,{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:b.product.name}),b.variant&&e.jsx("p",{className:"text-sm text-muted-foreground",children:b.variant.name}),e.jsxs("p",{className:"font-medium mt-1",children:["$",a(b).toFixed(2),Number(b.product.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(b.product.shipping_fee).toFixed(2)," shipping"]})]}),b.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(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return r(b.product.id,(N=b.variant)==null?void 0:N.id)},children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return n(b.product.id,(N=b.variant)==null?void 0:N.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(K1,{className:"h-3 w-3"})}),e.jsx(Re,{type:"number",value:b.quantity,onChange:N=>{var S;return n(b.product.id,(S=b.variant)==null?void 0:S.id,parseInt(N.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return n(b.product.id,(N=b.variant)==null?void 0:N.id,b.quantity+1)},children:e.jsx(Ys,{className:"h-3 w-3"})})]})]})]})})},`${b.product.id}-${((j=b.variant)==null?void 0:j.id)||"base"}`)}),e.jsx(Z,{variant:"ghost",className:"text-destructive",onClick:d,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(De,{className:"sticky top-4",children:[e.jsx($t,{children:e.jsx(Vt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((b,w)=>b+w.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(Jl,{}),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(Jl,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Lr,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:g,onChange:b=>v(b.target.value),rows:3,className:"resize-none"})]}),e.jsx(Z,{className:"w-full",size:"lg",onClick:_,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(Ai,{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 wps(){const t=Or(),{data:s,isLoading:r}=$us();return r?e.jsx(Ms,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(gs,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Ms,{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(Z,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ms,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(De,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:n.order_number}),e.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:js(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(nt,{className:Ywe[n.status],children:P5[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,d)=>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-d},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(Z,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(un,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(ei,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const b6e=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function jps({currentStatus:t,statusHistory:s}){const r=b6e.indexOf(t);return e.jsx("div",{className:"space-y-3",children:b6e.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(Ma,{className:"h-4 w-4"}):i?e.jsx(Tn,{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 ${d?"text-muted-foreground":""}`,children:P5[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[js(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function kps(){var N;const{orderId:t}=Uo(),s=Or(),{data:r,isLoading:n,refetch:a}=qus(t||""),o=Hus(),l=Wus(),[i,d]=M.useState(!1),[u,f]=M.useState(null),[g,v]=M.useState(""),[_,b]=M.useState(null),w=async S=>{b(S);try{await o.mutateAsync({orderId:t,itemId:S}),ge.success("Proof approved!"),a()}catch{ge.error("Failed to approve proof")}finally{b(null)}},j=async()=>{if(u){b(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:g}),ge.success("Revision requested"),d(!1),v(""),f(null),a()}catch{ge.error("Failed to request revision")}finally{b(null)}}};return n?e.jsx(Ms,{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(gs,{className:"h-64 w-full"}),e.jsx(gs,{className:"h-48 w-full"})]}),e.jsx(gs,{className:"h-96 w-full"})]})}):r?e.jsxs(Ms,{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(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsx(Vt,{children:"Order Status"}),e.jsx(nt,{className:Ywe[r.status],children:P5[r.status]})]}),e.jsx(Oe,{children:e.jsx(jps,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Items"})}),e.jsx(Oe,{className:"space-y-4",children:(N=r.items)==null?void 0:N.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",S.quantity," × $",Number(S.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(S.unit_price)*S.quantity).toFixed(2)]})]}),S.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(H1,{className:"h-4 w-4"}),"View Artwork",e.jsx(un,{className:"h-3 w-3"})]})]}),S.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(H1,{className:"h-4 w-4"}),"View Proof",e.jsx(un,{className:"h-3 w-3"})]}),S.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(Z,{size:"sm",onClick:()=>w(S.id),disabled:_===S.id,children:[_===S.id?e.jsx(Rs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(lu,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>{f(S.id),d(!0)},disabled:_===S.id,children:[e.jsx(xP,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),S.proof_status==="approved"&&e.jsxs(nt,{className:"bg-green-100 text-green-800",children:[e.jsx(Ma,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),S.proof_status==="rejected"&&S.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(nt,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.proof_notes})]})]})]},S.id))})]}),r.shipping_name&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(vP,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-medium",children:r.shipping_name}),e.jsxs("p",{className:"text-muted-foreground",children:[r.shipping_address,e.jsx("br",{}),r.shipping_city,", ",r.shipping_state," ",r.shipping_zip]}),r.tracking_number&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),e.jsx("p",{className:"font-mono font-medium",children:r.tracking_number}),r.tracking_url&&e.jsxs(Z,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(un,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(De,{className:"sticky top-4",children:[e.jsx($t,{children:e.jsx(Vt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",js(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(Jl,{}),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(Jl,{}),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(Jl,{}),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(bs,{open:i,onOpenChange:d,children:e.jsxs(_s,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Request Changes"}),e.jsx(Kr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Lr,{placeholder:"Describe the changes needed...",value:g,onChange:S=>v(S.target.value),rows:4}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(Z,{onClick:j,disabled:!g.trim()||_!==null,children:[_?e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Ms,{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(Z,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function Nps(){const t=Or(),[s]=Gc();return s.get("session_id"),M.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Ms,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(De,{children:e.jsxs(Oe,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(Ma,{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(Z,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx(Ai,{className:"h-4 w-4 ml-2"})]}),e.jsx(Z,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function Sps(){const{user:t}=Qs(),[s,r]=M.useState("store"),[n,a]=M.useState(null),[o,l]=M.useState(null),[i,d]=M.useState(!1),[u,f]=M.useState(5),[g,v]=M.useState(""),[_,b]=M.useState(!1),[w,j]=M.useState(!1),[N,S]=M.useState(""),[A,I]=M.useState(null),[L,F]=M.useState(!1),{hasSubmittedReview:$,submitReview:q,markPostedToGoogle:H}=R$e(),{data:U}=zXe(),{data:Q,isLoading:se}=FXe(),{data:te,isLoading:Y}=Jus(n),{data:ce,isLoading:oe}=ehs(t==null?void 0:t.id),{data:le=0}=shs(t==null?void 0:t.id),de=rhs(),xe=new Set((ce==null?void 0:ce.map(Ae=>Ae.item_id))||[]),be=async()=>{if(o)try{await de.mutateAsync(o.id),ge.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Ae){ge.error(Ae.message||"Failed to purchase item")}},ye=async()=>{if(!g.trim()){ge.error("Please write a review");return}b(!0);const Ae=await q(u,g);b(!1),Ae.success?(ge.success("Thank you for your review! You earned 25 points!"),S(g),j(!0),v(""),f(5)):ge.error(Ae.error||"Failed to submit review")},ve=()=>{navigator.clipboard.writeText(N),ge.success("Review copied to clipboard!")},ke=()=>{H(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ge=()=>{j(!1),d(!1),S("")};return se||Y||oe?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{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(gs,{className:"h-64"},Ae))})]})}):e.jsxs(Ms,{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(De,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Gn,{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:le.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(so,{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(dp,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(Eg,{open:L,onOpenChange:F,children:e.jsxs(De,{className:"border-primary/20",children:[e.jsx(Pg,{asChild:!0,children:e.jsx($t,{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(so,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Vt,{className:"text-base",children:"How to Earn Points"}),e.jsx(_r,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(Tg,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(tl,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(Ig,{children:e.jsx(Oe,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[U==null?void 0:U.filter(Ae=>Ae.is_active).map(Ae=>{const Pe=Fe=>{switch(Fe){case"event_attendance":return e.jsx(nn,{className:"h-5 w-5"});case"leave_review":return e.jsx(Gn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Hn,{className:"h-5 w-5"});case"first_contact":return e.jsx(xr,{className:"h-5 w-5"});case"first_video":return e.jsx(Cn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(ho,{className:"h-5 w-5"});default:return e.jsx(uo,{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:Pe(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(nt,{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(dp,{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(nt,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!$&&e.jsx(De,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:e.jsx(ho,{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(Z,{onClick:()=>d(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(Ia,{value:s,onValueChange:r,children:[e.jsxs(Aa,{children:[e.jsxs(Ts,{value:"store",className:"flex items-center gap-2",children:[e.jsx(qx,{className:"h-4 w-4"}),"Store"]}),e.jsxs(Ts,{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(nt,{variant:"secondary",className:"ml-1",children:ce.length})]})]}),e.jsxs(Vs,{value:"store",className:"mt-6",children:[Q&&Q.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(Z,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),Q.map(Ae=>e.jsxs(Z,{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(De,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(uo,{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 Pe=xe.has(Ae.id),Fe=Ae.max_quantity!==null&&Ae.current_quantity===0,Ie=le>=Ae.points_cost;return e.jsxs(De,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Pe?"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"}),Pe&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(nt,{className:"bg-green-500 text-white",children:[e.jsx(Ma,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Fe&&!Pe&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(nt,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(uo,{className:"h-12 w-12 text-muted-foreground/50"}),Pe&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(nt,{className:"bg-green-500 text-white",children:[e.jsx(Ma,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs($t,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Vt,{className:"text-lg",children:Ae.name}),e.jsxs(nt,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Ae.points_cost]})]}),Ae.category&&e.jsxs(nt,{variant:"outline",className:"w-fit",children:[Ae.category.icon&&`${Ae.category.icon} `,Ae.category.name]})]}),e.jsxs(Oe,{children:[e.jsx(_r,{className:"mb-4 line-clamp-2",children:Ae.description||"No description available"}),Ae.max_quantity!==null&&!Pe&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Ae.current_quantity," of ",Ae.max_quantity," remaining"]}),Pe?e.jsx(Z,{className:"w-full",onClick:Ve=>{Ve.stopPropagation(),Ae.file_url&&spe(Ae.file_url,Ae.name)},disabled:!Ae.file_url,children:Ae.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(Z,{className:"w-full",onClick:Ve=>{Ve.stopPropagation(),l(Ae)},disabled:Fe||!Ie,children:Fe?"Sold Out":Ie?e.jsxs(e.Fragment,{children:[e.jsx(qx,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Ae.points_cost-le} more pts`})]})]},Ae.id)})})]}),e.jsx(Vs,{value:"my-rewards",className:"mt-6",children:!ce||ce.length===0?e.jsx(De,{children:e.jsx(Oe,{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 Pe,Fe,Ie,Ve,dt;return e.jsxs(De,{className:"overflow-hidden",children:[(Pe=Ae.item)!=null&&Pe.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:((Fe=Ae.item)==null?void 0:Fe.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(uo,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs($t,{className:"pb-2",children:[e.jsx(Vt,{className:"text-lg",children:((Ie=Ae.item)==null?void 0:Ie.name)||"Unknown Item"}),e.jsxs(_r,{className:"text-xs",children:["Purchased for ",Ae.points_spent," points • ",new Date(Ae.purchased_at).toLocaleDateString()]})]}),e.jsx(Oe,{children:e.jsx(Z,{className:"w-full",onClick:()=>{var Le,Rt;(Le=Ae.item)!=null&&Le.file_url&&spe(Ae.item.file_url,(Rt=Ae.item)==null?void 0:Rt.name)},disabled:!((Ve=Ae.item)!=null&&Ve.file_url),children:((dt=Ae.item)==null?void 0:dt.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Ae.id)})})})]})]}),e.jsx(uc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(Gl,{children:[e.jsxs(Kl,{children:[e.jsx(Yl,{children:"Confirm Purchase"}),e.jsxs(Xl,{children:['Are you sure you want to purchase "',o==null?void 0:o.name,'" for ',o==null?void 0:o.points_cost," points?",e.jsx("br",{}),e.jsx("br",{}),"You currently have ",e.jsxs("strong",{children:[le," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[le-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(Zl,{children:[e.jsx(Ql,{children:"Cancel"}),e.jsx(Ml,{onClick:be,disabled:de.isPending,children:de.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(bs,{open:i,onOpenChange:Ae=>{!Ae&&w?Ge():d(Ae)},children:e.jsx(_s,{children:w?e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Ma,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Kr,{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(Z,{variant:"outline",className:"w-full",onClick:ve,children:[e.jsx(Ni,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(qn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(Z,{variant:"outline",onClick:Ge,children:"Maybe Later"}),e.jsxs(Z,{onClick:ke,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Leave a Review"}),e.jsx(Kr,{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:()=>f(Ae),className:"focus:outline-none",children:e.jsx(Gn,{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(Lr,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:g,onChange:Ae=>v(Ae.target.value),rows:4})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(Z,{onClick:ye,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(bs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[A==null?void 0:A.name,e.jsxs(nt,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),A==null?void 0:A.points_cost]})]}),(A==null?void 0:A.category)&&e.jsxs(nt,{variant:"outline",className:"w-fit",children:[A.category.icon&&`${A.category.icon} `,A.category.name]})]}),(A==null?void 0:A.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:A.preview_image_url,alt:A.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(A==null?void 0:A.description)||"No description available"}),(A==null?void 0:A.max_quantity)!==null&&!xe.has((A==null?void 0:A.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A==null?void 0:A.current_quantity," of ",A==null?void 0:A.max_quantity," remaining"]})]}),e.jsx(qn,{children:A&&xe.has(A.id)?e.jsx(Z,{className:"w-full",onClick:()=>{A.file_url&&spe(A.file_url,A.name)},disabled:!A.file_url,children:A.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Access"]})}):A&&e.jsx(Z,{className:"w-full",onClick:()=>{I(null),l(A)},disabled:A.max_quantity!==null&&A.current_quantity===0||le{const{user:t}=Qs(),s=ds(),r=Tt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:f}=await K.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(f)throw f;return u||[]},enabled:!!t}),n=Tt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:f}=await K.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(f)throw f;return u||[]},enabled:!!t}),a=Bt({mutationFn:async u=>{const{data:f,error:g}=await K.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Bt({mutationFn:async({id:u,...f})=>{const{data:g,error:v}=await K.from("smart_presentations").update(f).eq("id",u).select().single();if(v)throw v;return g},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Bt({mutationFn:async u=>{const{data:f,error:g}=await K.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),ge.success("Presentation published!")}}),i=Bt({mutationFn:async u=>{const{error:f}=await K.from("smart_presentations").update({status:"archived"}).eq("id",u);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),ge.success("Presentation archived")}}),d=Bt({mutationFn:async u=>{const{error:f}=await K.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(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),ge.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:d}},Cps=()=>{const t=Or(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=cQe(),o=i=>i.status==="draft"?e.jsx(nt,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(nt,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(nt,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const d=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(d),ge.success("Link copied!")};return e.jsx(Ms,{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(Z,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(gs,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(lf,{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(Z,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(De,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Un,{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 ",js(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Na,{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(Z,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(Ni,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(Du,{children:[e.jsx(Ou,{asChild:!0,children:e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(xg,{className:"h-4 w-4"})})}),e.jsxs(mu,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Wa,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Wa,{onClick:()=>a.mutate(i),children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Wa,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(K4,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},w6e={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."}]},Mps=[{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 Tps(t){const s=w6e[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(w6e))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return Mps}function Aps({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=M.useState(!1),[o,l]=M.useState("script"),[i,d]=M.useState(0),[u,f]=M.useState(0),{canRecord:g}=fGe(),v=XN(),[_,b]=M.useState(""),[w,j]=M.useState(!1),[N,S]=M.useState(!0),[A,I]=M.useState(!1),[L,F]=M.useState(null),$=Tps(t),q=()=>{l("script"),d(0),f(0),b(""),j(!1),S(!0),I(!1),F(null)},H=Y=>{!Y&&(o==="uploading"||o==="processing")||(a(Y),Y||q())},U=Y=>{F(Y),b($[Y].text),j(!1)},Q=()=>{l("record"),S(_.trim().length>0)},se=()=>{b(""),S(!1),l("record")},te=M.useCallback(async(Y,ce)=>{l("uploading");try{const oe=t||"Presentation Video",{videoId:le,uploadUrl:de,libraryId:xe}=await EL(oe),{apiKey:be}=await PL(le),ye=new XMLHttpRequest;ye.upload.onprogress=Ae=>{Ae.lengthComputable&&d(Ae.loaded/Ae.total*100)},await new Promise((Ae,Pe)=>{ye.onload=()=>ye.status>=200&&ye.status<300?Ae():Pe(new Error("Upload failed")),ye.onerror=()=>Pe(new Error("Upload failed")),ye.open("PUT",de),ye.setRequestHeader("AccessKey",be),ye.send(Y)}),l("processing");let ve=0;const ke=Date.now(),Ge=9e4;let Ne=null;for(;ve<4;){if(await new Promise(Pe=>setTimeout(Pe,3e3)),Date.now()-ke>Ge){const Pe=Y.size/1048576,Fe=`https://iframe.mediadelivery.net/embed/${xe}/${le}?responsive=true`;await v.mutateAsync({bunny_video_id:le,playback_url:Fe,file_size_mb:Pe,title:oe,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Fe),ge.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Ae=await y3(le);if(ve=Ae.status,f(Ae.encodeProgress||0),ve===4)Ne={playbackUrl:Ae.directPlayUrl,thumbnailUrl:Ae.thumbnailUrl,previewUrl:Ae.previewUrl||null,duration:Ae.length||ce,fileSizeMb:(Ae.storageSize||Y.size)/(1024*1024)};else if(ve===5||ve===6)throw new Error("Video processing failed")}if(!Ne)throw new Error("No video data");await v.mutateAsync({bunny_video_id:le,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:oe,status:"ready",touch_type:"presentation"}),r(Ne.playbackUrl),ge.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(oe){console.error("Recording upload error:",oe),ge.error("Failed to process video. Please try again."),l("record")}},[t,s,r,v]);return e.jsxs(bs,{open:n,onOpenChange:H,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{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(_s,{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(Cs,{children:e.jsxs(Ss,{children:[o==="script"&&`Prepare your script for "${t}"`,o==="record"&&`Record video for "${t}"`,o==="uploading"&&"Uploading...",o==="processing"&&"Processing...",o==="done"&&"Done!"]})}),o==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a starter script below, edit it to make it yours, or skip and speak freely."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starter Scripts"}),e.jsx("div",{className:"grid gap-2",children:$.map((Y,ce)=>e.jsxs("button",{onClick:()=>U(ce),className:It("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(Un,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:Y.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:Y.text})]},ce))})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!w&&e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>j(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Ga,{className:"h-3 w-3"}),"Edit"]})]}),w?e.jsx(Lr,{value:_,onChange:Y=>b(Y.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:_})]}),!_&&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(Lr,{value:_,onChange:Y=>{b(Y.target.value),F(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(Z,{variant:"ghost",size:"sm",onClick:se,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(Z,{onClick:Q,disabled:!1,children:_.trim()?"Continue with Script":"Continue Without Script"})]})]}),!g&&o==="record"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx(jh,{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."}),_.trim()&&e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>S(!N),className:"h-7 text-xs gap-1",children:[N?e.jsx(Nm,{className:"h-3 w-3"}):e.jsx(Na,{className:"h-3 w-3"}),N?"Hide Script":"Show Script"]})]}),e.jsx(pce,{maxDurationSeconds:60,onRecordingComplete:te,onRecordingStateChange:I,onError:Y=>ge.error(Y),teleprompterContent:_.trim()?e.jsx(fXe,{text:_,isVisible:N,onToggleVisibility:()=>S(!N),isRecording:A,startCountdown:!1}):void 0}),e.jsx(Z,{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(Rs,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(wo,{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(Rs,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(wo,{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(hi,{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 Eps({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=M.useState(!1),[o,l]=M.useState(null),[i,d]=M.useState("idle"),[u,f]=M.useState(0),g=M.useRef(null),v=XN(),{data:_}=fle(),b=(_==null?void 0:_.total_storage_mb)||0,j=((_==null?void 0:_.max_storage_mb)||1024)-b,N=()=>{l(null),d("idle"),f(0)},S=$=>{!$&&i!=="idle"&&i!=="done"||(a($),$||N())},A=$=>{var U;const q=(U=$.target.files)==null?void 0:U[0];if(!q)return;if(!q.type.startsWith("video/")){ge.error("Please select a video file");return}const H=q.size/(1024*1024);if(H>500){ge.error("Video file must be less than 500MB");return}if(H>j){ge.error(`Not enough storage. You have ${j.toFixed(1)} MB remaining.`);return}l(q)},I=M.useCallback(async()=>{if(o){d("creating"),f(0);try{const $=t||o.name,{data:q,error:H}=await K.functions.invoke("bunny-upload",{body:{action:"create",title:$,isAgentVideo:!0}});if(H)throw new Error(H.message);const{videoId:U,libraryId:Q}=q;d("uploading");const{data:se,error:te}=await K.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:U,isAgentVideo:!0}});if(te)throw new Error(te.message);await new Promise((oe,le)=>{const de=new XMLHttpRequest;de.upload.addEventListener("progress",xe=>{xe.lengthComputable&&f(Math.round(xe.loaded/xe.total*100))}),de.addEventListener("load",()=>de.status>=200&&de.status<300?oe():le(new Error(`Upload failed (${de.status})`))),de.addEventListener("error",()=>le(new Error("Upload failed"))),de.open("PUT",se.uploadUrl),de.setRequestHeader("AccessKey",se.apiKey),de.send(o)}),d("processing");const Y=o.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${Q}/${U}`;await v.mutateAsync({bunny_video_id:U,playback_url:ce,file_size_mb:Y,title:$,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(ce),d("done"),ge.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch($){console.error("Upload error:",$),ge.error($ instanceof Error?$.message:"Failed to upload video"),d("idle")}}},[o,t,s,r,v]),L=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${u}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},F=i!=="idle"&&i!=="done";return e.jsxs(bs,{open:n,onOpenChange:S,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(xi,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsxs(Ss,{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"]})]}),!F&&e.jsx(Z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Vr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var $;return($=g.current)==null?void 0:$.click()},children:[e.jsx(xi,{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:g,type:"file",accept:"video/*",className:"hidden",onChange:A,disabled:F}),F&&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(Rs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(wo,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>S(!1),disabled:F,children:"Cancel"}),e.jsx(Z,{onClick:I,disabled:!o||F,children:F?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const j6e=[{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"}],k6e=()=>{const t=Or(),{id:s}=Uo(),{user:r}=Qs(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=cQe(),{isGmailConnected:d,gmailEmail:u}=G0(),[f,g]=M.useState(!1),[v,_]=M.useState("client"),[b,w]=M.useState(!1),[j,N]=M.useState(""),[S,A]=M.useState([]),[I,L]=M.useState(!1),[F,$]=M.useState(null),[q,H]=M.useState(!1),[U,Q]=M.useState(""),[se,te]=M.useState(""),[Y,ce]=M.useState(""),[oe,le]=M.useState("buyer"),[de,xe]=M.useState(""),[be,ye]=M.useState(null),[ve,ke]=M.useState(""),[Ge,Ne]=M.useState([]),[Ae,Pe]=M.useState("schedule_call"),[Fe,Ie]=M.useState("Schedule a Call"),[Ve,dt]=M.useState(""),[Le,Rt]=M.useState(""),[fe,Qe]=M.useState(null),[at,rt]=M.useState(s||null),[je,mt]=M.useState(null),[He,ct]=M.useState(!1),We=async(bt,ws)=>{if(!r)return;const ir=5*1024*1024;if(bt.size>ir){ge.error("Image must be under 5MB");return}if(!bt.type.startsWith("image/")){ge.error("Please upload an image file");return}Qe(ws);try{const Rr=bt.name.split(".").pop()||"jpg",oa=`${r.id}/${Date.now()}.${Rr}`,{error:ri}=await K.storage.from("listing-photos").upload(oa,bt);if(ri)throw ri;const{data:{publicUrl:no}}=K.storage.from("listing-photos").getPublicUrl(oa);Lt(ws,{image_url:no}),ge.success("Image uploaded")}catch{ge.error("Failed to upload image")}finally{Qe(null)}};M.useEffect(()=>{s&&Ze(s)},[s]);const Ze=async bt=>{const{data:ws,error:ir}=await K.from("smart_presentations").select("*").eq("id",bt).single();if(ir||!ws)return;const Rr=ws;if(w(!0),ke(Rr.title),Q(Rr.client_name||""),xe(Rr.property_address||""),Ne(Rr.sections||[]),Pe(Rr.cta_type||"schedule_call"),Ie(Rr.cta_label||"Schedule a Call"),dt(Rr.cta_url||""),Rt(Rr.heading||""),mt(Rr.share_token),ct(Rr.status==="published"),rt(Rr.id),_("builder"),Rr.contact_id){const{data:oa}=await K.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Rr.contact_id).maybeSingle();oa&&($(oa),te(oa.email||""),ce(oa.phone||""))}};M.useEffect(()=>{if(!r||j.length<1){A([]);return}const bt=setTimeout(async()=>{L(!0);const{data:ws}=await K.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${j}%,last_name.ilike.%${j}%,email.ilike.%${j}%`).limit(10);A(ws||[]),L(!1)},300);return()=>clearTimeout(bt)},[j,r]);const ht=bt=>{$(bt),Q(`${bt.first_name} ${bt.last_name||""}`.trim()),te(bt.email||""),ce(bt.phone||""),H(!1)},Ke=async()=>{if(!U.trim()){ge.error("Client name is required");return}const bt=U.trim().split(" "),ws=bt[0],ir=bt.slice(1).join(" ")||null,{data:Rr,error:oa}=await K.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:ws,last_name:ir,email:se||null,phone:Y||null,lead_source:"Smart Presentation"}).select().single();if(oa){ge.error("Failed to create client");return}$(Rr),ge.success("Client created & saved to Agent OS"),_("template")},qe=bt=>{ye(bt);const ws=(bt.sections||[]).map(ir=>({...ir,is_visible:!0,video_url:"",text:""}));if(Ne(ws),ke(bt.name+(U?` for ${U}`:"")),bt.cta_config){const ir=bt.cta_config;Pe(ir.type||"schedule_call"),Ie(ir.label||"Schedule a Call")}_("builder")},Je=()=>{Ne([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),ke(U?`Presentation for ${U}`:"New Presentation"),_("builder")},Lt=(bt,ws)=>{Ne(ir=>ir.map((Rr,oa)=>oa===bt?{...Rr,...ws}:Rr))},zt=bt=>{Lt(bt,{is_visible:!Ge[bt].is_visible})},is=()=>{Ne(bt=>[...bt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Kt=bt=>{Ne(ws=>ws.filter((ir,Rr)=>Rr!==bt))},Qt=async()=>{if(!ve.trim()){ge.error("Title is required");return}try{if(at){const bt=await l.mutateAsync({id:at,title:ve,sections:Ge,client_name:U,property_address:de||null,cta_type:Ae,cta_label:Fe,cta_url:Ve||null,heading:Le||null});ge.success("Saved")}else{const bt=await o.mutateAsync({title:ve,contact_id:(F==null?void 0:F.id)||void 0,client_name:U,property_address:de||void 0,template_id:(be==null?void 0:be.id)||void 0,sections:Ge,cta_type:Ae,cta_label:Fe,cta_url:Ve||void 0,heading:Le||void 0});rt(bt.id),mt(bt.share_token),ge.success("Presentation created!")}}catch(bt){console.error("Failed to save presentation:",bt);const ws=(bt==null?void 0:bt.message)||(bt==null?void 0:bt.toString())||"Unknown error";ge.error(`Failed to save: ${ws}`)}},fs=async()=>{try{await Qt();const bt=at;if(bt){const ws=await i.mutateAsync(bt);mt(ws.share_token),ct(!0),_("share")}}catch(bt){console.error("Failed to publish presentation:",bt),ge.error(`Failed to publish: ${(bt==null?void 0:bt.message)||"Unknown error"}`)}},dr=je?`https://presentations.relevelup.com/${je}`:"";return e.jsx(Ms,{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(Z,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(Ba,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:b?"Edit Presentation":"Create Smart Presentation"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[v==="client"&&"Who is this presentation for?",v==="template"&&"Choose a starting template",v==="builder"&&"Customize your presentation",v==="share"&&"Share with your client"]})]})]}),!b&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((bt,ws)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:It("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",v===bt?"bg-primary text-primary-foreground":ws<["client","template","builder","share"].indexOf(v)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:ws<["client","template","builder","share"].indexOf(v)?e.jsx(ma,{className:"h-4 w-4"}):ws+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:bt}),ws<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},bt))}),v==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{$(null),Q(""),te(""),ce(""),H(!1),_("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(Pa,{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(Ai,{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(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:j,onChange:bt=>N(bt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(gs,{className:"h-12 w-full"}),S.map(bt=>e.jsxs("button",{onClick:()=>ht(bt),className:It("w-full text-left p-3 rounded-lg border transition-colors",(F==null?void 0:F.id)===bt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[bt.first_name," ",bt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:bt.email||bt.phone||"No contact info"})]},bt.id)),!j&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),j&&S.length===0&&!I&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),F&&e.jsxs(Z,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",F.first_name,e.jsx(Ai,{className:"h-4 w-4"})]})]})]}),e.jsxs(De,{children:[e.jsx($t,{className:"pb-3",children:e.jsxs(Vt,{className:"text-base flex items-center gap-2",children:[e.jsx(pc,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(_e,{className:"text-xs",children:"Name *"}),e.jsx(Re,{value:U,onChange:bt=>{Q(bt.target.value),H(!0),$(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Email"}),e.jsx(Re,{value:se,onChange:bt=>te(bt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Phone"}),e.jsx(Re,{value:Y,onChange:bt=>ce(bt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Client Type"}),e.jsxs(tr,{value:oe,onValueChange:le,children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"}),e.jsx(At,{value:"recruit",children:"Recruit"}),e.jsx(At,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Property Address"}),e.jsx(Re,{value:de,onChange:bt=>xe(bt.target.value),placeholder:"Optional"})]})]}),q&&U&&e.jsxs(Z,{onClick:Ke,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Ai,{className:"h-4 w-4"})]})]})]})]})]}),v==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ia,{defaultValue:"system",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"mine",children:"My Core Templates"}),e.jsx(Ts,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(Ts,{value:"blank",children:"+ Start Blank"})]}),e.jsx(Vs,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(bt=>e.jsx(gs,{className:"h-32"},bt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(bt=>!bt.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(bt=>!bt.is_system).map(bt=>e.jsx(N6e,{template:bt,onSelect:qe},bt.id))})}),e.jsx(Vs,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(bt=>bt.is_system).map(bt=>e.jsx(N6e,{template:bt,onSelect:qe},bt.id))})}),e.jsx(Vs,{value:"blank",className:"mt-4",children:e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(Z,{onClick:Je,children:"Start from Scratch"})]})})})]}),e.jsxs(Z,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[e.jsx(Ba,{className:"h-4 w-4"}),"Back"]})]}),v==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(De,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Presentation Title"}),e.jsx(Re,{value:ve,onChange:bt=>ke(bt.target.value)})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Page Heading"}),e.jsx(Re,{value:Le,onChange:bt=>Rt(bt.target.value),placeholder:U?`Welcome, ${U}!`:"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(_e,{children:"Client Name"}),e.jsx(Re,{value:U,onChange:bt=>Q(bt.target.value)})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Re,{value:de,onChange:bt=>xe(bt.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(Z,{variant:"outline",size:"sm",onClick:is,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Ge.map((bt,ws)=>e.jsx(De,{className:It(!bt.is_visible&&"opacity-50"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[e.jsx(Rh,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:bt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Re,{value:bt.title,onChange:ir=>Lt(ws,{title:ir.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(Z,{variant:"ghost",size:"icon",onClick:()=>zt(ws),children:bt.is_visible?e.jsx(Na,{className:"h-4 w-4"}):e.jsx(Nm,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>Kt(ws),className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})]})]}),e.jsx(Re,{value:bt.description||"",onChange:ir=>Lt(ws,{description:ir.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(_e,{className:"text-xs",children:"Video URL"}),e.jsx(Re,{value:bt.video_url||"",onChange:ir=>Lt(ws,{video_url:ir.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(Aps,{sectionTitle:bt.title,contactId:F==null?void 0:F.id,onVideoReady:ir=>Lt(ws,{video_url:ir})}),e.jsx(Eps,{sectionTitle:bt.title,contactId:F==null?void 0:F.id,onVideoReady:ir=>Lt(ws,{video_url:ir})}),e.jsx(Wwe,{userId:r==null?void 0:r.id,onSelect:ir=>Lt(ws,{video_url:ir})})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),bt.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:bt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(Z,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Lt(ws,{image_url:""}),children:e.jsx(Vr,{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:[fe===ws?e.jsx(Rs,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(_0,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:fe===ws?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:fe===ws,onChange:ir=>{var oa;const Rr=(oa=ir.target.files)==null?void 0:oa[0];Rr&&We(Rr,ws),ir.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Text (optional)"}),e.jsx(Wg,{content:bt.text||"",onChange:ir=>Lt(ws,{text:ir}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},ws))})]}),e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{className:"text-base",children:"Call to Action"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"CTA Type"}),e.jsxs(tr,{value:Ae,onValueChange:bt=>{Pe(bt);const ws=j6e.find(ir=>ir.value===bt);ws&&Ie(ws.label)},children:[e.jsx(Js,{children:e.jsx(rr,{})}),e.jsx(er,{children:j6e.map(bt=>e.jsx(At,{value:bt.value,children:bt.label},bt.value))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Button Label"}),e.jsx(Re,{value:Fe,onChange:bt=>Ie(bt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(_e,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(Re,{value:Ve,onChange:bt=>dt(bt.target.value),placeholder:"https://calendly.com/..."}),!Ve&&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:[!b&&e.jsxs(Z,{variant:"outline",onClick:()=>_("template"),className:"gap-2",children:[e.jsx(Ba,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(Z,{variant:"outline",onClick:Qt,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(Z,{onClick:fs,disabled:i.isPending,className:"gap-2",children:[e.jsx(Pa,{className:"h-4 w-4"}),He?"Update & Reshare":"Publish & Share"]})]})]})]}),v==="share"&&je&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mb-4",children:e.jsx(ma,{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 ",U||"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(Re,{value:dr,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(Z,{onClick:()=>{navigator.clipboard.writeText(dr),ge.success("Link copied!")},children:e.jsx(Ni,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(Z,{variant:"outline",className:"gap-2",onClick:()=>{const bt=`Hi ${U||""}! I put together something for you — check it out: ${dr}`;navigator.clipboard.writeText(bt),ge.success("Message copied!")},children:[e.jsx(ho,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(Z,{variant:"outline",className:"gap-2",onClick:()=>{d?g(!0):window.open(`mailto:${se||""}?subject=${encodeURIComponent(ve)}&body=${encodeURIComponent(`Hi ${(F==null?void 0:F.first_name)||(U==null?void 0:U.split(" ")[0])||""}, I put together a personalized presentation for you: ${dr} Looking forward to connecting!`)}`)},children:[e.jsx(Ar,{className:"h-4 w-4"}),"Send Email"]})]}),d&&e.jsx(AL,{open:f,onOpenChange:g,contact:F?{id:F.id,first_name:F.first_name,last_name:F.last_name,email:se||F.email||""}:se?{id:"",first_name:(U==null?void 0:U.split(" ")[0])||"",last_name:(U==null?void 0:U.split(" ").slice(1).join(" "))||"",email:se}:void 0,defaultSubject:ve,defaultBody:`Hi ${(F==null?void 0:F.first_name)||(U==null?void 0:U.split(" ")[0])||""}, I put together a personalized presentation for you: ${dr} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(Z,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(Z,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},N6e=({template:t,onSelect:s})=>e.jsx(De,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(nt,{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(Z,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),Pps=()=>{var w;const{shareToken:t}=Uo(),[s,r]=M.useState(null),[n,a]=M.useState(!0),[o,l]=M.useState(0),[i,d]=M.useState(!1);M.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),M.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:j,error:N}=await K.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(N||!j){d(!0),a(!1);return}const{data:S}=await K.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let A;if(S!=null&&S.brokerage_id){const{data:L}=await K.from("brokerages").select("name").eq("id",S.brokerage_id).single();A=(L==null?void 0:L.name)||void 0}let I=null;if(j.contact_id){const{data:L}=await K.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();I=L}r({...j,owner_name:S==null?void 0:S.name,owner_email:S==null?void 0:S.email,owner_phone:S==null?void 0:S.phone,owner_avatar:S==null?void 0:S.avatar_url,owner_title:(S==null?void 0:S.title)||void 0,brokerage_name:A,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 K.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{}},f=async()=>{if(s){try{await K.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(gs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(gs,{className:"h-64 w-full"}),e.jsx(gs,{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),v=g[o],_=j=>{const N=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(N)return`https://www.youtube.com/embed/${N[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const I=j.replace("/play/","/embed/"),L=I.includes("?")?"&":"?";return`${I}${L}responsive=true`}if(j.includes("iframe.mediadelivery.net")){if(j.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=j.includes("?")?"&":"?";return`${j}${L}responsive=true`}return""}const S=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const A=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return A?`https://iframe.mediadelivery.net/embed/${A[1]}/${A[2]}?responsive=true`:j},b=!!((w=s.cta_url)!=null&&w.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[v!=null&&v.video_url&&_(v.video_url)?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:_(v.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):v!=null&&v.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:v.image_url,alt:v.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:v==null?void 0:v.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:v==null?void 0:v.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:v==null?void 0:v.description})]}),(v==null?void 0:v.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:v.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:g.map((j,N)=>e.jsx("button",{onClick:()=>l(N),className:It("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: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})]})]})},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?"}),b?e.jsxs(Z,{size:"lg",onClick:f,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(un,{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(ZBe,{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 Ips({open:t,onOpenChange:s,openHouse:r}){const n=YBe(),{user:a}=Qs(),o=M.useRef(null),[l,i]=M.useState(r.auto_forward_to_card??!1),[d,u]=M.useState(r.disclosure_pdf_url??""),[f,g]=M.useState(!1),[v,_]=M.useState(!1),b=async N=>{var F;const S=(F=N.target.files)==null?void 0:F[0];if(!S||!a)return;if(S.size>20*1024*1024){dn({title:"File must be under 20MB",variant:"destructive"});return}if(S.type!=="application/pdf"){dn({title:"Only PDF files are accepted",variant:"destructive"});return}g(!0);const A=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:I}=await K.storage.from("open-house-photos").upload(A,S,{upsert:!0});if(I){dn({title:"Upload failed",description:I.message,variant:"destructive"}),g(!1);return}const{data:L}=K.storage.from("open-house-photos").getPublicUrl(A);u(L.publicUrl),g(!1),dn({title:"PDF uploaded!"})},w=()=>{u(""),o.current&&(o.current.value="")},j=async()=>{_(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:d||null}),dn({title:"Settings saved!"}),s(!1)}catch{dn({title:"Failed to save",variant:"destructive"})}finally{_(!1)}};return e.jsx(bs,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Guest Book Settings"}),e.jsx(Kr,{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(_e,{className:"text-sm font-medium",children:"Auto-forward to Digital Card"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"After check-in, redirect visitors to your digital business card"})]}),e.jsx(qr,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{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:b,className:"hidden"}),d?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(Un,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:w,children:e.jsx(Vr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var N;return(N=o.current)==null?void 0:N.click()},disabled:f,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:f?e.jsx(Rs,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(Z,{onClick:j,disabled:v,className:"w-full",children:v?"Saving...":"Save Settings"})]})]})})}const p0e="guestbook.relevelup.com";function Lps(){const{data:t,isLoading:s}=p0t(),r=g0t(),n=YBe(),a=x0t(),[o,l]=M.useState(!1),[i,d]=M.useState(null),{user:u}=Qs(),[f,g]=M.useState(null),[v,_]=M.useState(null),[b,w]=M.useState(!1),j=M.useRef(null),[N,S]=M.useState({property_address:"",city:"",state:"",zip:"",event_date:js(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),A=$=>{var H;const q=(H=$.target.files)==null?void 0:H[0];if(q){if(q.size>5*1024*1024){dn({title:"Photo must be under 5MB",variant:"destructive"});return}g(q),_(URL.createObjectURL(q))}},I=()=>{g(null),_(null),j.current&&(j.current.value="")},L=async()=>{if(!N.property_address){dn({title:N.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let $;if(f&&u){w(!0);const q=f.name.split(".").pop(),H=`${u.id}/${Date.now()}.${q}`,{error:U}=await K.storage.from("open-house-photos").upload(H,f,{upsert:!0});if(U){dn({title:"Photo upload failed",description:U.message,variant:"destructive"}),w(!1);return}const{data:Q}=K.storage.from("open-house-photos").getPublicUrl(H);$=Q.publicUrl,w(!1)}await r.mutateAsync({...N,photo_url:$}),l(!1),S({property_address:"",city:"",state:"",zip:"",event_date:js(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I()},F=$=>{navigator.clipboard.writeText(`https://${p0e}/${$}`),dn({title:"Link copied!"})};return e.jsxs(Ms,{title:"Guest Book",children:[e.jsx(Gh,{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(bs,{open:o,onOpenChange:l,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Create Open House"}),e.jsx(Kr,{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:()=>S($=>({...$,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${N.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:()=>S($=>({...$,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${N.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(_e,{children:N.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(Re,{value:N.property_address,onChange:$=>S(q=>({...q,property_address:$.target.value})),placeholder:N.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(_e,{children:"City"}),e.jsx(Re,{value:N.city,onChange:$=>S(q=>({...q,city:$.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"State"}),e.jsx(Re,{value:N.state,onChange:$=>S(q=>({...q,state:$.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"ZIP"}),e.jsx(Re,{value:N.zip,onChange:$=>S(q=>({...q,zip:$.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Date"}),e.jsx(Re,{type:"date",value:N.event_date,onChange:$=>S(q=>({...q,event_date:$.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Start Time"}),e.jsx(Re,{type:"time",value:N.start_time,onChange:$=>S(q=>({...q,start_time:$.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"End Time"}),e.jsx(Re,{type:"time",value:N.end_time,onChange:$=>S(q=>({...q,end_time:$.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Welcome Message"}),e.jsx(Lr,{value:N.agent_greeting,onChange:$=>S(q=>({...q,agent_greeting:$.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:N.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:j,type:"file",accept:"image/*",onChange:A,className:"hidden"}),v?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:v,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:I,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Vr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var $;return($=j.current)==null?void 0:$.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(_0,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",N.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(Z,{onClick:L,disabled:r.isPending||b,className:"w-full",children:b?"Uploading photo...":r.isPending?"Creating...":N.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map($=>e.jsx(De,{className:"animate-pulse",children:e.jsxs($t,{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"})]})},$))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map($=>e.jsx(Dps,{openHouse:$,isExpanded:i===$.id,onToggle:()=>d(i===$.id?null:$.id),onCopyLink:()=>F($.slug||""),onToggleActive:()=>n.mutate({id:$.id,is_active:!$.is_active}),onDelete:()=>a.mutate($.id)},$.id))}):e.jsx(De,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(eN,{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(Z,{onClick:()=>l(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function Dps({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=f0t(s?t.id:void 0),[i,d]=M.useState(!1),[u,f]=M.useState(!1),[g,v]=M.useState(!1),_=M.useRef(null),b=`https://${p0e}/${t.slug}`,w=I=>{if(!I)return"";const[L,F]=I.split(":"),$=parseInt(L),q=$>=12?"PM":"AM";return`${$>12?$-12:$||12}:${F} ${q}`},j=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],L=l.map(U=>[U.first_name,U.last_name||"",U.email||"",U.phone||"",U.visitor_intent||"",U.wants_market_updates?"Yes":"No",(U.message||"").replace(/"/g,'""'),js(new Date(U.created_at),"MM/dd/yyyy h:mm a")]),F=[I,...L].map(U=>U.map(Q=>`"${Q}"`).join(",")).join(` `),$=new Blob([F],{type:"text/csv"}),q=URL.createObjectURL($),H=document.createElement("a");H.href=q,H.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,H.click(),URL.revokeObjectURL(q)},N=M.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),F=document.createElement("canvas");F.width=1024,F.height=1024;const $=F.getContext("2d"),q=new Image;q.onload=()=>{$==null||$.drawImage(q,0,0,1024,1024);const H=document.createElement("a");H.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,H.href=F.toDataURL("image/png"),H.click()},q.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L)))},[t.property_address]),S=M.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),F="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L))),$=js(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),q=t.start_time?`${w(t.start_time)}${t.end_time?" – "+w(t.end_time):""}`:"",H=[t.city,t.state].filter(Boolean).join(", "),U=t.agent_greeting||"Welcome! Please sign in below.",Q=window.open("","_blank");Q&&(Q.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${H?`
${H}${t.zip?" "+t.zip:""}
`:""}
Date
${$}
${q?`
Time
${q}
`:""}
${U}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),Q.document.close(),setTimeout(()=>{Q.focus(),Q.print()},500))},[t,b]),A=async()=>{v(!0);try{const{error:I}=await K.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;dn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){dn({title:"Failed to send",description:I.message,variant:"destructive"})}finally{v(!1)}};return e.jsxs(De,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx($t,{className:"pb-3",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.jsx(Vt,{className:"text-base truncate",children:t.property_address}),t.event_type==="community"&&e.jsxs(nt,{variant:"outline",className:"shrink-0 gap-1",children:[e.jsx(_a,{className:"h-3 w-3"}),"Community"]}),e.jsx(nt,{variant:t.is_active?"default":"secondary",className:"shrink-0",children:t.is_active?"Active":"Inactive"})]}),e.jsxs(_r,{className:"flex flex-wrap items-center gap-3 text-xs",children:[t.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pi,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),js(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(Tn,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` - ${w(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(xr,{className:"h-3 w-3"}),t.visitor_count," visitors"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(Z,{variant:"ghost",size:"icon",onClick:n,title:"Copy link",children:e.jsx(Ni,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>d(!0),title:"QR Code",children:e.jsx(eN,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>f(!0),title:"Settings",children:e.jsx(Pl,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>window.open(b,"_blank"),title:"Preview",children:e.jsx(un,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:a,title:t.is_active?"Deactivate":"Activate",children:t.is_active?e.jsx(Nm,{className:"h-4 w-4"}):e.jsx(Na,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:o,title:"Delete",children:e.jsx(Cr,{className:"h-4 w-4 text-destructive"})}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:r,children:s?e.jsx(Tg,{className:"h-4 w-4"}):e.jsx(tl,{className:"h-4 w-4"})})]})]})}),s&&e.jsxs(Oe,{className:"pt-0",children:[e.jsx(Jl,{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://",p0e,"/",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(Z,{variant:"outline",size:"sm",onClick:j,className:"h-7 text-xs gap-1",children:[e.jsx(Ei,{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(nt,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:js(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!"})]}),e.jsx(bs,{open:i,onOpenChange:d,children:e.jsxs(_s,{className:"sm:max-w-sm",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"QR Code"}),e.jsx(Kr,{className:"truncate",children:t.property_address})]}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx("div",{ref:_,className:"bg-white p-4 rounded-xl",children:e.jsx(Zwe,{value:b,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:b}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(Z,{variant:"outline",className:"flex-1",onClick:N,children:[e.jsx(Ei,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(Z,{variant:"outline",className:"flex-1",onClick:S,children:[e.jsx(lP,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(Z,{variant:"default",className:"w-full",onClick:A,disabled:g,children:[e.jsx(Ar,{className:"h-4 w-4 mr-2"}),g?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(Ips,{open:u,onOpenChange:f,openHouse:t})]})}const Ops=O_({first_name:Ko().trim().min(1,"First name is required").max(50),last_name:Ko().trim().max(50).optional(),email:Ko().trim().email("Please enter a valid email").max(255).optional().or(c3("")),phone:Ko().trim().max(20).optional().or(c3(""))}),Rps=[{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 Fps(){var H;const{slug:t}=Uo(),{data:s,isLoading:r,error:n}=XBe(t),a=QBe(),[o,l]=M.useState("welcome"),[i,d]=M.useState({first_name:"",last_name:"",email:"",phone:""}),[u,f]=M.useState(""),[g,v]=M.useState(!1),[_,b]=M.useState(!1),[w,j]=M.useState(""),[N,S]=M.useState(""),A=U=>{if(!U)return"";const[Q,se]=U.split(":"),te=parseInt(Q),Y=te>=12?"PM":"AM";return`${te>12?te-12:te||12}:${se} ${Y}`},I=()=>{S("");const U=Ops.safeParse(i);if(!U.success){S(U.error.issues[0].message);return}if(!i.email&&!i.phone){S("Please provide either an email or phone number");return}l("intent")},L=async U=>{f(U);try{await a.mutateAsync({open_house_id:s.id,first_name:i.first_name.trim(),last_name:i.last_name.trim()||void 0,email:i.email.trim()||void 0,phone:i.phone.trim()||void 0,visitor_intent:U,wants_market_updates:g,has_agent:_,working_with_agent_name:_&&w.trim()?w.trim():void 0}),l("done")}catch{S("Something went wrong. Please try again.")}};if(r)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(n||!s)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(Hn,{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 F=s.profiles,$=((H=F==null?void 0:F.name)==null?void 0:H.split(" ").map(U=>U[0]).join("").slice(0,2))||"?",q=s.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(Gh,{children:[e.jsxs("title",{children:[q?"Community Event":"Open House"," | ",s.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${q?"community event":"open house"} at ${s.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(mn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(ba,{src:(F==null?void 0:F.avatar_url)||"",alt:(F==null?void 0:F.name)||""}),e.jsx(pn,{className:"bg-white/10 text-white text-lg",children:$})]}),e.jsx("p",{className:"text-white/60 text-sm",children:F==null?void 0:F.name}),(F==null?void 0:F.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:F.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[s.photo_url&&e.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[e.jsx("img",{src:s.photo_url,alt:s.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:s.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[s.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pi,{className:"h-3 w-3"}),s.city,s.state?`, ${s.state}`:""," ",s.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),js(new Date(s.event_date+"T00:00:00"),"MMM d, yyyy")]}),s.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),A(s.start_time),s.end_time?` – ${A(s.end_time)}`:""]})]})]})]}),!s.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:q?e.jsx(_a,{className:"h-5 w-5 text-white"}):e.jsx(Hn,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:s.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[s.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pi,{className:"h-3 w-3"}),s.city,s.state?`, ${s.state}`:""," ",s.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),js(new Date(s.event_date+"T00:00:00"),"MMM d, yyyy")]}),s.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),A(s.start_time),s.end_time?` – ${A(s.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[o==="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:s.agent_greeting||"Please sign in below."})]}),e.jsxs(Z,{onClick:()=>l("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(Ai,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),o==="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:()=>l("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ba,{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(_e,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Re,{value:i.first_name,onChange:U=>d(Q=>({...Q,first_name:U.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Re,{value:i.last_name,onChange:U=>d(Q=>({...Q,last_name:U.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Re,{type:"email",value:i.email,onChange:U=>d(Q=>({...Q,email:U.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Re,{type:"tel",value:i.phone,onChange:U=>d(Q=>({...Q,phone:U.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:g,onChange:U=>v(U.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:_?"Yes":"No"}),e.jsx(qr,{checked:_,onCheckedChange:b})]})]}),_&&e.jsx(Re,{value:w,onChange:U=>j(U.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),N&&e.jsx("p",{className:"text-destructive text-sm",children:N}),e.jsxs(Z,{onClick:I,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Ai,{className:"h-5 w-5 ml-2"})]})]}),o==="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:()=>l("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ba,{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:Rps.map(U=>e.jsxs("button",{onClick:()=>L(U.value),disabled:a.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:U.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:U.label})]},U.value))}),N&&e.jsx("p",{className:"text-destructive text-sm text-center",children:N})]}),o==="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(Ma,{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, ",i.first_name,". ",q?"Enjoy the event!":"Enjoy the open house!"]})]}),(F==null?void 0:F.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:F.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function zps(){const{slug:t}=Uo();return t?e.jsx(N9e,{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 dQe({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Qs(),l=XN(),i=M.useRef(null),d=M.useRef(null),[u,f]=M.useState(!1),[g,v]=M.useState(!1),[_,b]=M.useState(0),w=async N=>{if(o){f(!0);try{const S=N.name.split(".").pop()||"jpg",A=`${o.id}/card-${Date.now()}.${S}`,{error:I}=await K.storage.from("listing-photos").upload(A,N);if(I)throw I;const{data:{publicUrl:L}}=K.storage.from("listing-photos").getPublicUrl(A);r(L),ge.success("Photo uploaded")}catch(S){ge.error(S.message||"Failed to upload photo")}finally{f(!1)}}},j=async N=>{if(o){if(N.size>500*1024*1024){ge.error("Video must be under 500MB");return}v(!0),b(0);try{const{videoId:S,libraryId:A}=await EL(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:L}=await PL(S);await new Promise((q,H)=>{const U=new XMLHttpRequest;U.upload.addEventListener("progress",Q=>{Q.lengthComputable&&b(Math.round(Q.loaded/Q.total*100))}),U.addEventListener("load",()=>{U.status>=200&&U.status<300?q():H(new Error("Upload failed"))}),U.addEventListener("error",()=>H(new Error("Upload failed"))),U.open("PUT",I),U.setRequestHeader("AccessKey",L),U.send(N)});const F=`https://iframe.mediadelivery.net/embed/${A}/${S}`;n(F);const $=parseFloat((N.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${A}/${S}`,file_size_mb:$,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),ge.success("Video uploaded & added to your library")}catch(S){ge.error(S.message||"Failed to upload video")}finally{v(!1),b(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Media (optional)"}),e.jsxs(Ia,{defaultValue:"photo",className:"w-full",children:[e.jsxs(Aa,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ts,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(Ts,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(Vs,{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(Z,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(Vr,{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(Rs,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Mg,{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 A;const S=(A=N.target.files)==null?void 0:A[0];S&&w(S),N.target.value=""}})]}),e.jsxs(Vs,{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(Z,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(Vr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var N;return(N=d.current)==null?void 0:N.click()},disabled:g,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:g?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Rs,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",_,"%"]}),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:`${_}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a video (max 500MB)"})]})}),!s&&!g&&e.jsx("div",{className:"mt-2",children:e.jsx(Gwe,{contactId:a,onVideoReady:N=>n(N)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:N=>{var A;const S=(A=N.target.files)==null?void 0:A[0];S&&j(S),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 uQe=M.createContext({});function Bps(t){const s=M.useRef(null);return s.current===null&&(s.current=t()),s.current}const $ps=typeof window<"u",qps=$ps?M.useLayoutEffect:M.useEffect,e2e=M.createContext(null);function t2e(t,s){t.indexOf(s)===-1&&t.push(s)}function pie(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const ny=(t,s,r)=>r>s?s:r{};const w_={},hQe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function mQe(t){return typeof t=="object"&&t!==null}const pQe=t=>/^0[^.\s]+$/u.test(t);function fQe(t){let s;return()=>(s===void 0&&(s=t()),s)}const mf=t=>t,Ups=(t,s)=>r=>s(t(r)),qL=(...t)=>t.reduce(Ups),I6=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class r2e{constructor(){this.subscriptions=[]}add(s){return t2e(this.subscriptions,s),()=>pie(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,rf=t=>t/1e3;function gQe(t,s){return s?t*(1e3/s):0}const xQe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,Vps=1e-7,Hps=12;function Wps(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=xQe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>Vps&&++iWps(o,0,1,t,r);return o=>o===0||o===1?o:xQe(a(o),s,n)}const yQe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,vQe=t=>s=>1-t(1-s),_Qe=UL(.33,1.53,.69,.99),n2e=vQe(_Qe),bQe=yQe(n2e),wQe=t=>t>=1?1:(t*=2)<1?.5*n2e(t):.5*(2-Math.pow(2,-10*(t-1))),a2e=t=>1-Math.sin(Math.acos(t)),jQe=vQe(a2e),kQe=yQe(a2e),Gps=UL(.42,0,1,1),Kps=UL(0,0,.58,1),NQe=UL(.42,0,.58,1),Zps=t=>Array.isArray(t)&&typeof t[0]!="number",SQe=t=>Array.isArray(t)&&typeof t[0]=="number",Yps={linear:mf,easeIn:Gps,easeInOut:NQe,easeOut:Kps,circIn:a2e,circInOut:kQe,circOut:jQe,backIn:n2e,backInOut:bQe,backOut:_Qe,anticipate:wQe},Xps=t=>typeof t=="string",S6e=t=>{if(SQe(t)){s2e(t.length===4);const[s,r,n,a]=t;return UL(s,r,n,a)}else if(Xps(t))return Yps[t];return t},uR=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Qps(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 d(f){l.has(f)&&(u.schedule(f),t()),f(i)}const u={schedule:(f,g=!1,v=!1)=>{const b=v&&a?r:n;return g&&l.add(f),b.add(f),f},cancel:f=>{n.delete(f),l.delete(f)},process:f=>{if(i=f,a){o=!0;return}a=!0;const g=r;r=n,n=g,r.forEach(d),r.clear(),a=!1,o&&(o=!1,u.process(f))}};return u}const Jps=40;function CQe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=uR.reduce((A,I)=>(A[I]=Qps(o),A),{}),{setup:i,read:d,resolveKeyframes:u,preUpdate:f,update:g,preRender:v,render:_,postRender:b}=l,w=()=>{const A=w_.useManualTiming,I=A?a.timestamp:performance.now();r=!1,A||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,Jps),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),d.process(a),u.process(a),f.process(a),g.process(a),v.process(a),_.process(a),b.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(w))},j=()=>{r=!0,n=!0,a.isProcessing||t(w)};return{schedule:uR.reduce((A,I)=>{const L=l[I];return A[I]=(F,$=!1,q=!1)=>(r||j(),L.schedule(F,$,q)),A},{}),cancel:A=>{for(let I=0;I(ire===void 0&&Eh.set(Nu.isProcessing||w_.useManualTiming?Nu.timestamp:performance.now()),ire),set:t=>{ire=t,queueMicrotask(efs)}},MQe=t=>s=>typeof s=="string"&&s.startsWith(t),TQe=MQe("--"),tfs=MQe("var(--"),i2e=t=>tfs(t)?sfs.test(t.split("/*")[0].trim()):!1,sfs=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function C6e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const EM={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},L6={...EM,transform:t=>ny(0,1,t)},hR={...EM,default:1},JP=t=>Math.round(t*1e5)/1e5,o2e=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function rfs(t){return t==null}const nfs=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,l2e=(t,s)=>r=>!!(typeof r=="string"&&nfs.test(r)&&r.startsWith(t)||s&&!rfs(r)&&Object.prototype.hasOwnProperty.call(r,s)),AQe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(o2e);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},afs=t=>ny(0,255,t),ape={...EM,transform:t=>Math.round(afs(t))},Tk={test:l2e("rgb","red"),parse:AQe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+ape.transform(t)+", "+ape.transform(s)+", "+ape.transform(r)+", "+JP(L6.transform(n))+")"};function ifs(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 f0e={test:l2e("#"),parse:ifs,transform:Tk.transform},VL=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),Gv=VL("deg"),Yx=VL("%"),Xn=VL("px"),ofs=VL("vh"),lfs=VL("vw"),M6e={...Yx,parse:t=>Yx.parse(t)/100,transform:t=>Yx.transform(t*100)},O4={test:l2e("hsl","hue"),parse:AQe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+Yx.transform(JP(s))+", "+Yx.transform(JP(r))+", "+JP(L6.transform(n))+")"},yd={test:t=>Tk.test(t)||f0e.test(t)||O4.test(t),parse:t=>Tk.test(t)?Tk.parse(t):O4.test(t)?O4.parse(t):f0e.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Tk.transform(t):O4.transform(t),getAnimatableNone:t=>{const s=yd.parse(t);return s.alpha=0,yd.transform(s)}},cfs=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function dfs(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(o2e))==null?void 0:s.length)||0)+(((r=t.match(cfs))==null?void 0:r.length)||0)>0}const EQe="number",PQe="color",ufs="var",hfs="var(",T6e="${}",mfs=/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 V3(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(mfs,d=>(yd.test(d)?(n.color.push(o),a.push(PQe),r.push(yd.parse(d))):d.startsWith(hfs)?(n.var.push(o),a.push(ufs),r.push(d)):(n.number.push(o),a.push(EQe),r.push(parseFloat(d))),++o,T6e)).split(T6e);return{values:r,split:i,indexes:n,types:a}}function pfs(t){return V3(t).values}function IQe({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,xfs=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:gfs(t);function yfs(t){const s=V3(t);return IQe(s)(s.values.map((n,a)=>xfs(n,s.split[a])))}const Dg={test:dfs,parse:pfs,createTransformer:ffs,getAnimatableNone:yfs};function ipe(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 vfs({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,d=2*r-i;a=ipe(d,i,t+1/3),o=ipe(d,i,t),l=ipe(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function fie(t,s){return r=>r>0?s:t}const Hl=(t,s,r)=>t+(s-t)*r,ope=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},_fs=[f0e,Tk,O4],bfs=t=>_fs.find(s=>s.test(t));function A6e(t){const s=bfs(t);if(!s)return!1;let r=s.parse(t);return s===O4&&(r=vfs(r)),r}const E6e=(t,s)=>{const r=A6e(t),n=A6e(s);if(!r||!n)return fie(t,s);const a={...r};return o=>(a.red=ope(r.red,n.red,o),a.green=ope(r.green,n.green,o),a.blue=ope(r.blue,n.blue,o),a.alpha=Hl(r.alpha,n.alpha,o),Tk.transform(a))},g0e=new Set(["none","hidden"]);function wfs(t,s){return g0e.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function jfs(t,s){return r=>Hl(t,s,r)}function c2e(t){return typeof t=="number"?jfs:typeof t=="string"?i2e(t)?fie:yd.test(t)?E6e:Sfs:Array.isArray(t)?LQe:typeof t=="object"?yd.test(t)?E6e:kfs:fie}function LQe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>c2e(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function Nfs(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=Dg.createTransformer(s),n=V3(t),a=V3(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?g0e.has(t)&&!a.values.length||g0e.has(s)&&!n.values.length?wfs(t,s):qL(LQe(Nfs(n,a),a.values),r):fie(t,s)};function DQe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?Hl(t,s,r):c2e(t)(t,s)}const Cfs=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>fl.update(s,r),stop:()=>j_(s),now:()=>Nu.isProcessing?Nu.timestamp:Eh.now()}},OQe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=gie?1/0:s}function Mfs(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(d2e(n),gie);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:rf(a)}}const Ic={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 x0e(t,s){return t*Math.sqrt(1-s*s)}const Tfs=12;function Afs(t,s,r){let n=r;for(let a=1;a{const f=u*l,g=f*t,v=f-r,_=x0e(u,l),b=Math.exp(-g);return lpe-v/_*b},o=u=>{const g=u*l*t,v=g*r+r,_=Math.pow(l,2)*Math.pow(u,2)*t,b=Math.exp(-g),w=x0e(Math.pow(u,2),l);return(-a(u)+lpe>0?-1:1)*((v-_)*b)/w}):(a=u=>{const f=Math.exp(-u*t),g=(u-r)*t+1;return-lpe+f*g},o=u=>{const f=Math.exp(-u*t),g=(r-u)*(t*t);return f*g});const i=5/t,d=Afs(a,o,i);if(t=vp(t),isNaN(d))return{stiffness:Ic.stiffness,damping:Ic.damping,duration:t};{const u=Math.pow(d,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const Pfs=["duration","bounce"],Ifs=["stiffness","damping","mass"];function P6e(t,s){return s.some(r=>t[r]!==void 0)}function Lfs(t){let s={velocity:Ic.velocity,stiffness:Ic.stiffness,damping:Ic.damping,mass:Ic.mass,isResolvedFromDuration:!1,...t};if(!P6e(t,Ifs)&&P6e(t,Pfs))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*ny(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:Ic.mass,stiffness:a,damping:o}}else{const r=Efs({...t,velocity:0});s={...s,...r,mass:Ic.mass},s.isResolvedFromDuration=!0}return s}function xie(t=Ic.visualDuration,s=Ic.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:d,damping:u,mass:f,duration:g,velocity:v,isResolvedFromDuration:_}=Lfs({...r,velocity:-rf(r.velocity||0)}),b=v||0,w=u/(2*Math.sqrt(d*f)),j=l-o,N=rf(Math.sqrt(d/f)),S=Math.abs(j)<5;n||(n=S?Ic.restSpeed.granular:Ic.restSpeed.default),a||(a=S?Ic.restDelta.granular:Ic.restDelta.default);let A,I,L,F,$,q;if(w<1)L=x0e(N,w),F=(b+w*N*j)/L,A=U=>{const Q=Math.exp(-w*N*U);return l-Q*(F*Math.sin(L*U)+j*Math.cos(L*U))},$=w*N*F+j*L,q=w*N*j-F*L,I=U=>Math.exp(-w*N*U)*($*Math.sin(L*U)+q*Math.cos(L*U));else if(w===1){A=Q=>l-Math.exp(-N*Q)*(j+(b+N*j)*Q);const U=b+N*j;I=Q=>Math.exp(-N*Q)*(N*U*Q-b)}else{const U=N*Math.sqrt(w*w-1);A=Y=>{const ce=Math.exp(-w*N*Y),oe=Math.min(U*Y,300);return l-ce*((b+w*N*j)*Math.sinh(oe)+U*j*Math.cosh(oe))/U};const Q=(b+w*N*j)/U,se=w*N*Q-j*U,te=w*N*j-Q*U;I=Y=>{const ce=Math.exp(-w*N*Y),oe=Math.min(U*Y,300);return ce*(se*Math.sinh(oe)+te*Math.cosh(oe))}}const H={calculatedDuration:_&&g||null,velocity:U=>vp(I(U)),next:U=>{if(!_&&w<1){const se=Math.exp(-w*N*U),te=Math.sin(L*U),Y=Math.cos(L*U),ce=l-se*(F*te+j*Y),oe=vp(se*($*te+q*Y));return i.done=Math.abs(oe)<=n&&Math.abs(l-ce)<=a,i.value=i.done?l:ce,i}const Q=A(U);if(_)i.done=U>=g;else{const se=vp(I(U));i.done=Math.abs(se)<=n&&Math.abs(l-Q)<=a}return i.value=i.done?l:Q,i},toString:()=>{const U=Math.min(d2e(H),gie),Q=OQe(se=>H.next(U*se).value,U,30);return U+"ms "+Q},toTransition:()=>{}};return H}xie.applyToOptions=t=>{const s=Mfs(t,100,xie);return t.ease=s.ease,t.duration=vp(s.duration),t.type="keyframes",t};const Dfs=5;function RQe(t,s,r){const n=Math.max(s-Dfs,0);return gQe(r-t(n),s-n)}function y0e({keyframes:t,velocity:s=0,power:r=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:d,restDelta:u=.5,restSpeed:f}){const g=t[0],v={done:!1,value:g},_=q=>i!==void 0&&qd,b=q=>i===void 0?d:d===void 0||Math.abs(i-q)-w*Math.exp(-q/n),A=q=>N+S(q),I=q=>{const H=S(q),U=A(q);v.done=Math.abs(H)<=u,v.value=v.done?N:U};let L,F;const $=q=>{_(v.value)&&(L=q,F=xie({keyframes:[v.value,b(v.value)],velocity:RQe(A,q,v.value),damping:a,stiffness:o,restDelta:u,restSpeed:f}))};return $(0),{calculatedDuration:null,next:q=>{let H=!1;return!F&&L===void 0&&(H=!0,I(q),$(q)),L!==void 0&&q>=L?F.next(q-L):(!H&&I(q),v)}}}function Ofs(t,s,r){const n=[],a=r||w_.mix||DQe,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=Ofs(s,n,a),d=i.length,u=f=>{if(l&&f1)for(;gu(ny(t[0],t[o-1],f)):u}function Ffs(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=I6(0,s,n);t.push(Hl(r,1,a))}}function zfs(t){const s=[0];return Ffs(s,t.length-1),s}function Bfs(t,s){return t.map(r=>r*s)}function $fs(t,s){return t.map(()=>s||NQe).splice(0,t.length-1)}function eI({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=Zps(n)?n.map(S6e):S6e(n),o={done:!1,value:s[0]},l=Bfs(r&&r.length===s.length?r:zfs(s),t),i=Rfs(l,s,{ease:Array.isArray(a)?a:$fs(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const qfs=t=>t!==null;function yce(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(qfs),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const Ufs={decay:y0e,inertia:y0e,tween:eI,keyframes:eI,spring:xie};function FQe(t){typeof t.type=="string"&&(t.type=Ufs[t.type])}class u2e{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 Vfs=t=>t/100;class yie extends u2e{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!==Eh.now()&&this.tick(Eh.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;FQe(s);const{type:r=eI,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const d=r||eI;d!==eI&&typeof i[0]!="number"&&(this.mixKeyframes=qL(Vfs,DQe(i[0],i[1])),i=[0,100]);const u=d({...s,keyframes:i});o==="mirror"&&(this.mirroredGenerator=d({...s,keyframes:[...i].reverse(),velocity:-l})),u.calculatedDuration===null&&(u.calculatedDuration=d2e(u));const{calculatedDuration:f}=u;this.calculatedDuration=f,this.resolvedDuration=f+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:d}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:f,repeat:g,repeatType:v,repeatDelay:_,type:b,onUpdate:w,finalKeyframe:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const N=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?N<0:N>a;this.currentTime=Math.max(N,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let A=this.currentTime,I=n;if(g){const q=Math.min(this.currentTime,a)/i;let H=Math.floor(q),U=q%1;!U&&q>=1&&(U=1),U===1&&H--,H=Math.min(H,g+1),!!(H%2)&&(v==="reverse"?(U=1-U,_&&(U-=_/i)):v==="mirror"&&(I=l)),A=ny(0,1,U)*i}let L;S?(this.delayState.value=f[0],L=this.delayState):L=I.next(A),o&&!S&&(L.value=o(L.value));let{done:F}=L;!S&&d!==null&&(F=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&F);return $&&b!==y0e&&(L.value=yce(f,this.options,j,this.speed)),w&&w(L.value),$&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return rf(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+rf(s)}get time(){return rf(this.currentTime)}set time(s){s=vp(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 RQe(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(Eh.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=rf(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=Cfs,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(Eh.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 Hfs(t){for(let s=1;st*180/Math.PI,v0e=t=>{const s=Ak(Math.atan2(t[1],t[0]));return _0e(s)},Wfs={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:v0e,rotateZ:v0e,skewX:t=>Ak(Math.atan(t[1])),skewY:t=>Ak(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},_0e=t=>(t=t%360,t<0&&(t+=360),t),I6e=v0e,L6e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),D6e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Gfs={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=>_0e(Ak(Math.atan2(t[6],t[5]))),rotateY:t=>_0e(Ak(Math.atan2(-t[2],t[0]))),rotateZ:I6e,rotate:I6e,skewX:t=>Ak(Math.atan(t[4])),skewY:t=>Ak(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function b0e(t){return t.includes("scale")?1:0}function w0e(t,s){if(!t||t==="none")return b0e(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=Gfs,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=Wfs,a=i}if(!a)return b0e(s);const o=n[s],l=a[1].split(",").map(Zfs);return typeof o=="function"?o(l):l[o]}const Kfs=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return w0e(r,s)};function Zfs(t){return parseFloat(t.trim())}const PM=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],IM=new Set(PM),O6e=t=>t===EM||t===Xn,Yfs=new Set(["x","y","z"]),Xfs=PM.filter(t=>!Yfs.has(t));function Qfs(t){const s=[];return Xfs.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const I1={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})=>w0e(s,"x"),y:(t,{transform:s})=>w0e(s,"y")};I1.translateX=I1.x;I1.translateY=I1.y;const hN=new Set;let j0e=!1,k0e=!1,N0e=!1;function zQe(){if(k0e){const t=Array.from(hN).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=Qfs(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)})}k0e=!1,j0e=!1,hN.forEach(t=>t.complete(N0e)),hN.clear()}function BQe(){hN.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(k0e=!0)})}function Jfs(){N0e=!0,BQe(),zQe(),N0e=!1}class h2e{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?(hN.add(this),j0e||(j0e=!0,fl.read(BQe),fl.resolveKeyframes(zQe))):(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])}Hfs(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),hN.delete(this)}cancel(){this.state==="scheduled"&&(hN.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const egs=t=>t.startsWith("--");function $Qe(t,s,r){egs(s)?t.style.setProperty(s,r):t.style[s]=r}const tgs={};function qQe(t,s){const r=fQe(t);return()=>tgs[s]??r()}const sgs=qQe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),UQe=qQe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),kE=([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:kE([0,.65,.55,1]),circOut:kE([.55,0,1,.45]),backIn:kE([.31,.01,.66,-.59]),backOut:kE([.33,1.53,.69,.99])};function VQe(t,s){if(t)return typeof t=="function"?UQe()?OQe(t,s):"ease-out":SQe(t)?kE(t):Array.isArray(t)?t.map(r=>VQe(r,s)||R6e.easeOut):R6e[t]}function rgs(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:d}={},u=void 0){const f={[s]:r};d&&(f.offset=d);const g=VQe(i,a);Array.isArray(g)&&(f.easing=g);const v={delay:n,duration:a,easing:Array.isArray(g)?"linear":g,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(v.pseudoElement=u),t.animate(f,v)}function HQe(t){return typeof t=="function"&&"applyToOptions"in t}function ngs({type:t,...s}){return HQe(t)&&UQe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class WQe extends u2e{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:d}=s;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=s,s2e(typeof s.type!="string");const u=ngs(s);this.animation=rgs(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const f=yce(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(f),$Qe(r,n,f),this.animation.cancel()}d==null||d(),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 rf(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+rf(s)}get time(){return rf(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=vp(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&&sgs()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),mf):a(this)}}const GQe={anticipate:wQe,backInOut:bQe,circInOut:kQe};function ags(t){return t in GQe}function igs(t){typeof t.ease=="string"&&ags(t.ease)&&(t.ease=GQe[t.ease])}const cpe=10;class ogs extends WQe{constructor(s){igs(s),FQe(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 yie({...l,autoplay:!1}),d=Math.max(cpe,Eh.now()-this.startTime),u=ny(0,cpe,d-cpe),f=i.sample(d).value,{name:g}=this.options;o&&g&&$Qe(o,g,f),r.setWithVelocity(i.sample(Math.max(0,d-u)).value,f,u),i.stop()}}const F6e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Dg.test(t)||t==="0")&&!t.startsWith("url("));function lgs(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function pgs(t){var g;const{motionValue:s,name:r,repeatDelay:n,repeatType:a,damping:o,type:l,keyframes:i}=t;if(!(((g=s==null?void 0:s.owner)==null?void 0:g.current)instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:f}=s.owner.getProps();return mgs()&&r&&(KQe.has(r)||hgs.has(r)&&ugs(i))&&(r!=="transform"||!f)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const fgs=40;class ggs extends u2e{constructor({autoplay:s=!0,delay:r=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:d,motionValue:u,element:f,...g}){var b;super(),this.stop=()=>{var w,j;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(j=this.keyframeResolver)==null||j.cancel()},this.createdAt=Eh.now();const v={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:u,element:f,...g},_=(f==null?void 0:f.KeyframeResolver)||h2e;this.keyframeResolver=new _(i,(w,j,N)=>this.onKeyframesResolved(w,j,v,!N),d,u,f),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var N,S;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:u,onUpdate:f}=n;this.resolvedAt=Eh.now();let g=!0;cgs(s,o,l,i)||(g=!1,(w_.instantAnimations||!d)&&(f==null||f(yce(s,n,r))),s[0]=s[s.length-1],S0e(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>fgs?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=g&&!u&&pgs(_),w=(S=(N=_.motionValue)==null?void 0:N.owner)==null?void 0:S.current;let j;if(b)try{j=new ogs({..._,element:w})}catch{j=new yie(_)}else j=new yie(_);j.finished.then(()=>{this.notifyFinished()}).catch(mf),this.pendingTimeline&&(this.stopTimeline=j.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=j}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),Jfs()),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 ZQe(t,s,r,n=0,a=1){const o=Array.from(t).sort((u,f)=>u.sortNodePosition(f)).indexOf(s),l=t.size,i=(l-1)*n;return typeof r=="function"?r(o,l):a===1?o*n:i-o*n}const xgs=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ygs(t){const s=xgs.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function YQe(t,s,r=1){const[n,a]=ygs(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return hQe(l)?parseFloat(l):l}return i2e(a)?YQe(a,s,r+1):a}const vgs={type:"spring",stiffness:500,damping:25,restSpeed:10},_gs=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),bgs={type:"keyframes",duration:.8},wgs={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},jgs=(t,{keyframes:s})=>s.length>2?bgs:IM.has(t)?t.startsWith("scale")?_gs(s[1]):vgs:wgs;function XQe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function m2e(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?XQe(r,t):r}const kgs=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function Ngs(t){for(const s in t)if(!kgs.has(s))return!0;return!1}const p2e=(t,s,r,n={},a,o)=>l=>{const i=m2e(n,t)||{},d=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-vp(d);const f={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:v=>{s.set(v),i.onUpdate&&i.onUpdate(v)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};Ngs(i)||Object.assign(f,jgs(t,f)),f.duration&&(f.duration=vp(f.duration)),f.repeatDelay&&(f.repeatDelay=vp(f.repeatDelay)),f.from!==void 0&&(f.keyframes[0]=f.from);let g=!1;if((f.type===!1||f.duration===0&&!f.repeatDelay)&&(S0e(f),f.delay===0&&(g=!0)),(w_.instantAnimations||w_.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(g=!0,S0e(f),f.delay=0),f.allowFlatten=!i.type&&!i.ease,g&&!o&&s.get()!==void 0){const v=yce(f.keyframes,i);if(v!==void 0){fl.update(()=>{f.onUpdate(v),f.onComplete()});return}}return i.isSync?new yie(f):new ggs(f)};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 f2e(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 mN(t,s,r){const n=t.getProps();return f2e(n,s,r!==void 0?r:n.custom,t)}const QQe=new Set(["width","height","top","left","right","bottom",...PM]),B6e=30,Sgs=t=>!isNaN(parseFloat(t));class Cgs{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=Eh.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=Eh.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=Sgs(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 r2e);const n=this.events[s].add(r);return s==="change"?()=>{n(),fl.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=Eh.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>B6e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,B6e);return gQe(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 H3(t,s){return new Cgs(t,s)}const C0e=t=>Array.isArray(t);function Mgs(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,H3(r))}function Tgs(t){return C0e(t)?t[t.length-1]||0:t}function Ags(t,s){const r=mN(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=Tgs(o[l]);Mgs(t,l,i)}}const Au=t=>!!(t&&t.getVelocity);function Egs(t){return!!(Au(t)&&t.add)}function M0e(t,s){const r=t.getValue("willChange");if(Egs(r))return r.add(s);if(!r&&w_.WillChange){const n=new w_.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function g2e(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const Pgs="framerAppearId",JQe="data-"+g2e(Pgs);function eJe(t){return t.props[JQe]}function Igs({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function tJe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const d=t.getDefaultTransition();o=o?XQe(o,d):d;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const f=[],g=a&&t.animationState&&t.animationState.getState()[a];for(const v in i){const _=t.getValue(v,t.latestValues[v]??null),b=i[v];if(b===void 0||g&&Igs(g,v))continue;const w={delay:r,...m2e(o||{},v)},j=_.get();if(j!==void 0&&!_.isAnimating()&&!Array.isArray(b)&&b===j&&!w.velocity){fl.update(()=>_.set(b));continue}let N=!1;if(window.MotionHandoffAnimation){const I=eJe(t);if(I){const L=window.MotionHandoffAnimation(I,v,fl);L!==null&&(w.startTime=L,N=!0)}}M0e(t,v);const S=u??t.shouldReduceMotion;_.start(p2e(v,_,b,S&&QQe.has(v)?{type:!1}:w,t,N));const A=_.animation;A&&f.push(A)}if(l){const v=()=>fl.update(()=>{l&&Ags(t,l)});f.length?Promise.all(f).then(v):v()}return f}function T0e(t,s,r={}){var d;const n=mN(t,s,r.type==="exit"?(d=t.presenceContext)==null?void 0:d.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(a=r.transitionOverride);const o=n?()=>Promise.all(tJe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:f=0,staggerChildren:g,staggerDirection:v}=a;return Lgs(t,s,u,f,g,v,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[u,f]=i==="beforeChildren"?[o,l]:[l,o];return u().then(()=>f())}else return Promise.all([o(),l(r.delay)])}function Lgs(t,s,r=0,n=0,a=0,o=1,l){const i=[];for(const d of t.variantChildren)d.notify("AnimationStart",s),i.push(T0e(d,s,{...l,delay:r+(typeof n=="function"?0:n)+ZQe(t.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",s)));return Promise.all(i)}function Dgs(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>T0e(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=T0e(t,s,r);else{const a=typeof s=="function"?mN(t,s,r.custom):s;n=Promise.all(tJe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const Ogs={test:t=>t==="auto",parse:t=>t},sJe=t=>s=>s.test(t),rJe=[EM,Xn,Yx,Gv,lfs,ofs,Ogs],$6e=t=>rJe.find(sJe(t));function Rgs(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||pQe(t):!0}const Fgs=new Set(["brightness","contrast","saturate","opacity"]);function zgs(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(o2e)||[];if(!n)return t;const a=r.replace(n,"");let o=Fgs.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const Bgs=/\b([a-z-]*)\(.*?\)/gu,A0e={...Dg,getAnimatableNone:t=>{const s=t.match(Bgs);return s?s.map(zgs).join(" "):t}},E0e={...Dg,getAnimatableNone:t=>{const s=Dg.parse(t);return Dg.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},q6e={...EM,transform:Math.round},$gs={rotate:Gv,rotateX:Gv,rotateY:Gv,rotateZ:Gv,scale:hR,scaleX:hR,scaleY:hR,scaleZ:hR,skew:Gv,skewX:Gv,skewY:Gv,distance:Xn,translateX:Xn,translateY:Xn,translateZ:Xn,x:Xn,y:Xn,z:Xn,perspective:Xn,transformPerspective:Xn,opacity:L6,originX:M6e,originY:M6e,originZ:Xn},x2e={borderWidth:Xn,borderTopWidth:Xn,borderRightWidth:Xn,borderBottomWidth:Xn,borderLeftWidth:Xn,borderRadius:Xn,borderTopLeftRadius:Xn,borderTopRightRadius:Xn,borderBottomRightRadius:Xn,borderBottomLeftRadius:Xn,width:Xn,maxWidth:Xn,height:Xn,maxHeight:Xn,top:Xn,right:Xn,bottom:Xn,left:Xn,inset:Xn,insetBlock:Xn,insetBlockStart:Xn,insetBlockEnd:Xn,insetInline:Xn,insetInlineStart:Xn,insetInlineEnd:Xn,padding:Xn,paddingTop:Xn,paddingRight:Xn,paddingBottom:Xn,paddingLeft:Xn,paddingBlock:Xn,paddingBlockStart:Xn,paddingBlockEnd:Xn,paddingInline:Xn,paddingInlineStart:Xn,paddingInlineEnd:Xn,margin:Xn,marginTop:Xn,marginRight:Xn,marginBottom:Xn,marginLeft:Xn,marginBlock:Xn,marginBlockStart:Xn,marginBlockEnd:Xn,marginInline:Xn,marginInlineStart:Xn,marginInlineEnd:Xn,fontSize:Xn,backgroundPositionX:Xn,backgroundPositionY:Xn,...$gs,zIndex:q6e,fillOpacity:L6,strokeOpacity:L6,numOctaves:q6e},qgs={...x2e,color:yd,backgroundColor:yd,outlineColor:yd,fill:yd,stroke:yd,borderColor:yd,borderTopColor:yd,borderRightColor:yd,borderBottomColor:yd,borderLeftColor:yd,filter:A0e,WebkitFilter:A0e,mask:E0e,WebkitMask:E0e},nJe=t=>qgs[t],Ugs=new Set([A0e,E0e]);function aJe(t,s){let r=nJe(t);return Ugs.has(r)||(r=Dg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const Vgs=new Set(["auto","none","0"]);function Hgs(t,s,r){let n=0,a;for(;n{s.getValue(d).set(u)}),this.resolveNoneKeyframes()}}function iJe(t,s,r){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let n=document;const a=(r==null?void 0:r[t])??n.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t).filter(n=>n!=null)}const oJe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function Ggs(t){return mQe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:y2e}=CQe(queueMicrotask,!1),og={x:!1,y:!1};function lJe(){return og.x||og.y}function Kgs(t){return t==="x"||t==="y"?og[t]?null:(og[t]=!0,()=>{og[t]=!1}):og.x||og.y?null:(og.x=og.y=!0,()=>{og.x=og.y=!1})}function cJe(t,s){const r=iJe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function Zgs(t){return!(t.pointerType==="touch"||lJe())}function Ygs(t,s,r={}){const[n,a,o]=cJe(t,r);return n.forEach(l=>{let i=!1,d=!1,u;const f=()=>{l.removeEventListener("pointerleave",b)},g=j=>{u&&(u(j),u=void 0),f()},v=j=>{i=!1,window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),d&&(d=!1,g(j))},_=()=>{i=!0,window.addEventListener("pointerup",v,a),window.addEventListener("pointercancel",v,a)},b=j=>{if(j.pointerType!=="touch"){if(i){d=!0;return}g(j)}},w=j=>{if(!Zgs(j))return;d=!1;const N=s(l,j);typeof N=="function"&&(u=N,l.addEventListener("pointerleave",b,a))};l.addEventListener("pointerenter",w,a),l.addEventListener("pointerdown",_,a)}),o}const dJe=(t,s)=>s?t===s?!0:dJe(t,s.parentElement):!1,v2e=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Xgs=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Qgs(t){return Xgs.has(t.tagName)||t.isContentEditable===!0}const Jgs=new Set(["INPUT","SELECT","TEXTAREA"]);function exs(t){return Jgs.has(t.tagName)||t.isContentEditable===!0}const ore=new WeakSet;function U6e(t){return s=>{s.key==="Enter"&&t(s)}}function dpe(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const txs=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=U6e(()=>{if(ore.has(r))return;dpe(r,"down");const a=U6e(()=>{dpe(r,"up")}),o=()=>dpe(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 v2e(t)&&!lJe()}const H6e=new WeakSet;function sxs(t,s,r={}){const[n,a,o]=cJe(t,r),l=i=>{const d=i.currentTarget;if(!V6e(i)||H6e.has(i))return;ore.add(d),r.stopPropagation&&H6e.add(i);const u=s(d,i),f=(_,b)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",v),ore.has(d)&&ore.delete(d),V6e(_)&&typeof u=="function"&&u(_,{success:b})},g=_=>{f(_,d===window||d===document||r.useGlobalTarget||dJe(d,_.target))},v=_=>{f(_,!1)};window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",v,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),Ggs(i)&&(i.addEventListener("focus",u=>txs(u,a)),!Qgs(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function _2e(t){return mQe(t)&&"ownerSVGElement"in t}const lre=new WeakMap;let Kv;const uJe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:_2e(n)&&"getBBox"in n?n.getBBox()[s]:n[r],rxs=uJe("inline","width","offsetWidth"),nxs=uJe("block","height","offsetHeight");function axs({target:t,borderBoxSize:s}){var r;(r=lre.get(t))==null||r.forEach(n=>{n(t,{get width(){return rxs(t,s)},get height(){return nxs(t,s)}})})}function ixs(t){t.forEach(axs)}function oxs(){typeof ResizeObserver>"u"||(Kv=new ResizeObserver(ixs))}function lxs(t,s){Kv||oxs();const r=iJe(t);return r.forEach(n=>{let a=lre.get(n);a||(a=new Set,lre.set(n,a)),a.add(s),Kv==null||Kv.observe(n)}),()=>{r.forEach(n=>{const a=lre.get(n);a==null||a.delete(s),a!=null&&a.size||Kv==null||Kv.unobserve(n)})}}const cre=new Set;let R4;function cxs(){R4=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};cre.forEach(s=>s(t))},window.addEventListener("resize",R4)}function dxs(t){return cre.add(t),R4||cxs(),()=>{cre.delete(t),!cre.size&&typeof R4=="function"&&(window.removeEventListener("resize",R4),R4=void 0)}}function W6e(t,s){return typeof t=="function"?dxs(t):lxs(t,s)}function uxs(t){return _2e(t)&&t.tagName==="svg"}const hxs=[...rJe,yd,Dg],mxs=t=>hxs.find(sJe(t)),G6e=()=>({translate:0,scale:1,origin:0,originPoint:0}),F4=()=>({x:G6e(),y:G6e()}),K6e=()=>({min:0,max:0}),Ad=()=>({x:K6e(),y:K6e()}),pxs=new WeakMap;function vce(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function D6(t){return typeof t=="string"||Array.isArray(t)}const b2e=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],w2e=["initial",...b2e];function _ce(t){return vce(t.animate)||w2e.some(s=>D6(t[s]))}function hJe(t){return!!(_ce(t)||t.variants)}function fxs(t,s,r){for(const n in s){const a=s[n],o=r[n];if(Au(a))t.addValue(n,a);else if(Au(o))t.addValue(n,H3(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,H3(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const P0e={current:null},mJe={current:!1},gxs=typeof window<"u";function xxs(){if(mJe.current=!0,!!gxs)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>P0e.current=t.matches;t.addEventListener("change",s),s()}else P0e.current=!1}const Z6e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let vie={};function pJe(t){vie=t}function yxs(){return vie}class vxs{scrapeMotionValuesFromProps(s,r,n){return{}}constructor({parent:s,props:r,presenceContext:n,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:i},d={}){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=h2e,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 _=Eh.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,fl.render(this.render,!1,!0))};const{latestValues:u,renderState:f}=i;this.latestValues=u,this.baseTarget={...u},this.initialValues=r.initial?{...u}:{},this.renderState=f,this.parent=s,this.props=r,this.presenceContext=n,this.depth=s?s.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=d,this.blockInitialAnimation=!!l,this.isControllingVariants=_ce(r),this.isVariantNode=hJe(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:g,...v}=this.scrapeMotionValuesFromProps(r,{},this);for(const _ in v){const b=v[_];u[_]!==void 0&&Au(b)&&b.set(u[_])}}mount(s){var r,n;if(this.hasBeenMounted)for(const a in this.initialValues)(r=this.values.get(a))==null||r.jump(this.initialValues[a]),this.latestValues[a]=this.initialValues[a];this.current=s,pxs.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,o)=>this.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(mJe.current||xxs(),this.shouldReduceMotion=P0e.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(),j_(this.notifyUpdate),j_(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&&KQe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:u,duration:f}=r.accelerate,g=new WQe({element:this.current,name:s,keyframes:i,times:d,ease:u,duration:vp(f)}),v=l(g);this.valueSubscriptions.set(s,()=>{v(),g.cancel()});return}const n=IM.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&fl.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 vie){const r=vie[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):Ad()}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=H3(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"&&(hQe(n)||pQe(n))?n=parseFloat(n):!mxs(n)&&Dg.test(r)&&(n=aJe(s,r)),this.setBaseTarget(s,Au(n)?n.get():n)),Au(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=f2e(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&&!Au(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 r2e),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){y2e.render(this.render)}}class fJe extends vxs{constructor(){super(...arguments),this.KeyframeResolver=Wgs}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;Au(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class W_{constructor(s){this.isMounted=!1,this.node=s}update(){}}function gJe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function _xs({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function bxs(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 upe(t){return t===void 0||t===1}function I0e({scale:t,scaleX:s,scaleY:r}){return!upe(t)||!upe(s)||!upe(r)}function ck(t){return I0e(t)||xJe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function xJe(t){return Y6e(t.x)||Y6e(t.y)}function Y6e(t){return t&&t!=="0%"}function _ie(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=_ie(t,a,n)),_ie(t,r,n)+s}function L0e(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 yJe(t,{x:s,y:r}){L0e(t.x,s.translate,s.scale,s.originPoint),L0e(t.y,r.translate,r.scale,r.originPoint)}const Q6e=.999999999999,J6e=1.0000000000001;function wxs(t,s,r,n=!1){var i;const a=r.length;if(!a)return;s.x=s.y=1;let o,l;for(let d=0;dQ6e&&(s.x=1),s.yQ6e&&(s.y=1)}function Mx(t,s){t.min+=s,t.max+=s}function eLe(t,s,r,n,a=.5){const o=Hl(t.min,t.max,a);L0e(t,s,r,o,n)}function tLe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function dre(t,s,r){const n=r??t;eLe(t.x,tLe(s.x,n.x),s.scaleX,s.scale,s.originX),eLe(t.y,tLe(s.y,n.y),s.scaleY,s.scale,s.originY)}function vJe(t,s){return gJe(bxs(t.getBoundingClientRect(),s))}function jxs(t,s,r){const n=vJe(t,r),{scroll:a}=s;return a&&(Mx(n.x,a.offset.x),Mx(n.y,a.offset.y)),n}const kxs={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Nxs=PM.length;function Sxs(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(Xn.test(t))t=parseFloat(t);else return t;const r=sLe(t,s.target.x),n=sLe(t,s.target.y);return`${r}% ${n}%`}},Cxs={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=Dg.parse(t);if(a.length>5)return n;const o=Dg.createTransformer(t),l=typeof a[0]!="number"?1:0,i=r.x.scale*s.x,d=r.y.scale*s.y;a[0+l]/=i,a[1+l]/=d;const u=Hl(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},D0e={borderRadius:{...iE,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:iE,borderTopRightRadius:iE,borderBottomLeftRadius:iE,borderBottomRightRadius:iE,boxShadow:Cxs};function bJe(t,{layout:s,layoutId:r}){return IM.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!D0e[t]||t==="opacity")}function k2e(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)(Au(n[i])||a&&Au(a[i])||bJe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function Mxs(t){return window.getComputedStyle(t)}class Txs extends fJe{constructor(){super(...arguments),this.type="html",this.renderInstance=_Je}readValueFromInstance(s,r){var n;if(IM.has(r))return(n=this.projection)!=null&&n.isProjecting?b0e(r):Kfs(s,r);{const a=Mxs(s),o=(TQe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return vJe(s,r)}build(s,r,n){j2e(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return k2e(s,r,n)}}const Axs={offset:"stroke-dashoffset",array:"stroke-dasharray"},Exs={offset:"strokeDashoffset",array:"strokeDasharray"};function Pxs(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?Axs:Exs;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const Ixs=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function wJe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,u,f){if(j2e(t,i,u),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:g,style:v}=t;g.transform&&(v.transform=g.transform,delete g.transform),(v.transform||g.transformOrigin)&&(v.transformOrigin=g.transformOrigin??"50% 50%",delete g.transformOrigin),v.transform&&(v.transformBox=(f==null?void 0:f.transformBox)??"fill-box",delete g.transformBox);for(const _ of Ixs)g[_]!==void 0&&(v[_]=g[_],delete g[_]);s!==void 0&&(g.x=s),r!==void 0&&(g.y=r),n!==void 0&&(g.scale=n),a!==void 0&&Pxs(g,a,o,l,!1)}const jJe=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"]),kJe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Lxs(t,s,r,n){_Je(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(jJe.has(a)?a:g2e(a),s.attrs[a])}function NJe(t,s,r){const n=k2e(t,s,r);for(const a in t)if(Au(t[a])||Au(s[a])){const o=PM.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class Dxs extends fJe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Ad}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(IM.has(r)){const n=nJe(r);return n&&n.default||0}return r=jJe.has(r)?r:g2e(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return NJe(s,r,n)}build(s,r,n){wJe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){Lxs(s,r,n,a)}mount(s){this.isSVGTag=kJe(s.tagName),super.mount(s)}}const Oxs=w2e.length;function SJe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?SJe(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})=>Dgs(t,r,n)))}function Bxs(t){let s=zxs(t),r=rLe(),n=!0,a=!1;const o=u=>(f,g)=>{var _;const v=mN(t,g,u==="exit"?(_=t.presenceContext)==null?void 0:_.custom:void 0);if(v){const{transition:b,transitionEnd:w,...j}=v;f={...f,...j,...w}}return f};function l(u){s=u(t)}function i(u){const{props:f}=t,g=SJe(t.parent)||{},v=[],_=new Set;let b={},w=1/0;for(let N=0;Nw&&L,U=!1;const Q=Array.isArray(I)?I:[I];let se=Q.reduce(o(S),{});F===!1&&(se={});const{prevResolvedValues:te={}}=A,Y={...te,...se},ce=de=>{H=!0,_.has(de)&&(U=!0,_.delete(de)),A.needsAnimating[de]=!0;const xe=t.getValue(de);xe&&(xe.liveStyle=!1)};for(const de in Y){const xe=se[de],be=te[de];if(b.hasOwnProperty(de))continue;let ye=!1;C0e(xe)&&C0e(be)?ye=!CJe(xe,be):ye=xe!==be,ye?xe!=null?ce(de):_.add(de):xe!==void 0&&_.has(de)?ce(de):A.protectedKeys[de]=!0}A.prevProp=I,A.prevResolvedValues=se,A.isActive&&(b={...b,...se}),(n||a)&&t.blockInitialAnimation&&(H=!1);const oe=$&&q;H&&(!oe||U)&&v.push(...Q.map(de=>{const xe={type:S};if(typeof de=="string"&&(n||a)&&!oe&&t.manuallyAnimateOnMount&&t.parent){const{parent:be}=t,ye=mN(be,de);if(be.enteringChildren&&ye){const{delayChildren:ve}=ye.transition||{};xe.delay=ZQe(be.enteringChildren,t,ve)}}return{animation:de,options:xe}}))}if(_.size){const N={};if(typeof f.initial!="boolean"){const S=mN(t,Array.isArray(f.initial)?f.initial[0]:f.initial);S&&S.transition&&(N.transition=S.transition)}_.forEach(S=>{const A=t.getBaseTarget(S),I=t.getValue(S);I&&(I.liveStyle=!0),N[S]=A??null}),v.push({animation:N})}let j=!!v.length;return n&&(f.initial===!1||f.initial===f.animate)&&!t.manuallyAnimateOnMount&&(j=!1),n=!1,a=!1,j?s(v):Promise.resolve()}function d(u,f){var v;if(r[u].isActive===f)return Promise.resolve();(v=t.variantChildren)==null||v.forEach(_=>{var b;return(b=_.animationState)==null?void 0:b.setActive(u,f)}),r[u].isActive=f;const g=i(u);for(const _ in r)r[_].protectedKeys={};return g}return{animateChanges:i,setActive:d,setAnimateFunction:l,getState:()=>r,reset:()=>{r=rLe(),a=!0}}}function $xs(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!CJe(s,t):!1}function Vb(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function rLe(){return{animate:Vb(!0),whileInView:Vb(),whileHover:Vb(),whileTap:Vb(),whileDrag:Vb(),whileFocus:Vb(),exit:Vb()}}function O0e(t,s){t.min=s.min,t.max=s.max}function sg(t,s){O0e(t.x,s.x),O0e(t.y,s.y)}function nLe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const MJe=1e-4,qxs=1-MJe,Uxs=1+MJe,TJe=.01,Vxs=0-TJe,Hxs=0+TJe;function Ph(t){return t.max-t.min}function Wxs(t,s,r){return Math.abs(t-s)<=r}function aLe(t,s,r,n=.5){t.origin=n,t.originPoint=Hl(s.min,s.max,t.origin),t.scale=Ph(r)/Ph(s),t.translate=Hl(r.min,r.max,t.origin)-t.originPoint,(t.scale>=qxs&&t.scale<=Uxs||isNaN(t.scale))&&(t.scale=1),(t.translate>=Vxs&&t.translate<=Hxs||isNaN(t.translate))&&(t.translate=0)}function tI(t,s,r,n){aLe(t.x,s.x,r.x,n?n.originX:void 0),aLe(t.y,s.y,r.y,n?n.originY:void 0)}function iLe(t,s,r,n=0){const a=n?Hl(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+Ph(s)}function Gxs(t,s,r,n){iLe(t.x,s.x,r.x,n==null?void 0:n.x),iLe(t.y,s.y,r.y,n==null?void 0:n.y)}function oLe(t,s,r,n=0){const a=n?Hl(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+Ph(s)}function bie(t,s,r,n){oLe(t.x,s.x,r.x,n==null?void 0:n.x),oLe(t.y,s.y,r.y,n==null?void 0:n.y)}function lLe(t,s,r,n,a){return t-=s,t=_ie(t,1/r,n),a!==void 0&&(t=_ie(t,1/a,n)),t}function Kxs(t,s=0,r=1,n=.5,a,o=t,l=t){if(Yx.test(s)&&(s=parseFloat(s),s=Hl(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=Hl(o.min,o.max,n);t===o&&(i-=s),t.min=lLe(t.min,s,r,i,a),t.max=lLe(t.max,s,r,i,a)}function cLe(t,s,[r,n,a],o,l){Kxs(t,s[r],s[n],s[a],s.scale,o,l)}const Zxs=["x","scaleX","originX"],Yxs=["y","scaleY","originY"];function dLe(t,s,r,n){cLe(t.x,s,Zxs,r?r.x:void 0,n?n.x:void 0),cLe(t.y,s,Yxs,r?r.y:void 0,n?n.y:void 0)}function uLe(t){return t.translate===0&&t.scale===1}function AJe(t){return uLe(t.x)&&uLe(t.y)}function hLe(t,s){return t.min===s.min&&t.max===s.max}function Xxs(t,s){return hLe(t.x,s.x)&&hLe(t.y,s.y)}function mLe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function EJe(t,s){return mLe(t.x,s.x)&&mLe(t.y,s.y)}function pLe(t){return Ph(t.x)/Ph(t.y)}function fLe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function jx(t){return[t("x"),t("y")]}function Qxs(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:f,rotateX:g,rotateY:v,skewX:_,skewY:b}=r;u&&(n=`perspective(${u}px) ${n}`),f&&(n+=`rotate(${f}deg) `),g&&(n+=`rotateX(${g}deg) `),v&&(n+=`rotateY(${v}deg) `),_&&(n+=`skewX(${_}deg) `),b&&(n+=`skewY(${b}deg) `)}const i=t.x.scale*s.x,d=t.y.scale*s.y;return(i!==1||d!==1)&&(n+=`scale(${i}, ${d})`),n||"none"}const PJe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Jxs=PJe.length,gLe=t=>typeof t=="string"?parseFloat(t):t,xLe=t=>typeof t=="number"||Xn.test(t);function eys(t,s,r,n,a,o){a?(t.opacity=Hl(0,r.opacity??1,tys(n)),t.opacityExit=Hl(s.opacity??1,0,sys(n))):o&&(t.opacity=Hl(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(I6(t,s,n))}function rys(t,s,r){const n=Au(t)?t:H3(t);return n.start(p2e("",n,s,r)),n.animation}function O6(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const nys=(t,s)=>t.depth-s.depth;class ays{constructor(){this.children=[],this.isDirty=!1}add(s){t2e(this.children,s),this.isDirty=!0}remove(s){pie(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(nys),this.isDirty=!1,this.children.forEach(s)}}function iys(t,s){const r=Eh.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(j_(n),t(o-s))};return fl.setup(n,!0),()=>j_(n)}function ure(t){return Au(t)?t.get():t}class oys{constructor(){this.members=[]}add(s){t2e(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&&(pie(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(pie(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 hre={hasAnimatedSinceResize:!0,hasEverUpdated:!1},hpe=["","X","Y","Z"],lys=1e3;let cys=0;function mpe(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function LJe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=eJe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",fl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&LJe(n)}function DJe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=cys++,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(hys),this.nodes.forEach(yys),this.nodes.forEach(vys),this.nodes.forEach(mys)},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 d=0;dthis.root.updateBlockedByResize=!1;fl.read(()=>{g=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==g&&(g=_,this.root.updateBlockedByResize=!0,f&&f(),f=iys(v,250),hre.hasAnimatedSinceResize&&(hre.hasAnimatedSinceResize=!1,this.nodes.forEach(bLe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||d)&&this.addEventListener("didUpdate",({delta:f,hasLayoutChanged:g,hasRelativeLayoutChanged:v,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||u.getDefaultTransition()||kys,{onLayoutAnimationStart:w,onLayoutAnimationComplete:j}=u.getProps(),N=!this.targetLayout||!EJe(this.targetLayout,_),S=!g&&v;if(this.options.layoutRoot||this.resumeFrom||S||g&&(N||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const A={...m2e(b,"layout"),onPlay:w,onComplete:j};(u.shouldReduceMotion||this.options.layoutRoot)&&(A.delay=0,A.type=!1),this.startAnimation(A),this.setAnimationOrigin(f,S)}else g||bLe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=_})}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(),j_(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(_ys),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&&LJe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let f=0;f{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ph(this.snapshot.measuredBox.x)&&!Ph(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 d=0;d{const L=I/1e3;wLe(g.x,l.x,L),wLe(g.y,l.y,L),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(bie(v,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),wys(this.relativeTarget,this.relativeTargetOrigin,v,L),A&&Xxs(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=Ad()),sg(A,this.relativeTarget)),w&&(this.animationValues=f,eys(f,u,this.latestValues,L,S,N)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,d,u;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(u=(d=this.resumingFrom)==null?void 0:d.currentAnimation)==null||u.stop(),this.pendingAnimation&&(j_(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=fl.update(()=>{hre.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=H3(0)),this.motionValue.jump(0,!1),this.currentAnimation=rys(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:f=>{this.mixTargetDelta(f),l.onUpdate&&l.onUpdate(f)},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(lys),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:d,layout:u,latestValues:f}=l;if(!(!i||!d||!u)){if(this!==l&&this.layout&&u&&OJe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){d=this.target||Ad();const g=Ph(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const v=Ph(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+v}sg(i,d),dre(i,f),tI(this.projectionDeltaWithTransform,this.layoutCorrected,i,f)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new oys),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:d}={}){const u=this.getStack();u&&u.promote(this,d),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:d}=l;if((d.z||d.rotate||d.rotateX||d.rotateY||d.rotateZ||d.skewX||d.skewY)&&(i=!0),!i)return;const u={};d.z&&mpe("z",l,u,this.animationValues);for(let f=0;f{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(vLe),this.root.sharedNodes.clear()}}}function dys(t){t.updateLayout()}function uys(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")jx(g=>{const v=l?s.measuredBox[g]:s.layoutBox[g],_=Ph(v);v.min=n[g].min,v.max=v.min+_});else if(o==="x"||o==="y"){const g=o==="x"?"y":"x";O0e(l?s.measuredBox[g]:s.layoutBox[g],n[g])}else OJe(o,s.layoutBox,n)&&jx(g=>{const v=l?s.measuredBox[g]:s.layoutBox[g],_=Ph(n[g]);v.max=v.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[g].max=t.relativeTarget[g].min+_)});const i=F4();tI(i,n,s.layoutBox);const d=F4();l?tI(d,t.applyTransform(a,!0),s.measuredBox):tI(d,n,s.layoutBox);const u=!AJe(i);let f=!1;if(!t.resumeFrom){const g=t.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:v,layout:_}=g;if(v&&_){const b=t.options.layoutAnchor||void 0,w=Ad();bie(w,s.layoutBox,v.layoutBox,b);const j=Ad();bie(j,n,_.layoutBox,b),EJe(w,j)||(f=!0),g.options.layoutRoot&&(t.relativeTarget=j,t.relativeTargetOrigin=w,t.relativeParent=g)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:d,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:f})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function hys(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 mys(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function pys(t){t.clearSnapshot()}function vLe(t){t.clearMeasurements()}function fys(t){t.isLayoutDirty=!0,t.updateLayout()}function _Le(t){t.isLayoutDirty=!1}function gys(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function xys(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function bLe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function yys(t){t.resolveTargetDelta()}function vys(t){t.calcProjection()}function _ys(t){t.resetSkewAndRotation()}function bys(t){t.removeLeadSnapshot()}function wLe(t,s,r){t.translate=Hl(s.translate,0,r),t.scale=Hl(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function jLe(t,s,r,n){t.min=Hl(s.min,r.min,n),t.max=Hl(s.max,r.max,n)}function wys(t,s,r,n){jLe(t.x,s.x,r.x,n),jLe(t.y,s.y,r.y,n)}function jys(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const kys={duration:.45,ease:[.4,0,.1,1]},kLe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),NLe=kLe("applewebkit/")&&!kLe("chrome/")?Math.round:mf;function SLe(t){t.min=NLe(t.min),t.max=NLe(t.max)}function Nys(t){SLe(t.x),SLe(t.y)}function OJe(t,s,r){return t==="position"||t==="preserve-aspect"&&!Wxs(pLe(s),pLe(r),.2)}function Sys(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const Cys=DJe({attachResizeListener:(t,s)=>O6(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}),ppe={current:void 0},RJe=DJe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!ppe.current){const t=new Cys({});t.mount(window),t.setOptions({layoutScroll:!0}),ppe.current=t}return ppe.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),FJe=M.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Mys(t=!0){const s=M.useContext(e2e);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=M.useId();M.useEffect(()=>{if(t)return a(o)},[t]);const l=M.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const zJe=M.createContext({strict:!1}),CLe={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 MLe=!1;function Tys(){if(MLe)return;const t={};for(const s in CLe)t[s]={isEnabled:r=>CLe[s].some(n=>!!r[n])};pJe(t),MLe=!0}function BJe(){return Tys(),yxs()}function Ays(t){const s=BJe();for(const r in t)s[r]={...s[r],...t[r]};pJe(s)}const Eys=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 wie(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Eys.has(t)}let $Je=t=>!wie(t);function Pys(t){typeof t=="function"&&($Je=s=>s.startsWith("on")?!wie(s):t(s))}try{Pys(require("@emotion/is-prop-valid").default)}catch{}function Iys(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||Au(t[a])||($Je(a)||r===!0&&wie(a)||!s&&!wie(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const bce=M.createContext({});function Lys(t,s){if(_ce(t)){const{initial:r,animate:n}=t;return{initial:r===!1||D6(r)?r:void 0,animate:D6(n)?n:void 0}}return t.inherit!==!1?s:{}}function Dys(t){const{initial:s,animate:r}=Lys(t,M.useContext(bce));return M.useMemo(()=>({initial:s,animate:r}),[TLe(s),TLe(r)])}function TLe(t){return Array.isArray(t)?t.join(" "):t}const N2e=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function qJe(t,s,r){for(const n in s)!Au(s[n])&&!bJe(n,r)&&(t[n]=s[n])}function Oys({transformTemplate:t},s){return M.useMemo(()=>{const r=N2e();return j2e(r,s,t),Object.assign({},r.vars,r.style)},[s])}function Rys(t,s){const r=t.style||{},n={};return qJe(n,r,t),Object.assign(n,Oys(t,s)),n}function Fys(t,s){const r={},n=Rys(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 UJe=()=>({...N2e(),attrs:{}});function zys(t,s,r,n){const a=M.useMemo(()=>{const o=UJe();return wJe(o,s,kJe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};qJe(o,t.style,t),a.style={...o,...a.style}}return a}const Bys=["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 S2e(t){return typeof t!="string"||t.includes("-")?!1:!!(Bys.indexOf(t)>-1||/[A-Z]/u.test(t))}function $ys(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??S2e(t)?zys:Fys)(s,n,a,t),u=Iys(s,typeof t=="string",o),f=t!==M.Fragment?{...u,...d,ref:r}:{},{children:g}=s,v=M.useMemo(()=>Au(g)?g.get():g,[g]);return M.createElement(t,{...f,children:v})}function qys({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:Uys(r,n,a,t),renderState:s()}}function Uys(t,s,r,n){const a={},o=n(t,{});for(const v in o)a[v]=ure(o[v]);let{initial:l,animate:i}=t;const d=_ce(t),u=hJe(t);s&&u&&!d&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let f=r?r.initial===!1:!1;f=f||l===!1;const g=f?i:l;if(g&&typeof g!="boolean"&&!vce(g)){const v=Array.isArray(g)?g:[g];for(let _=0;_(s,r)=>{const n=M.useContext(bce),a=M.useContext(e2e),o=()=>qys(t,s,n,a);return r?o():Bps(o)},Vys=VJe({scrapeMotionValuesFromProps:k2e,createRenderState:N2e}),Hys=VJe({scrapeMotionValuesFromProps:NJe,createRenderState:UJe}),Wys=Symbol.for("motionComponentSymbol");function Gys(t,s,r){const n=M.useRef(r);M.useInsertionEffect(()=>{n.current=r});const a=M.useRef(null);return M.useCallback(o=>{var i;o&&((i=t.onMount)==null||i.call(t,o));const l=n.current;if(typeof l=="function")if(o){const d=l(o);typeof d=="function"&&(a.current=d)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const HJe=M.createContext({});function p4(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Kys(t,s,r,n,a,o){var A,I;const{visualElement:l}=M.useContext(bce),i=M.useContext(zJe),d=M.useContext(e2e),u=M.useContext(FJe),f=u.reducedMotion,g=u.skipAnimations,v=M.useRef(null),_=M.useRef(!1);n=n||i.renderer,!v.current&&n&&(v.current=n(t,{visualState:s,parent:l,props:r,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:f,skipAnimations:g,isSVG:o}),_.current&&v.current&&(v.current.manuallyAnimateOnMount=!0));const b=v.current,w=M.useContext(HJe);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&Zys(v.current,r,a,w);const j=M.useRef(!1);M.useInsertionEffect(()=>{b&&j.current&&b.update(r,d)});const N=r[JQe],S=M.useRef(!!N&&typeof window<"u"&&!((A=window.MotionHandoffIsComplete)!=null&&A.call(window,N))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,N)));return qps(()=>{_.current=!0,b&&(j.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),S.current&&b.animationState&&b.animationState.animateChanges())}),M.useEffect(()=>{b&&(!S.current&&b.animationState&&b.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,N)}),S.current=!1),b.enteringChildren=void 0)}),b}function Zys(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:u,layoutAnchor:f,layoutCrossfade:g}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:WJe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&p4(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:g,layoutScroll:d,layoutRoot:u,layoutAnchor:f})}function WJe(t){if(t)return t.options.allowProjection!==!1?t.projection:WJe(t.parent)}function fpe(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&Ays(n);const o=r?r==="svg":S2e(t),l=o?Hys:Vys;function i(u,f){let g;const v={...M.useContext(FJe),...u,layoutId:Yys(u)},{isStatic:_}=v,b=Dys(u),w=l(u,_);if(!_&&typeof window<"u"){Xys();const j=Qys(v);g=j.MeasureLayout,b.visualElement=Kys(t,w,v,a,j.ProjectionNode,o)}return e.jsxs(bce.Provider,{value:b,children:[g&&b.visualElement?e.jsx(g,{visualElement:b.visualElement,...v}):null,$ys(t,u,Gys(w,b.visualElement,f),w,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=M.forwardRef(i);return d[Wys]=t,d}function Yys({layoutId:t}){const s=M.useContext(uQe).id;return s&&t!==void 0?s+"-"+t:t}function Xys(t,s){M.useContext(zJe).strict}function Qys(t){const s=BJe(),{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 Jys(t,s){if(typeof Proxy>"u")return fpe;const r=new Map,n=(o,l)=>fpe(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,fpe(l,void 0,t,s)),r.get(l))})}const e0s=(t,s)=>s.isSVG??S2e(t)?new Dxs(s):new Txs(s,{allowProjection:t!==M.Fragment});class t0s extends W_{constructor(s){super(s),s.animationState||(s.animationState=Bxs(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();vce(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 s0s=0;class r0s extends W_{constructor(){super(...arguments),this.id=s0s++,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 d=mN(this.node,l,i);if(d){const{transition:u,transitionEnd:f,...g}=d;for(const v in g)(o=this.node.getValue(v))==null||o.jump(g[v])}}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 n0s={animation:{Feature:t0s},exit:{Feature:r0s}};function HL(t){return{point:{x:t.pageX,y:t.pageY}}}const a0s=t=>s=>v2e(s)&&t(s,HL(s));function sI(t,s,r,n){return O6(t,s,a0s(r),n)}const GJe=({current:t})=>t?t.ownerDocument.defaultView:null,ALe=(t,s)=>Math.abs(t-s);function i0s(t,s){const r=ALe(t.x,s.x),n=ALe(t.y,s.y);return Math.sqrt(r**2+n**2)}const ELe=new Set(["auto","scroll"]);class KJe{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=_=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=mR(this.lastRawMoveEventInfo,this.transformPagePoint));const _=gpe(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,w=i0s(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!w)return;const{point:j}=_,{timestamp:N}=Nu;this.history.push({...j,timestamp:N});const{onStart:S,onMove:A}=this.handlers;b||(S&&S(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=mR(b,this.transformPagePoint),fl.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:w,onSessionEnd:j,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=gpe(_.type==="pointercancel"?this.lastMoveEventInfo:mR(b,this.transformPagePoint),this.history);this.startEvent&&w&&w(_,S),j&&j(_,S)},!v2e(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=HL(s),u=mR(d,this.transformPagePoint),{point:f}=u,{timestamp:g}=Nu;this.history=[{...f,timestamp:g}];const{onSessionStart:v}=r;v&&v(s,gpe(u,this.history)),this.removeListeners=qL(sI(this.contextWindow,"pointermove",this.handlePointerMove),sI(this.contextWindow,"pointerup",this.handlePointerUp),sI(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(ELe.has(n.overflowX)||ELe.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),fl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),j_(this.updatePoint)}}function mR(t,s){return s?{point:s(t.point)}:t}function PLe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function gpe({point:t},s){return{point:t,delta:PLe(t,ZJe(s)),offset:PLe(t,o0s(s)),velocity:l0s(s,.1)}}function o0s(t){return t[0]}function ZJe(t){return t[t.length-1]}function l0s(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=ZJe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>vp(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>vp(s)*2&&(n=t[1]);const o=rf(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 c0s(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?Hl(r,t,n.max):Math.min(t,r)),t}function ILe(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 d0s(t,{top:s,left:r,bottom:n,right:a}){return{x:ILe(t.x,r,a),y:ILe(t.y,s,n)}}function LLe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=I6(s.min,s.max-n,t.min):n>a&&(r=I6(t.min,t.max-a,s.min)),ny(0,1,r)}function m0s(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 R0e=.35;function p0s(t=R0e){return t===!1?t=0:t===!0&&(t=R0e),{x:DLe(t,"left","right"),y:DLe(t,"top","bottom")}}function DLe(t,s,r){return{min:OLe(t,s),max:OLe(t,r)}}function OLe(t,s){return typeof t=="number"?t:t[s]||0}const f0s=new WeakMap;class g0s{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=Ad(),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=g=>{r&&this.snapToCursor(HL(g).point),this.stopAnimation()},l=(g,v)=>{const{drag:_,dragPropagation:b,onDragStart:w}=this.getProps();if(_&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Kgs(_),!this.openDragLock))return;this.latestPointerEvent=g,this.latestPanInfo=v,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),jx(N=>{let S=this.getAxisMotionValue(N).get()||0;if(Yx.test(S)){const{projection:A}=this.visualElement;if(A&&A.layout){const I=A.layout.layoutBox[N];I&&(S=Ph(I)*(parseFloat(S)/100))}}this.originPoint[N]=S}),w&&fl.update(()=>w(g,v),!1,!0),M0e(this.visualElement,"transform");const{animationState:j}=this.visualElement;j&&j.setActive("whileDrag",!0)},i=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v;const{dragPropagation:_,dragDirectionLock:b,onDirectionLock:w,onDrag:j}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:N}=v;if(b&&this.currentDirection===null){this.currentDirection=y0s(N),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",v.point,N),this.updateAxis("y",v.point,N),this.visualElement.render(),j&&fl.update(()=>j(g,v),!1,!0)},d=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v,this.stop(g,v),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:g}=this.getProps();(g||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:f}=this.getProps();this.panSession=new KJe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,distanceThreshold:n,contextWindow:GJe(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&&fl.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||!pR(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=c0s(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&&p4(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=d0s(n.layoutBox,s):this.constraints=!1,this.elastic=p0s(r),a!==this.constraints&&!p4(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&jx(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=m0s(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!p4(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=jxs(n,a.root,this.visualElement.getTransformPagePoint());let l=u0s(a.layout.layoutBox,o);if(r){const i=r(_xs(l));this.hasMutatedConstraints=!!i,i&&(l=gJe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},u=jx(f=>{if(!pR(f,r,this.currentDirection))return;let g=d&&d[f]||{};(l===!0||l===f)&&(g={min:0,max:0});const v=a?200:1e6,_=a?40:1e7,b={type:"inertia",velocity:n?s[f]:0,bounceStiffness:v,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...g};return this.startAxisValueAnimation(f,b)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return M0e(this.visualElement,s),n.start(p2e(s,n,0,r,this.visualElement,!1))}stopAnimation(){jx(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){jx(r=>{const{drag:n}=this.getProps();if(!pR(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],d=o.get()||0;o.set(s[r]-Hl(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!p4(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};jx(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=h0s({min:d,max:d},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(),jx(l=>{if(!pR(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:u}=this.constraints[l];i.set(Hl(d,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;f0s.set(this.visualElement,this);const s=this.visualElement.current,r=sI(s,"pointerdown",u=>{const{drag:f,dragListener:g=!0}=this.getProps(),v=u.target,_=v!==s&&exs(v);f&&g&&!_&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();p4(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=x0s(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),fl.read(a);const i=O6(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:f})=>{this.isDragging&&f&&(jx(g=>{const v=this.getAxisMotionValue(g);v&&(this.originPoint[g]+=u[g].translate,v.set(v.get()+u[g].translate))}),this.visualElement.render())});return()=>{i(),r(),l(),d&&d(),n&&n()}}getProps(){const s=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=R0e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function RLe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function x0s(t,s,r){const n=W6e(t,RLe(r)),a=W6e(s,RLe(r));return()=>{n(),a()}}function pR(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function y0s(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class v0s extends W_{constructor(s){super(s),this.removeGroupControls=mf,this.removeListeners=mf,this.controls=new g0s(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||mf}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 xpe=t=>(s,r)=>{t&&fl.update(()=>t(s,r),!1,!0)};class _0s extends W_{constructor(){super(...arguments),this.removePointerDownListener=mf}onPointerDown(s){this.session=new KJe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:GJe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:xpe(s),onStart:xpe(r),onMove:xpe(n),onEnd:(o,l)=>{delete this.session,a&&fl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=sI(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 ype=!1;class b0s extends M.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),ype&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),hre.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}),ype=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||fl.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(),y2e.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;ype=!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 YJe(t){const[s,r]=Mys(),n=M.useContext(uQe);return e.jsx(b0s,{...t,layoutGroup:n,switchLayoutGroup:M.useContext(HJe),isPresent:s,safeToRemove:r})}const w0s={pan:{Feature:_0s},drag:{Feature:v0s,ProjectionNode:RJe,MeasureLayout:YJe}};function FLe(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&&fl.postRender(()=>o(s,HL(s)))}class j0s extends W_{mount(){const{current:s}=this.node;s&&(this.unmount=Ygs(s,(r,n)=>(FLe(this.node,n,"Start"),a=>FLe(this.node,a,"End"))))}unmount(){}}class k0s extends W_{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=qL(O6(this.node.current,"focus",()=>this.onFocus()),O6(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function zLe(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&&fl.postRender(()=>o(s,HL(s)))}class N0s extends W_{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=sxs(s,(a,o)=>(zLe(this.node,o,"Start"),(l,{success:i})=>zLe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const F0e=new WeakMap,vpe=new WeakMap,S0s=t=>{const s=F0e.get(t.target);s&&s(t)},C0s=t=>{t.forEach(S0s)};function M0s({root:t,...s}){const r=t||document;vpe.has(r)||vpe.set(r,{});const n=vpe.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(C0s,{root:t,...s})),n[a]}function T0s(t,s,r){const n=M0s(s);return F0e.set(t,r),n.observe(t),()=>{F0e.delete(t),n.unobserve(t)}}const A0s={some:0,all:1};class E0s extends W_{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var d;(d=this.stopObserver)==null||d.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:A0s[a]},i=u=>{const{isIntersecting:f}=u;if(this.isInView===f||(this.isInView=f,o&&!f&&this.hasEnteredView))return;f&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",f);const{onViewportEnter:g,onViewportLeave:v}=this.node.getProps(),_=f?g:v;_&&_(u)};this.stopObserver=T0s(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(P0s(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function P0s({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const I0s={inView:{Feature:E0s},tap:{Feature:N0s},focus:{Feature:k0s},hover:{Feature:j0s}},L0s={layout:{ProjectionNode:RJe,MeasureLayout:YJe}},D0s={...n0s,...I0s,...w0s,...L0s},Nr=Jys(D0s,e0s),O0s=[{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 R0s({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:O0s.map((s,r)=>e.jsxs(Nr.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 LM={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 BLe({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Qs(),d=ds(),[u,f]=M.useState(!1),[g,v]=M.useState("type"),[_,b]=M.useState(""),[w,j]=M.useState(null),[N,S]=M.useState(!1),[A,I]=M.useState("home_anniversary"),[L,F]=M.useState(""),[$,q]=M.useState(""),[H,U]=M.useState(""),[Q,se]=M.useState(""),[te,Y]=M.useState("elegant"),[ce,oe]=M.useState(null),[le,de]=M.useState(null),xe=M.useState(!1);!xe[0]&&t&&s&&(xe[1](!0),f(!0),I(s),r&&j(r),n&&F(n),a&&q(a),o&&U(o),v(n?"details":"contact"));const{data:be}=Tt({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let Ve=K.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);_&&(Ve=Ve.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:dt,error:Le}=await Ve;if(Le)throw Le;return dt},enabled:!!(i!=null&&i.id)&&u}),{data:ye}=Tt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Ve,error:dt}=await K.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(dt)throw dt;return Ve},enabled:!!(i!=null&&i.id)}),ve=Ve=>{j(Ve.id),F(`${Ve.first_name}${Ve.last_name?" "+Ve.last_name:""}`),q([Ve.address,Ve.city,Ve.state].filter(Boolean).join(", ")),U(Ve.home_anniversary||""),v("details")},ke=Ve=>{I(Ve),v("contact")},Ge=async()=>{var Ve;if(!(!i||!ye)){S(!0);try{const dt={owner_user_id:i.id,contact_id:w,card_type:A,template:te,recipient_name:L,property_address:$||null,home_anniversary_date:H||null,custom_message:Q||null,property_photo_url:ce||null,video_url:le||null,agent_name:ye.name||"Agent",agent_photo_url:ye.avatar_url,agent_phone:ye.phone,agent_email:ye.email,agent_brokerage:((Ve=ye.brokerage)==null?void 0:Ve.name)||null},{error:Le}=await K.from("sendable_cards").insert(dt);if(Le)throw Le;ge.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),Ne()}catch(dt){ge.error(dt.message||"Failed to create card")}finally{S(!1)}}},Ne=()=>{f(!1),v("type"),I("home_anniversary"),b(""),j(null),F(""),q(""),U(""),se(""),Y("elegant"),oe(null),de(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"},Pe=LM[A],Fe=A==="home_anniversary",Ie=["home_anniversary","just_listed","just_sold"].includes(A);return e.jsxs(bs,{open:u,onOpenChange:Ve=>{Ve?f(!0):(Ne(),l==null||l(!1))},children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{className:"gap-2",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:g==="type"?"What type of card?":g==="contact"?`${Ae[A]} — Choose a Contact`:`${Ae[A]} — Customize`})}),g==="type"&&e.jsx(R0s,{onSelect:ke}),g==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Z,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>v("type"),children:[e.jsx(Ba,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search contacts...",value:_,onChange:Ve=>b(Ve.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[be==null?void 0:be.map(Ve=>e.jsxs("button",{onClick:()=>ve(Ve),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(mo,{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:[Ve.first_name," ",Ve.last_name]}),Ve.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Hn,{className:"h-3 w-3"}),Ve.address]})]}),Ve.home_anniversary&&A==="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"})]},Ve.id)),(be==null?void 0:be.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(Z,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{v("details")},children:"Skip — enter details manually"})})]}),g==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Z,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>v("contact"),children:[e.jsx(Ba,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Recipient Name"}),e.jsx(Re,{value:L,onChange:Ve=>F(Ve.target.value),placeholder:"John & Jane Smith"})]}),Ie&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Re,{value:$,onChange:Ve=>q(Ve.target.value),placeholder:"123 Main St, Austin, TX"})]}),Fe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Home Anniversary Date"}),e.jsx(Re,{type:"date",value:H,onChange:Ve=>U(Ve.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Personal Message (optional)"}),e.jsx(Lr,{value:Q,onChange:Ve=>se(Ve.target.value),placeholder:Pe.defaultMessage,rows:3})]}),e.jsx(dQe,{photoUrl:ce,videoUrl:le,onPhotoChange:oe,onVideoChange:de,contactId:w}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{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:Ve,label:dt,gradient:Le})=>e.jsxs("button",{onClick:()=>Y(Ve),className:`p-2 rounded-lg border-2 transition-all text-center ${te===Ve?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${Le}`}),e.jsx("span",{className:"text-[10px] font-medium",children:dt})]},Ve))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(Z,{variant:"outline",onClick:()=>v("contact"),className:"flex-1",children:"Back"}),e.jsx(Z,{onClick:Ge,disabled:!L||N,className:"flex-1 gap-2",children:N?"Creating...":"Create Card"})]})]})]})]})}const F0s={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 z0s({card:t}){const{user:s}=Qs(),{isGmailConnected:r}=G0(),n=ds(),[a,o]=M.useState(!1),[l,i]=M.useState("");M.useEffect(()=>{a&&t.contact_id&&!l&&K.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:w})=>{w!=null&&w.email&&i(w.email)})},[a,t.contact_id]);const d={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,f]=M.useState(d[t.card_type]||`A Special Card for ${t.recipient_name}!`),[g,v]=M.useState(""),_=`https://cardstudio.relevelup.com/c/${t.share_token}`,b=Bt({mutationFn:async()=>{var A;if(!l)throw new Error("Recipient email is required");const w=`
${g?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:j}=await K.auth.getSession(),N=(A=j==null?void 0:j.session)==null?void 0:A.access_token,S=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:w,contactId:t.contact_id||void 0})});if(!S.ok){const I=await S.json();throw new Error(I.error||"Failed to send")}return S.json()},onSuccess:async()=>{await K.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),ge.success(`Card sent to ${l}!`),o(!1)},onError:w=>{ge.error(w.message||"Failed to send email")}});return r?e.jsxs(bs,{open:a,onOpenChange:o,children:[e.jsx(Si,{asChild:!0,children:e.jsx(Z,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Pa,{className:"h-3 w-3"})})}),e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"To"}),e.jsx(Re,{type:"email",value:l,onChange:w=>i(w.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Subject"}),e.jsx(Re,{value:u,onChange:w=>f(w.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Personal Note (optional)"}),e.jsx(Lr,{value:g,onChange:w=>v(w.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:_})]}),e.jsx(Z,{onClick:()=>b.mutate(),disabled:!l||b.isPending,className:"w-full gap-2",children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(Z,{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(Pa,{className:"h-3 w-3"})})}function B0s({card:t}){const s=ds(),[r,n]=M.useState(!1),[a,o]=M.useState(!1),[l,i]=M.useState(t.recipient_name),[d,u]=M.useState(t.property_address||""),[f,g]=M.useState(t.home_anniversary_date||""),[v,_]=M.useState(t.custom_message||""),[b,w]=M.useState(t.template),[j,N]=M.useState(t.property_photo_url),[S,A]=M.useState(t.video_url||null),I=F=>{F&&(i(t.recipient_name),u(t.property_address||""),g(t.home_anniversary_date||""),_(t.custom_message||""),w(t.template),N(t.property_photo_url),A(t.video_url||null)),n(F)},L=async()=>{if(!l.trim()){ge.error("Recipient name is required");return}o(!0);try{const{error:F}=await K.from("sendable_cards").update({recipient_name:l.trim(),property_address:d.trim()||null,home_anniversary_date:f||null,custom_message:v.trim()||null,template:b,property_photo_url:j||null,video_url:S||null}).eq("id",t.id);if(F)throw F;s.invalidateQueries({queryKey:["sendable-cards"]}),ge.success("Card updated"),n(!1)}catch(F){ge.error(F.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(bs,{open:r,onOpenChange:I,children:[e.jsx(Si,{asChild:!0,children:e.jsx(Z,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Ga,{className:"h-3 w-3"})})}),e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Recipient Name"}),e.jsx(Re,{value:l,onChange:F=>i(F.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Re,{value:d,onChange:F=>u(F.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Home Anniversary Date"}),e.jsx(Re,{type:"date",value:f,onChange:F=>g(F.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Personal Message (optional)"}),e.jsx(Lr,{value:v,onChange:F=>_(F.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(dQe,{photoUrl:j,videoUrl:S,onPhotoChange:N,onVideoChange:A,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(F=>e.jsxs("button",{onClick:()=>w(F),className:`p-3 rounded-lg border-2 transition-all text-center ${b===F?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${F==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":F==="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:F})]},F))})]}),e.jsx(Z,{onClick:L,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function $0s(){const{user:t}=Qs(),s=ds(),[r,n]=M.useState(""),[a,o]=Gc(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),u=a.get("address"),f=a.get("date"),g=!!l,{data:v,isLoading:_}=Tt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:A,error:I}=await K.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(I)throw I;return A},enabled:!!(t!=null&&t.id)}),b=Bt({mutationFn:async A=>{const{error:I}=await K.from("sendable_cards").delete().eq("id",A);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),ge.success("Card deleted")}}),w=A=>{const I=`https://cardstudio.relevelup.com/c/${A}`;navigator.clipboard.writeText(I),ge.success("Share link copied!")},j=v==null?void 0:v.filter(A=>{var I;return!r||A.recipient_name.toLowerCase().includes(r.toLowerCase())||((I=A.property_address)==null?void 0:I.toLowerCase().includes(r.toLowerCase()))}),N={elegant:"Elegant",bold:"Bold",warm:"Warm"},S={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(Ms,{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(BLe,{initialOpen:g,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:f||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search cards...",value:r,onChange:A=>n(A.target.value),className:"pl-9"})]}),_?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(De,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},A))}):j!=null&&j.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j.map(A=>e.jsxs(De,{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 ${A.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":A.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:[A.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"})]}),A.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%)]"})]}),A.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:A.card_type==="home_anniversary"?"🏡":A.card_type==="birthday"?"🎂":A.card_type==="just_sold"?"🎉":A.card_type==="just_listed"?"🏠":A.card_type==="thank_you"?"💐":A.card_type==="congratulations"?"🏆":A.card_type==="holiday"?"🎄":A.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${A.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:S[A.card_type]||A.card_type}),e.jsx("p",{className:`font-semibold text-base ${A.template==="bold"?"text-white":"text-foreground"}`,children:A.recipient_name}),A.property_address&&e.jsx("p",{className:`text-xs mt-1 ${A.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:A.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(nt,{variant:A.template==="bold"?"outline":"secondary",className:`text-[10px] ${A.template==="bold"?"border-white/30 text-white/80":""}`,children:N[A.template]||A.template})})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Na,{className:"h-3 w-3"}),A.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:$d(new Date(A.created_at),{addSuffix:!0})})]}),A.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",js(new Date(A.sent_at),"MMM d, yyyy")," via ",A.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(Z,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>w(A.share_token),children:[e.jsx(Ni,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(B0s,{card:A}),e.jsx(z0s,{card:A}),e.jsx(Z,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${A.share_token}`,"_blank"),children:e.jsx(un,{className:"h-3 w-3"})}),e.jsx(Z,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>b.mutate(A.id),children:e.jsx(Cr,{className:"h-3 w-3"})})]})]})]},A.id))}):e.jsx(De,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Ar,{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(BLe,{initialOpen:g,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:f||void 0,onOpenChange:()=>o({})})]})})]})})}function oE({delay:t,x:s,y:r,size:n}){return e.jsx(Nr.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 q0s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:f,propertyPhotoUrl:g,videoUrl:v}=t,_=LM[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(Nr.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(Nr.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(oE,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(oE,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(oE,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(oE,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(oE,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(Nr.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(Nr.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(Nr.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(Nr.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(Nr.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:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(Nr.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(Nr.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:_.title[0]}),_.title[1]&&e.jsx(Nr.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:_.title[1]}),e.jsxs(Nr.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(Nr.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"}}),g&&e.jsx(Nr.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:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&e.jsx(Nr.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:`${v}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Nr.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||_.defaultMessage}),e.jsxs(Nr.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(Nr.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}),f&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:f})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[d&&e.jsxs(Nr.a,{href:`tel:${d}`,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(ga,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Nr.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(Ar,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Nr.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 _pe({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(Nr.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 lE({delay:t,x:s,y:r}){return e.jsx(Nr.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 $Le={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 U0s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:f,propertyPhotoUrl:g,videoUrl:v}=t,_=LM[s],b=$Le[s]||$Le.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx(_pe,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(_pe,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(_pe,{delay:2,x:"50%",y:"20%",color:b.orbs[2],size:150}),e.jsx(lE,{delay:0,x:"20%",y:"25%"}),e.jsx(lE,{delay:.8,x:"75%",y:"15%"}),e.jsx(lE,{delay:1.6,x:"85%",y:"65%"}),e.jsx(lE,{delay:2.4,x:"10%",y:"75%"}),e.jsx(lE,{delay:.4,x:"45%",y:"85%"}),e.jsxs(Nr.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(Nr.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(Nr.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(Nr.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(Nr.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:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Nr.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(Nr.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(Nr.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:_.title[0]}),_.title[1]&&e.jsx(Nr.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:_.title[1]}),e.jsx(Nr.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:_.emojis.slice(0,3).join("")}),e.jsxs(Nr.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(Hn,{className:"h-3.5 w-3.5"}),n]})]}),g&&e.jsx(Nr.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:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&e.jsx(Nr.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:`${v}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Nr.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||_.defaultMessage})}),e.jsxs(Nr.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(Nr.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}),f&&e.jsx("p",{className:"text-xs text-violet-300/60",children:f})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[d&&e.jsxs(Nr.a,{href:`tel:${d}`,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(ga,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(Nr.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(Ar,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Nr.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 V0s({emoji:t,delay:s,x:r,duration:n}){return e.jsx(Nr.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 qLe={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 H0s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:f,propertyPhotoUrl:g,videoUrl:v}=t,_=LM[s],b=qLe[s]||qLe.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[_.emojis.map((w,j)=>e.jsx(V0s,{emoji:w,delay:j*1.2,x:`${15+j*14}%`,duration:5+j%3},j)),e.jsx(Nr.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(Nr.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(Nr.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(Nr.div,{className:`h-28 bg-gradient-to-r ${b.header} relative overflow-hidden`,children:[e.jsx(Nr.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(Nr.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:_.emojis[0]}),e.jsx(Nr.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:_.emojis[1]}),e.jsx(Nr.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:_.emojis[2]})]}),e.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[e.jsx(Nr.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(Nr.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-3xl",children:_.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(Nr.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 ${b.accent}`,children:[e.jsx(Nr.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(Nr.h1,{className:`text-3xl font-bold ${b.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[_.title.join(" ")," ",_.emojis[4]]}),e.jsxs(Nr.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:`text-lg font-semibold ${b.text} mb-1`,children:r}),n&&e.jsxs("p",{className:`text-sm ${b.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[e.jsx(Pi,{className:"h-3 w-3"}),n]})]}),g&&e.jsx(Nr.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:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&e.jsx(Nr.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:`${v}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Nr.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 ${b.text} leading-relaxed italic`,children:['"',o||_.defaultMessage,'"']})}),e.jsxs(Nr.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(Nr.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 ${b.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 ${b.accent}`,children:l}),f&&e.jsx("p",{className:`text-xs ${b.text} opacity-60`,children:f})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(Nr.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(ga,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Nr.a,{href:`mailto:${u}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Ar,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Nr.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 fR({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(Nr.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 bpe({delay:t,x:s,y:r,size:n}){return e.jsx(Nr.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 ULe={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 W0s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:f,propertyPhotoUrl:g,videoUrl:v}=t,_=LM[s],b=ULe[s]||ULe.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(fR,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(fR,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(fR,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(fR,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(bpe,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(bpe,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(bpe,{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(Nr.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(Nr.div,{className:`relative rounded-[28px] overflow-hidden backdrop-blur-2xl bg-white/[0.06] border border-white/[0.12] shadow-2xl ${b.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(Nr.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(Nr.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(Nr.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(Nr.span,{className:"text-5xl",animate:{scale:[1,1.08,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Nr.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(Nr.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] ${b.accent}`,children:a===1?"Year":"Years"})]}),e.jsx(Nr.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:_.title[0]}),_.title[1]&&e.jsx(Nr.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:_.title[1]}),e.jsxs(Nr.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(Pi,{className:"h-3 w-3"})," ",n]})]}),e.jsx(Nr.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"}}),g&&e.jsx(Nr.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:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&e.jsx(Nr.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:`${v}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Nr.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||_.defaultMessage,'"']})}),e.jsxs(Nr.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(Nr.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}),f&&e.jsx("p",{className:"text-xs text-white/30",children:f})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(Nr.a,{href:`tel:${d}`,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(ga,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Nr.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(Ar,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Nr.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 wpe({delay:t,x:s,angle:r,color:n}){return e.jsx(Nr.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 gR({delay:t,x:s}){return e.jsx(Nr.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 VLe={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 G0s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:f,propertyPhotoUrl:g,videoUrl:v}=t,_=LM[s],b=VLe[s]||VLe.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${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(wpe,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(wpe,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(wpe,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(gR,{delay:0,x:"30%"}),e.jsx(gR,{delay:1.5,x:"60%"}),e.jsx(gR,{delay:3,x:"45%"}),e.jsx(gR,{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(Nr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(Nr.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(Nr.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(Nr.div,{className:`h-20 w-20 mx-auto rounded-2xl bg-gradient-to-br ${b.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:_.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Nr.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(Nr.span,{className:`text-6xl font-black bg-gradient-to-r ${b.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(Nr.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:_.title[0]})}),_.title[1]&&e.jsx("div",{className:"overflow-hidden mb-8",children:e.jsx(Nr.h2,{className:`text-5xl font-black bg-gradient-to-r ${b.accent} bg-clip-text text-transparent`,initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.95,ease:[.16,1,.3,1]},children:_.title[1]})}),e.jsxs(Nr.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(Pi,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(Nr.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(Nr.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(Nr.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(Nr.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"}})]}),g&&e.jsxs(Nr.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:g,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"})]}),v&&e.jsx(Nr.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:`${v}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Nr.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||_.defaultMessage}),e.jsxs(Nr.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(Nr.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 ${b.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}),f&&e.jsx("p",{className:"text-[11px] text-white/25",children:f})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d&&e.jsxs(Nr.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.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(ga,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Nr.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(Ar,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(Nr.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 XJe(){const{shareToken:t}=Uo(),{data:s,isLoading:r,error:n}=Tt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await K.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(M.useEffect(()=>{t&&K.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()-new Date(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(U0s,{...o});case"warm":return e.jsx(H0s,{...o});case"glass":return e.jsx(W0s,{...o});case"cinematic":return e.jsx(G0s,{...o});case"elegant":default:return e.jsx(q0s,{...o})}}function K0s(){const t=vi();return Tt({queryKey:["drip-settings",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await K.from("drip_settings").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function Z0s(){const t=vi(),s=ds();return Bt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n}=await K.from("drip_settings").select("id").eq("user_id",t).maybeSingle();if(n){const{data:a,error:o}=await K.from("drip_settings").update(r).eq("user_id",t).select().single();if(o)throw o;return a}else{const{data:a,error:o}=await K.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 Y0s(){const t=Or(),{isGmailConnected:s,gmailEmail:r}=G0(),{data:n,isLoading:a}=K0s(),o=Z0s(),[l,i]=M.useState(!1),[d,u]=M.useState(!0),[f,g]=M.useState(!1);M.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const v=async b=>{if(b&&!s){ge.error("Connect your Gmail account first before enabling Smart Drips");return}i(b);try{await o.mutateAsync({is_globally_enabled:b}),ge.success(b?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!b),ge.error("Failed to update settings")}},_=async b=>{u(b);try{await o.mutateAsync({append_signature:b}),ge.success(b?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!b),ge.error("Failed to update settings")}};return e.jsxs(bs,{open:f,onOpenChange:g,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(Z,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Pl,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Pl,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Kr,{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(Ar,{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(nt,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(Ma,{className:"h-3 w-3"}),"Active"]}):e.jsxs(Z,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{g(!1),t("/mission-control/integrations")},children:[e.jsx(un,{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(Jl,{}),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(oP,{className:`h-4 w-4 ${l?"text-emerald-600":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Enable Smart Drips"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?"Active drips will send when deals move stages":"All drips are paused — nothing will send"})]})]}),e.jsx(qr,{checked:l,onCheckedChange:v,disabled:a||o.isPending})]}),e.jsx(Jl,{}),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 ${d?"bg-primary/10":"bg-muted"}`,children:e.jsx(Cx,{className:`h-4 w-4 ${d?"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:d?"Your signature from Profile settings will be added":"Drip emails will send without a signature"})]})]}),e.jsx(qr,{checked:d,onCheckedChange:_,disabled:a||o.isPending})]}),d&&e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{g(!1),t("/profile")},children:[e.jsx(Cx,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function X0s(){const t=vi();return Tt({queryKey:["drip-templates",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.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 Q0s(){const t=vi();return Tt({queryKey:["drip-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await K.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function J0s(){const t=vi(),s=ds();return Bt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await K.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 evs(){const t=ds();return Bt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await K.from("drip_templates").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function tvs(){const t=ds();return Bt({mutationFn:async s=>{const{error:r}=await K.from("drip_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function svs(){const t=vi(),s=ds();return Bt({mutationFn:async({templateId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await K.from("drip_templates").select("*").eq("id",r).single();if(o)throw o;const{data:l,error:i}=await K.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 rvs=[{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 nvs(){const t=vi(),{data:s,isLoading:r}=X0s(),{data:n,isLoading:a}=Q0s(),o=J0s(),l=evs(),i=tvs(),d=svs(),[u,f]=M.useState(null),[g,v]=M.useState(null),_=(s==null?void 0:s.filter(L=>!L.is_starter&&L.owner_user_id===t))||[],b=(s==null?void 0:s.filter(L=>L.is_starter))||[],w=L=>_.filter(F=>F.stage_id===L),j=async L=>{try{await l.mutateAsync({id:L.id,is_enabled:!L.is_enabled}),ge.success(L.is_enabled?"Drip disabled":"Drip enabled")}catch{ge.error("Failed to update")}},N=async L=>{try{const F=n==null?void 0:n.find($=>$.id===L);await o.mutateAsync({stage_id:L,title:`${(F==null?void 0:F.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),f(L),ge.success("Drip template created")}catch{ge.error("Failed to create template")}},S=async L=>{try{await i.mutateAsync(L),ge.success("Template deleted")}catch{ge.error("Failed to delete")}},A=async L=>{if(!n||n.length===0){ge.error("No pipeline stages found");return}const F=n[0].id;try{await d.mutateAsync({templateId:L,stageId:F}),ge.success("Template copied to your drips!")}catch{ge.error("Failed to copy template")}},I=r||a;return e.jsx(Ms,{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(Tm,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(nt,{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(Y0s,{})]}),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(ZE,{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(Ia,{defaultValue:"my-drips",children:[e.jsxs(Aa,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(Ts,{value:"my-drips",children:"My Drips"}),e.jsxs(Ts,{value:"starters",children:["Starter Templates",b.length>0&&e.jsx(nt,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:b.length})]})]}),e.jsx(Vs,{value:"my-drips",children:I?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(L=>e.jsx(gs,{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(Tm,{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 F=w(L.id),$=u===L.id,q=F.some(H=>H.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>f($?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}),F.length>0&&e.jsxs(nt,{variant:"outline",className:`text-[10px] ${q?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[F.length," drip",F.length!==1?"s":"",q&&" · Active"]}),$?e.jsx(tl,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ei,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:F.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(Z,{variant:"outline",size:"sm",onClick:()=>N(L.id),disabled:o.isPending,children:[e.jsx(Ys,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[F.map(H=>e.jsx(HLe,{template:H,isEditing:g===H.id,onToggleEdit:()=>v(g===H.id?null:H.id),onToggleEnabled:()=>j(H),onUpdate:U=>l.mutateAsync({id:H.id,...U}),onDelete:()=>S(H.id),userId:t||""},H.id)),e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(L.id),children:[e.jsx(Ys,{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 F=w(L.id),$=u===L.id,q=F.some(H=>H.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>f($?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}),F.length>0&&e.jsxs(nt,{variant:"outline",className:`text-[10px] ${q?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[F.length," drip",F.length!==1?"s":"",q&&" · Active"]}),$?e.jsx(tl,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ei,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:F.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(Z,{variant:"outline",size:"sm",onClick:()=>N(L.id),disabled:o.isPending,children:[e.jsx(Ys,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[F.map(H=>e.jsx(HLe,{template:H,isEditing:g===H.id,onToggleEdit:()=>v(g===H.id?null:H.id),onToggleEnabled:()=>j(H),onUpdate:U=>l.mutateAsync({id:H.id,...U}),onDelete:()=>S(H.id),userId:t||""},H.id)),e.jsxs(Z,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(L.id),children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)})]})]})}),e.jsx(Vs,{value:"starters",children:b.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(gn,{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:b.map(L=>e.jsx(avs,{template:L,onCopy:()=>A(L.id),isCopying:d.isPending},L.id))})})]})]})})}function HLe({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,d]=M.useState(t.title),[u,f]=M.useState(t.subject),[g,v]=M.useState(t.body),[_,b]=M.useState(t.video_url||""),[w,j]=M.useState(t.channel),[N,S]=M.useState(t.delay_type),[A,I]=M.useState(t.delay_minutes),[L,F]=M.useState(!1),$=async()=>{F(!0);try{await a({title:i,subject:u,body:g,video_url:_||null,channel:w,delay_type:N,delay_minutes:A}),ge.success("Drip saved"),r()}catch{ge.error("Failed to save")}finally{F(!1)}},q=H=>{v(U=>U+H)};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(ho,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(Ar,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.delay_type==="instant"?"Sends instantly":`Sends after ${t.delay_minutes>=60?`${Math.round(t.delay_minutes/60)}h`:`${t.delay_minutes}m`}`}),t.video_url&&e.jsx(Cn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(qr,{checked:t.is_enabled,onCheckedChange:n})]}),s&&e.jsxs("div",{className:"border-t p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(Re,{value:i,onChange:H=>d(H.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(_e,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(H=>e.jsxs("button",{onClick:()=>j(H),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${w===H?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[H==="sms"?e.jsx(ho,{className:"h-3 w-3"}):e.jsx(Ar,{className:"h-3 w-3"}),H==="sms"?"SMS":"Email"]},H))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(_e,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>S("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${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:()=>S("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(Tn,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),N==="scheduled"&&e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Re,{type:"number",min:1,value:A>=60?Math.round(A/60):A,onChange:H=>{const U=parseInt(H.target.value)||0;I(A>=60?U*60:U)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:A<60?A:30},{label:"Hours",mins:A>=60?A:60},{label:"Days",mins:A>=1440?A:1440}].map(H=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${H.label==="Minutes"&&A<60||H.label==="Hours"&&A>=60&&A<1440||H.label==="Days"&&A>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{H.label==="Minutes"?I(30):H.label==="Hours"?I(60):I(1440)},children:H.label},H.label))})]})]}),w==="email"&&e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(Re,{value:u,onChange:H=>f(H.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(_e,{className:"text-xs font-medium",children:w==="sms"?"Message":"Email Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Insert:"}),e.jsxs("select",{className:"text-[10px] border rounded px-1 py-0.5 bg-background text-muted-foreground",value:"",onChange:H=>{H.target.value&&q(H.target.value),H.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),rvs.map(H=>e.jsx("option",{value:H.key,children:H.label},H.key))]})]})]}),e.jsx("textarea",{value:g,onChange:H=>v(H.target.value),placeholder:w==="sms"?"Hey {{client_first_name}}, great talking with you today! Here's a quick video about what's next...":`Hi {{client_first_name}}, It was great meeting with you! Here's a video about what to expect next...`,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[100px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs font-medium",children:"Attached Video"}),_?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"}),_.length>50?_.slice(0,50)+"...":_]}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive",onClick:()=>b(""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(Gwe,{onVideoReady:H=>b(H)}),e.jsx(Wwe,{userId:l,onSelect:H=>b(H),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(Z,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const H=prompt("Paste a YouTube or Loom URL:");H&&b(H)},children:[e.jsx(Po,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(Z,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(Cr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(Z,{size:"sm",className:"text-xs",onClick:$,disabled:L,children:L?"Saving...":"Save Drip"})]})]})]})]})}function avs({template:t,onCopy:s,isCopying:r}){const[n,a]=M.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(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(nt,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(ho,{className:"h-3 w-3"}):e.jsx(Ar,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(nt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(tl,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(ei,{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(Tn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(Z,{onClick:d=>{d.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(Ni,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const QJe=()=>{const t=sh();return M.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 ivs(){return M.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(nFe,{children:[e.jsx(Zs,{path:"/c/:shareToken",element:e.jsx(XJe,{})}),e.jsx(Zs,{path:"*",element:e.jsx(QJe,{})})]})}const jpe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function JJe({slugOverride:t}){const s=Uo(),r=t||s.slug,[n,a]=M.useState("types"),[o,l]=M.useState(null),[i,d]=M.useState(null),[u,f]=M.useState(null),[g,v]=M.useState(new Date),[_,b]=M.useState({name:"",email:"",phone:"",message:""}),[w,j]=M.useState(!1),{data:N,isLoading:S}=Tt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Y,error:ce}=await K.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ce)throw ce;return Y},enabled:!!r}),{data:A}=Tt({queryKey:["public-booking-profile",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:ce}=await K.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",N.user_id).single();if(ce)throw ce;return Y},enabled:!!(N!=null&&N.user_id)}),{data:I=[]}=Tt({queryKey:["public-booking-types",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:ce}=await K.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 Y},enabled:!!(N!=null&&N.user_id)}),{data:L=[]}=Tt({queryKey:["public-availability",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:ce}=await K.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 Y},enabled:!!(N!=null&&N.user_id)}),{data:F=[]}=Tt({queryKey:["public-blocked-dates",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:ce}=await K.from("agent_blocked_dates").select("blocked_date").eq("user_id",N.user_id);if(ce)throw ce;return Y.map(oe=>oe.blocked_date)},enabled:!!(N!=null&&N.user_id)}),{data:$=[]}=Tt({queryKey:["public-existing-bookings",N==null?void 0:N.user_id,i],queryFn:async()=>{if(!i)return[];const Y=js(i,"yyyy-MM-dd"),{data:ce,error:oe}=await K.from("bookings").select("start_time, end_time").eq("agent_user_id",N.user_id).eq("booking_date",Y).eq("status","confirmed");if(oe)throw oe;return ce},enabled:!!(N!=null&&N.user_id)&&!!i}),q=M.useMemo(()=>[...new Set(L.map(Y=>Y.day_of_week))],[L]),H=Y=>{const ce=qh(new Date),oe=hl(ce,(N==null?void 0:N.max_advance_days)||30),le=hl(ce,0);return SN(Y,le)||NN(Y,oe)||F.includes(js(Y,"yyyy-MM-dd"))?!1:q.includes(Y.getDay())},U=M.useMemo(()=>{if(!i||!o||!N)return[];const Y=L.filter(be=>be.day_of_week===i.getDay()),ce=o.duration_minutes,oe=N.buffer_minutes||0,le=[],de=new Date,xe=(N.min_notice_hours||2)*60*60*1e3;for(const be of Y){const[ye,ve]=be.start_time.split(":").map(Number),[ke,Ge]=be.end_time.split(":").map(Number);let Ne=TP(MP(i,ye),ve);const Ae=TP(MP(i,ke),Ge);for(;C4(Ne,ce)<=Ae;){const Pe=js(Ne,"HH:mm"),Fe=js(C4(Ne,ce),"HH:mm");Ne.getTime()-de.getTime()>=xe&&($.some(Ve=>{const dt=Ve.start_time.slice(0,5),Le=Ve.end_time.slice(0,5);return Pedt})||le.push(Pe)),Ne=C4(Ne,ce+oe)}}return le},[i,o,L,N,$]),Q=M.useMemo(()=>{const Y=g.getFullYear(),ce=g.getMonth(),oe=new Date(Y,ce,1),le=new Date(Y,ce+1,0),de=oe.getDay(),xe=[];for(let be=0;be{if(!(!o||!i||!u||!_.name||!N)){j(!0);try{const Y=js(C4(TP(MP(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:ce}=await K.from("bookings").insert({agent_user_id:N.user_id,booking_type_id:o.id,booking_date:js(i,"yyyy-MM-dd"),start_time:u,end_time:Y,guest_name:_.name,guest_email:_.email||null,guest_phone:_.phone||null,guest_message:_.message||null});if(ce)throw ce;K.functions.invoke("booking-notify",{body:{agentUserId:N.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:js(i,"yyyy-MM-dd"),startTime:u,endTime:Y,durationMinutes:o.duration_minutes,meetingLink:N.meeting_link||null}}).catch(oe=>console.error("Booking notify error:",oe)),a("confirmed")}catch(Y){ge.error("Failed to book: "+Y.message)}finally{j(!1)}}},te=Y=>{const[ce,oe]=Y.split(":").map(Number),le=ce>=12?"PM":"AM";return`${ce%12||12}:${oe.toString().padStart(2,"0")} ${le}`};return S?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):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:[A!=null&&A.avatar_url?e.jsx("img",{src:A.avatar_url,alt:(A==null?void 0:A.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(mo,{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:(A==null?void 0:A.name)||"Agent"}),(A==null?void 0:A.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:A.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(A==null?void 0:A.phone)&&e.jsxs("a",{href:`tel:${A.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(ga,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:A.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(A==null?void 0:A.email)&&e.jsxs("a",{href:`mailto:${A.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(Ar,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:A.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(Y=>e.jsx("button",{onClick:()=>{l(Y),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:Y.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:jpe[Y.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:Y.name}),Y.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:Y.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(Tn,{className:"h-3 w-3"}),Y.duration_minutes,"m"]})]})})},Y.id))})]}),n==="date"&&o&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>{a("types"),d(null),f(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ba,{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:jpe[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(Tn,{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:js(g,"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:()=>v(new Date(g.getFullYear(),g.getMonth()-1)),children:e.jsx(ec,{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:()=>v(new Date(g.getFullYear(),g.getMonth()+1)),children:e.jsx(ei,{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(Y=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:Y},Y)),Q.map((Y,ce)=>{if(!Y)return e.jsx("div",{},`pad-${ce}`);const oe=H(Y),le=i&&ll(Y,i),de=ll(Y,new Date);return e.jsx("button",{disabled:!oe,onClick:()=>{d(Y),f(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${le?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":oe?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${de&&!le?"ring-1 ring-[#406E71]/40":""}`,children:Y.getDate()},Y.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jc,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:js(i,"EEEE, MMMM d")})]}),U.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(Tn,{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:U.map(Y=>{const ce=u===Y;return e.jsx("button",{onClick:()=>f(Y),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(Y)},Y)})}),u&&e.jsx(Z,{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(Ba,{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:jpe[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(jc,{className:"h-3.5 w-3.5 text-[#406E71]"}),js(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{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(_e,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(Re,{value:_.name,onChange:Y=>b({..._,name:Y.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(_e,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Re,{type:"email",value:_.email,onChange:Y=>b({..._,email:Y.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(_e,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(ga,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Re,{type:"tel",value:_.phone,onChange:Y=>b({..._,phone:Y.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(_e,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Lr,{value:_.message,onChange:Y=>b({..._,message:Y.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(Z,{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:se,disabled:!_.name||w,children:w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),"Booking..."]}):"Confirm Booking"})]}),n==="confirmed"&&e.jsxs("div",{className:"text-center space-y-5 py-6",children:[e.jsxs("div",{className:"relative mx-auto w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-emerald-100 animate-ping opacity-30"}),e.jsx("div",{className:"relative w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-200",children:e.jsx(Ma,{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 ",(A==null?void 0:A.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&&js(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."}),((A==null?void 0:A.phone)||(A==null?void 0:A.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:[(A==null?void 0:A.phone)&&e.jsxs("a",{href:`tel:${A.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(ga,{className:"h-3.5 w-3.5"})," Call"]}),(A==null?void 0:A.email)&&e.jsxs("a",{href:`mailto:${A.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(Ar,{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(jc,{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 ovs(){const s=sh().pathname.slice(1).split("/")[0];return M.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(JJe,{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."})]})})}const lvs=({team:t,onSelect:s})=>{const{data:r}=Tt({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await K.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 K.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(De,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx($t,{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(Vt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(_r,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(nt,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(xr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(mn,{className:"h-6 w-6",children:[e.jsx(ba,{src:r.leaderProfile.avatar_url||""}),e.jsx(pn,{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(Dh,{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(Xu,{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(nt,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(nt,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(nt,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},cvs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Qs(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:d,isLoading:u,createTeam:f,updateTeam:g,deleteTeam:v,addMember:_,removeMember:b,updateMemberRole:w}=YN(i),[j,N]=M.useState(!1),[S,A]=M.useState(null),{data:I}=Tt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:$,error:q}=await K.from("brokerages").select("id, name").order("name");if(q)throw q;return $||[]},enabled:s}),{data:L}=Tt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:$,error:q}=await K.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(q)throw q;return $||[]},enabled:!!l}),F=async $=>{const q=$.brokerage_id||l||null,H=await f.mutateAsync({name:$.name,brokerage_id:q,description:$.description});if($.leaderId&&$.leaderId!=="none"&&await _.mutateAsync({team_id:H.id,user_id:$.leaderId,role:"team_leader"}),$.memberIds)for(const U of $.memberIds)await _.mutateAsync({team_id:H.id,user_id:U,role:"team_member"});N(!1)};return!r&&!s?e.jsx(Ms,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(xr,{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(Ms,{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(Z,{onClick:()=>N(!0),children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(gWe,{open:j,onOpenChange:N,onCreateTeam:F,isCreating:f.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($=>e.jsx(De,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsx(gs,{className:"h-5 w-32 mb-3"}),e.jsx(gs,{className:"h-4 w-48 mb-4"}),e.jsx(gs,{className:"h-8 w-full"})]})},$))}),!u&&d.length===0&&!S&&e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(xr,{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(Z,{onClick:()=>N(!0),children:[e.jsx(Ys,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&d.length>0&&!S&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:d.map($=>e.jsx(lvs,{team:$,onSelect:()=>A($)},$.id))}),S&&e.jsx(fWe,{team:S,brokerageAgents:L||[],onBack:()=>A(null),onUpdate:$=>g.mutateAsync({id:S.id,...$}).then(q=>A(q)),onAddMember:($,q)=>_.mutateAsync({team_id:S.id,user_id:$,role:q}),onRemoveMember:$=>b.mutateAsync({team_id:S.id,member_id:$}),onUpdateRole:($,q)=>w.mutateAsync({team_id:S.id,member_id:$,role:q}),onDeleteTeam:()=>v.mutate(S.id),isUpdating:g.isPending,isAddingMember:_.isPending})]})})},dvs=()=>{const{data:t,isLoading:s}=Ug(),{useTeamMembers:r}=YN(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Ms,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"h-8 w-48"}),e.jsx(gs,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ms,{title:"My Team",description:"Your team",children:e.jsx(De,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(xr,{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(Ms,{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(nt,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Dh,{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(Ia,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Aa,{className:"flex-wrap",children:[e.jsx(Ts,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(Ts,{value:"contacts",children:[e.jsx(Wk,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(Ts,{value:"lead-pond",children:[e.jsx(zx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(Ts,{value:"shared-assets",children:[e.jsx(Oh,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(Vs,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(gs,{className:"h-16 w-full"},l))}):n.map(l=>{var i,d,u,f;return e.jsx(De,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsxs(mn,{className:"h-10 w-10",children:[e.jsx(ba,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(pn,{children:(((d=l.profile)==null?void 0:d.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:(f=l.profile)==null?void 0:f.email})]}),l.role==="team_leader"?e.jsxs(nt,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Dh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(nt,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(Vs,{value:"contacts",className:"space-y-4",children:e.jsx(_be,{})}),o.lead_pond_enabled&&e.jsx(Vs,{value:"lead-pond",className:"space-y-4",children:e.jsx(bbe,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(Vs,{value:"shared-assets",className:"space-y-4",children:e.jsx(pWe,{teamId:t.teamId})})]})]})})};function uvs(){const{user:t}=Qs(),s=ds(),r=Tt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await K.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(N)throw N;return j},enabled:!!t}),n=Tt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await K.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(N)throw N;return j},enabled:!!t}),a=Tt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await K.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(N)throw N;return j},enabled:!!t}),o=Tt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await K.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(N)throw N;return j},enabled:!!t}),l=Tt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await K.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(N)throw N;return j},enabled:!!t}),i=Bt({mutationFn:async()=>{const{data:j,error:N}=await K.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(N)throw N;const S=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:A}=await K.from("agent_booking_types").insert(S.map(F=>({...F,user_id:t.id})));if(A)throw A;const I=[1,2,3,4,5].map(F=>({user_id:t.id,day_of_week:F,start_time:"09:00",end_time:"17:00"})),{error:L}=await K.from("agent_availability_slots").insert(I);if(L)throw L;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),ge.success("Scheduler set up successfully!")},onError:j=>ge.error(j.message)}),d=Bt({mutationFn:async j=>{const{error:N}=await K.from("agent_booking_settings").update(j).eq("user_id",t.id);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),ge.success("Settings updated")},onError:j=>ge.error(j.message)}),u=Bt({mutationFn:async j=>{const N={...j,user_id:t.id};if(j.id){const{error:S}=await K.from("agent_booking_types").update(N).eq("id",j.id);if(S)throw S}else{const{error:S}=await K.from("agent_booking_types").insert(N);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),ge.success("Booking type saved")},onError:j=>ge.error(j.message)}),f=Bt({mutationFn:async j=>{const{error:N}=await K.from("agent_booking_types").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),ge.success("Booking type deleted")},onError:j=>ge.error(j.message)}),g=Bt({mutationFn:async j=>{const N={...j,user_id:t.id};if(j.id){const{error:S}=await K.from("agent_availability_slots").update(N).eq("id",j.id);if(S)throw S}else{const{error:S}=await K.from("agent_availability_slots").insert(N);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>ge.error(j.message)}),v=Bt({mutationFn:async j=>{const{error:N}=await K.from("agent_availability_slots").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>ge.error(j.message)}),_=Bt({mutationFn:async j=>{const{error:N}=await K.from("agent_blocked_dates").insert({...j,user_id:t.id});if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),ge.success("Date blocked")},onError:j=>ge.error(j.message)}),b=Bt({mutationFn:async j=>{const{error:N}=await K.from("agent_blocked_dates").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:j=>ge.error(j.message)}),w=Bt({mutationFn:async({id:j,reason:N})=>{const{error:S}=await K.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:N}).eq("id",j);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),ge.success("Booking cancelled")},onError:j=>ge.error(j.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:d,upsertBookingType:u,deleteBookingType:f,upsertAvailability:g,deleteAvailability:v,addBlockedDate:_,removeBlockedDate:b,cancelBooking:w}}const WLe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function hvs({types:t,onSave:s,onDelete:r}){const[n,a]=M.useState(null),[o,l]=M.useState(!1),i=()=>{a({name:"",description:"",duration_minutes:30,color:"#3B82F6",icon:"Calendar",is_active:!0,qualification_enabled:!1}),l(!0)},d=f=>{a({...f}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Vt,{children:"Booking Types"}),e.jsx(_r,{children:"The meeting types prospects can book with you"})]}),e.jsxs(Z,{onClick:i,size:"sm",children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No booking types yet. Add one to get started."}):e.jsx("div",{className:"grid gap-3",children:t.map(f=>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:f.color+"20"},children:WLe[f.icon]||"📅"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:f.name}),!f.is_active&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Inactive"}),f.qualification_enabled&&e.jsxs(nt,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(tP,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),f.duration_minutes," min",f.description&&e.jsxs("span",{children:["· ",f.description.slice(0,60),f.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>d(f),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>r(f.id),className:"text-destructive hover:text-destructive",children:e.jsx(Cr,{className:"h-4 w-4"})})]})]},f.id))})})]}),e.jsx(bs,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{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(_e,{children:"Name"}),e.jsx(Re,{value:n.name||"",onChange:f=>a({...n,name:f.target.value}),placeholder:"e.g. Listing Consultation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Lr,{value:n.description||"",onChange:f=>a({...n,description:f.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(_e,{children:"Duration (minutes)"}),e.jsx(Re,{type:"number",min:15,max:180,step:15,value:n.duration_minutes||30,onChange:f=>a({...n,duration_minutes:parseInt(f.target.value)||30})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:n.color||"#3B82F6",onChange:f=>a({...n,color:f.target.value}),className:"h-10 w-10 rounded border cursor-pointer"}),e.jsx(Re,{value:n.color||"#3B82F6",onChange:f=>a({...n,color:f.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(WLe).map(([f,g])=>e.jsx("button",{onClick:()=>a({...n,icon:f}),className:`w-10 h-10 rounded-lg text-lg flex items-center justify-center border transition-colors ${n.icon===f?"border-primary bg-primary/10":"hover:bg-muted"}`,children:g},f))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Meeting Link Override (optional)"}),e.jsx(Re,{value:n.meeting_link_override||"",onChange:f=>a({...n,meeting_link_override:f.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(_e,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(qr,{checked:n.qualification_enabled||!1,onCheckedChange:f=>a({...n,qualification_enabled:f})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Active"}),e.jsx(qr,{checked:n.is_active??!0,onCheckedChange:f=>a({...n,is_active:f})})]})]}),e.jsxs(qn,{children:[e.jsx(Z,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Z,{onClick:u,children:"Save"})]})]})})]})}const GLe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function mvs({slots:t,onSave:s,onDelete:r}){const[n,a]=M.useState(null),[o,l]=M.useState("09:00"),[i,d]=M.useState("17:00"),u=GLe.map((g,v)=>t.filter(_=>_.day_of_week===v)),f=()=>{n!==null&&(s({day_of_week:n,start_time:o,end_time:i,is_active:!0}),a(null),l("09:00"),d("17:00"))};return e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(_r,{children:"Set your available hours for each day"})]}),e.jsx(Oe,{className:"space-y-2",children:GLe.map((g,v)=>{const _=u[v];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:g})}),e.jsxs("div",{className:"flex-1 space-y-1",children:[_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):_.map(b=>{var w,j;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=b.start_time)==null?void 0:w.slice(0,5),onBlur:N=>s({id:b.id,start_time:N.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=b.end_time)==null?void 0:j.slice(0,5),onBlur:N=>s({id:b.id,end_time:N.target.value})}),e.jsx(qr,{checked:b.is_active,onCheckedChange:N=>s({id:b.id,is_active:N})}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(b.id),children:e.jsx(Cr,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},b.id)}),n===v?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",value:o,onChange:b=>l(b.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:b=>d(b.target.value)}),e.jsx(Z,{size:"sm",className:"h-8",onClick:f,children:"Add"}),e.jsx(Z,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(Z,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(v),children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},g)})})]})}const pvs={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 fvs({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,d;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(mo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(nt,{className:`text-xs ${pvs[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(jc,{className:"h-3.5 w-3.5"}),js(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),(i=o.start_time)==null?void 0:i.slice(0,5)," - ",(d=o.end_time)==null?void 0:d.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(Ar,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ga,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(nt,{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(Z,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(bc,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsx(Vt,{children:"Upcoming Bookings"}),e.jsxs(_r,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Oe,{children:r.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming bookings"}):e.jsx("div",{className:"space-y-3",children:r.map(o=>a(o,!0))})})]}),n.length>0&&e.jsxs(De,{children:[e.jsx($t,{children:e.jsx(Vt,{children:"Past & Cancelled"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function gvs({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=M.useState(!1),[o,l]=M.useState(""),[i,d]=M.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),d(""))};return e.jsxs(De,{children:[e.jsxs($t,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx($E,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(_r,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Oe,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(Re,{type:"date",value:o,onChange:f=>l(f.target.value),className:"w-40"}),e.jsx(Re,{placeholder:"Reason (optional)",value:i,onChange:f=>d(f.target.value),className:"flex-1"}),e.jsx(Z,{size:"sm",onClick:u,children:"Add"}),e.jsx(Z,{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(f=>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:js(new Date(f.blocked_date+"T00:00:00"),"MMM d, yyyy")}),f.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",f.reason,")"]}),e.jsx("button",{onClick:()=>r(f.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(Vr,{className:"h-3.5 w-3.5"})})]},f.id))})]})]})}function xvs(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:d,deleteBookingType:u,upsertAvailability:f,deleteAvailability:g,addBlockedDate:v,removeBlockedDate:_,cancelBooking:b}=uvs(),[w,j]=M.useState(""),[N,S]=M.useState(15);w||t!=null&&t.meeting_link;const A=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Ms,{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(Ms,{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(jc,{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:[A&&e.jsxs(e.Fragment,{children:[e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(A),ge.success("Booking link copied!")},children:[e.jsx(Ni,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(Z,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(un,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(qr,{id:"scheduler-active",checked:t.is_active,onCheckedChange:I=>i.mutate({is_active:I})})]})]})]}),e.jsxs(Ia,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(Aa,{children:[e.jsx(Ts,{value:"types",children:"Booking Types"}),e.jsx(Ts,{value:"availability",children:"Availability"}),e.jsx(Ts,{value:"settings",children:"Settings"}),e.jsxs(Ts,{value:"bookings",children:["Bookings",a.filter(I=>I.status==="confirmed").length>0&&e.jsx(nt,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(I=>I.status==="confirmed").length})]})]}),e.jsx(Vs,{value:"types",children:e.jsx(hvs,{types:s,onSave:I=>d.mutate(I),onDelete:I=>u.mutate(I)})}),e.jsx(Vs,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(mvs,{slots:r,onSave:I=>f.mutate(I),onDelete:I=>g.mutate(I)}),e.jsx(gvs,{blockedDates:n,onAdd:I=>v.mutate(I),onRemove:I=>_.mutate(I)})]})}),e.jsx(Vs,{value:"settings",children:e.jsxs(De,{children:[e.jsxs($t,{children:[e.jsxs(Vt,{className:"flex items-center gap-2",children:[e.jsx(hP,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(_r,{children:"Configure your booking page defaults"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Booking Page URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>{A&&(navigator.clipboard.writeText(A),ge.success("Copied!"))},children:e.jsx(Ni,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"meeting-link",children:[e.jsx(Al,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(Re,{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(_e,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{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(_e,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{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(_e,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{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(Vs,{value:"bookings",children:e.jsx(fvs,{bookings:a,onCancel:I=>b.mutate({id:I})})})]})]})}):e.jsx(Ms,{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(jc,{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(De,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(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(Jl,{}),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(Z,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(gn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const yvs=M.lazy(()=>H0(()=>import("./PostcardManager-DWg4SFc2.js"),[])),vvs=M.lazy(()=>H0(()=>import("./HomeReelManager-w7EQPeqJ.js"),[])),_vs=M.lazy(()=>H0(()=>import("./AdminCredits-DWHEO6J1.js"),[])),bvs=new Cdt,wvs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},jvs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},kvs=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},Nvs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},Svs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},Cvs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},Mvs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},Tvs=()=>e.jsx(Pdt,{client:bvs,children:e.jsx(uFe,{children:e.jsxs(HN,{children:[e.jsx(Got,{}),e.jsx(Nlt,{}),e.jsx(Vut,{children:e.jsx(Gpt,{children:e.jsx(Kpt,{children:e.jsxs(Ypt,{children:[e.jsx(Zpt,{}),e.jsx(Mxt,{}),e.jsx(Vxt,{}),Cvs()?e.jsx(ivs,{}):jvs()?e.jsx(c0t,{}):wvs()?e.jsx(Eyt,{}):kvs()?e.jsx(h0t,{}):Nvs()?e.jsx(b_t,{}):Svs()?e.jsx(U_t,{}):Mvs()?e.jsx(ovs,{}):e.jsxs(nFe,{children:[e.jsx(Zs,{path:"/",element:e.jsx(Q_t,{})}),e.jsx(Zs,{path:"/privacy-policy",element:e.jsx(J_t,{})}),e.jsx(Zs,{path:"/terms-of-service",element:e.jsx(ebt,{})}),e.jsx(Zs,{path:"/data-deletion",element:e.jsx(tbt,{})}),e.jsx(Zs,{path:"/public/listings",element:e.jsx(qBe,{})}),e.jsx(Zs,{path:"/public/listing/:slugOrId",element:e.jsx(tjt,{})}),e.jsx(Zs,{path:"/card/:slug",element:e.jsx(sjt,{})}),e.jsx(Zs,{path:"/join-brokerage/:slug",element:e.jsx(hps,{})}),e.jsx(Zs,{path:"/recruit-video/:shareToken",element:e.jsx(pps,{})}),e.jsx(Zs,{path:"/auth",element:e.jsx(rbt,{})}),e.jsx(Zs,{path:"/subscription-success",element:e.jsx(nbt,{})}),e.jsx(Zs,{path:"/subscription",element:e.jsx(gr,{children:e.jsx(d2t,{})})}),e.jsxs(Zs,{path:"/share/video",element:e.jsx(X2t,{}),children:[e.jsx(Zs,{path:":shareToken",element:e.jsx(d3e,{})}),e.jsx(Zs,{path:":shareToken/r/:recipientToken",element:e.jsx(d3e,{})})]}),e.jsx(Zs,{path:"/p/:shareToken",element:e.jsx(Pps,{})}),e.jsx(Zs,{path:"/portal/:slug",element:e.jsx(zps,{})}),e.jsx(Zs,{path:"/og/video/:token",element:e.jsx(Q2t,{})}),e.jsx(Zs,{path:"/setup-brokerage",element:e.jsx(gr,{children:e.jsx(u2t,{})})}),e.jsx(Zs,{path:"/claim-account",element:e.jsx(o3e,{})}),e.jsx(Zs,{path:"/claim",element:e.jsx(o3e,{})}),e.jsx(Zs,{path:"/join",element:e.jsx(h2t,{})}),e.jsx(Zs,{path:"/trial",element:e.jsx(j2t,{})}),e.jsx(Zs,{path:"/trial/success",element:e.jsx(k2t,{})}),e.jsx(Zs,{path:"/dashboard",element:e.jsx(gr,{children:e.jsx(bkt,{})})}),e.jsx(Zs,{path:"/profile",element:e.jsx(gr,{children:e.jsx(aAt,{})})}),e.jsx(Zs,{path:"/apps",element:e.jsx(gr,{children:e.jsx(yAt,{})})}),e.jsx(Zs,{path:"/admin",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(rIt,{})})}),e.jsx(Zs,{path:"/admin/apps",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(iIt,{})})}),e.jsx(Zs,{path:"/admin/members",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(pIt,{})})}),e.jsx(Zs,{path:"/admin/invite-codes",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(fIt,{})})}),e.jsx(Zs,{path:"/admin/events",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(bIt,{})})}),e.jsx(Zs,{path:"/events",element:e.jsx(gr,{children:e.jsx(fAt,{})})}),e.jsx(Zs,{path:"/events/:eventId",element:e.jsx(gr,{children:e.jsx(xAt,{})})}),e.jsx(Zs,{path:"/templates",element:e.jsx(gr,{children:e.jsx(vAt,{})})}),e.jsx(Zs,{path:"/templates/:templateId",element:e.jsx(gr,{children:e.jsx(jAt,{})})}),e.jsx(Zs,{path:"/admin/templates",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(jIt,{})})}),e.jsx(Zs,{path:"/academy",element:e.jsx(gr,{children:e.jsx(kAt,{})})}),e.jsx(Zs,{path:"/academy/:videoId",element:e.jsx(gr,{children:e.jsx(SAt,{})})}),e.jsx(Zs,{path:"/admin/academy",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(NIt,{})})}),e.jsx(Zs,{path:"/toolbox",element:e.jsx(gr,{children:e.jsx(CAt,{})})}),e.jsx(Zs,{path:"/toolbox/:kitId",element:e.jsx(gr,{children:e.jsx(MAt,{})})}),e.jsx(Zs,{path:"/admin/toolbox",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(SIt,{})})}),e.jsx(Zs,{path:"/social-swag",element:e.jsx(gr,{children:e.jsx(TAt,{})})}),e.jsx(Zs,{path:"/social-swag-2",element:e.jsx(gr,{children:e.jsx(CPt,{})})}),e.jsx(Zs,{path:"/social-swag/:swagId",element:e.jsx(gr,{children:e.jsx(MPt,{})})}),e.jsx(Zs,{path:"/social-connections",element:e.jsx(gr,{children:e.jsx(fps,{})})}),e.jsx(Zs,{path:"/social-connections/callback",element:e.jsx(gr,{children:e.jsx(gps,{})})}),e.jsx(Zs,{path:"/social-connections/linkedin-callback",element:e.jsx(gr,{children:e.jsx(yps,{})})}),e.jsx(Zs,{path:"/social-connections/google-callback",element:e.jsx(gr,{children:e.jsx(xps,{})})}),e.jsx(Zs,{path:"/admin/social-swag",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(CIt,{})})}),e.jsx(Zs,{path:"/admin/social-swag-2",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(dLt,{})})}),e.jsx(Zs,{path:"/community",element:e.jsx(gr,{children:e.jsx(GPt,{})})}),e.jsx(Zs,{path:"/support",element:e.jsx(gr,{children:e.jsx(KPt,{})})}),e.jsx(Zs,{path:"/admin/community",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(uLt,{})})}),e.jsx(Zs,{path:"/admin/support-tickets",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(bLt,{})})}),e.jsx(Zs,{path:"/admin/email-templates",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(kLt,{})})}),e.jsx(Zs,{path:"/admin/agent-email-templates",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(NLt,{})})}),e.jsx(Zs,{path:"/admin/analytics",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(yLt,{})})}),e.jsx(Zs,{path:"/admin/brokerage-resources",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(vLt,{})})}),e.jsx(Zs,{path:"/admin/dashboard-management",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(_Lt,{})})}),e.jsx(Zs,{path:"/brokerage/dashboard",element:e.jsx(gr,{requireBrokerageManager:!0,children:e.jsx(RLt,{})})}),e.jsx(Zs,{path:"/brokerage/teams",element:e.jsx(gr,{requireBrokerageManager:!0,children:e.jsx(cvs,{})})}),e.jsx(Zs,{path:"/my-team",element:e.jsx(gr,{children:e.jsx(dvs,{})})}),e.jsx(Zs,{path:"/my-brokerage",element:e.jsx(gr,{children:e.jsx(ULt,{})})}),e.jsx(Zs,{path:"/brokerage-content",element:e.jsx(gr,{children:e.jsx(ZLt,{})})}),e.jsx(Zs,{path:"/brokerage-content/:contentId",element:e.jsx(gr,{children:e.jsx(eDt,{})})}),e.jsx(Zs,{path:"/brokerage-resources",element:e.jsx(gr,{requireBrokerageManager:!0,children:e.jsx(eIt,{})})}),e.jsx(Zs,{path:"/brokerage-resources/:resourceId",element:e.jsx(gr,{requireBrokerageManager:!0,children:e.jsx(tIt,{})})}),e.jsx(Zs,{path:"/newsletters",element:e.jsx(gr,{children:e.jsx(tDt,{})})}),e.jsx(Zs,{path:"/newsletters/:id",element:e.jsx(gr,{children:e.jsx(rDt,{})})}),e.jsx(Zs,{path:"/wishlist",element:e.jsx(gr,{children:e.jsx(iDt,{})})}),e.jsx(Zs,{path:"/wishlist/:itemId",element:e.jsx(gr,{children:e.jsx(oDt,{})})}),e.jsx(Zs,{path:"/admin/wishlist",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(lDt,{})})}),e.jsx(Zs,{path:"/admin/levelup-brief",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(cDt,{})})}),e.jsx(Zs,{path:"/admin/newsletters",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(aDt,{})})}),e.jsx(Zs,{path:"/admin/additional-services",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(dDt,{})})}),e.jsx(Zs,{path:"/admin/discounts",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(uDt,{})})}),e.jsx(Zs,{path:"/admin/subscriptions",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(hDt,{})})}),e.jsx(Zs,{path:"/admin/referrals",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(mDt,{})})}),e.jsx(Zs,{path:"/admin/prospector",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(_hs,{})})}),e.jsx(Zs,{path:"/admin/recruiting",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(qhs,{})})}),e.jsx(Zs,{path:"/admin/beta/social-post-generator",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(Ums,{})})}),e.jsx(Zs,{path:"/admin/credits",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(M.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(_vs,{})})})}),e.jsx(Zs,{path:"/admin/beta/postcard-manager",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(M.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(yvs,{})})})}),e.jsx(Zs,{path:"/admin/beta/homereel",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(M.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(vvs,{})})})}),e.jsx(Zs,{path:"/admin/lms",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(rps,{})})}),e.jsx(Zs,{path:"/admin/lms/stats",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(lps,{})})}),e.jsx(Zs,{path:"/admin/lms/:courseId",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(nps,{})})}),e.jsx(Zs,{path:"/levelup-u",element:e.jsx(gr,{children:e.jsx(cps,{})})}),e.jsx(Zs,{path:"/levelup-u/:courseId",element:e.jsx(gr,{children:e.jsx(ups,{})})}),e.jsx(Zs,{path:"/admin/brokerage-content-activity",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(Uhs,{})})}),e.jsx(Zs,{path:"/admin/onboarding-checklist",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(fDt,{})})}),e.jsx(Zs,{path:"/admin/marketplace",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(Xus,{})})}),e.jsx(Zs,{path:"/admin/agent-points",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(bus,{})})}),e.jsx(Zs,{path:"/admin/reward-store",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(hhs,{})})}),e.jsx(Zs,{path:"/admin/integrations",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(phs,{})})}),e.jsx(Zs,{path:"/admin/integrations/callback",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(vhs,{})})}),e.jsx(Zs,{path:"/reward-store",element:e.jsx(gr,{children:e.jsx(Sps,{})})}),e.jsx(Zs,{path:"/additional-services",element:e.jsx(gr,{children:e.jsx(SDt,{})})}),e.jsx(Zs,{path:"/additional-services/:serviceId",element:e.jsx(gr,{children:e.jsx(CDt,{})})}),e.jsx(Zs,{path:"/ai-toolkit",element:e.jsx(gr,{children:e.jsx(MDt,{})})}),e.jsx(Zs,{path:"/mission-control",element:e.jsx(gr,{children:e.jsx(UDt,{})})}),e.jsx(Zs,{path:"/mission-control/contacts",element:e.jsx(gr,{children:e.jsx(wOt,{})})}),e.jsx(Zs,{path:"/mission-control/contacts/:contactId",element:e.jsx(gr,{children:e.jsx(WOt,{})})}),e.jsx(Zs,{path:"/mission-control/plans",element:e.jsx(gr,{children:e.jsx(GOt,{})})}),e.jsx(Zs,{path:"/mission-control/popbys",element:e.jsx(gr,{children:e.jsx(YOt,{})})}),e.jsx(Zs,{path:"/mission-control/popbys/map",element:e.jsx(gr,{children:e.jsx(XOt,{})})}),e.jsx(Zs,{path:"/admin/notification-settings",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(ghs,{})})}),e.jsx(Zs,{path:"/admin/agent-os",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(xDt,{})})}),e.jsx(Zs,{path:"/mission-control/listings",element:e.jsx(gr,{children:e.jsx(zls,{})})}),e.jsx(Zs,{path:"/mission-control/listings/new",element:e.jsx(gr,{children:e.jsx(GIe,{})})}),e.jsx(Zs,{path:"/mission-control/listings/:listingId",element:e.jsx(gr,{children:e.jsx(ecs,{})})}),e.jsx(Zs,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(gr,{children:e.jsx(GIe,{})})}),e.jsx(Zs,{path:"/admin/listing-exchange",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(fus,{})})}),e.jsx(Zs,{path:"/mission-control/pipeline",element:e.jsx(gr,{children:e.jsx(jds,{})})}),e.jsx(Zs,{path:"/mission-control/tasks",element:e.jsx(gr,{children:e.jsx(Ids,{})})}),e.jsx(Zs,{path:"/mission-control/my-card",element:e.jsx(gr,{children:e.jsx(Jds,{})})}),e.jsx(Zs,{path:"/mission-control/integrations",element:e.jsx(gr,{children:e.jsx(lus,{})})}),e.jsx(Zs,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(gr,{children:e.jsx(cus,{})})}),e.jsx(Zs,{path:"/mission-control/integrations/canva/callback",element:e.jsx(dus,{})}),e.jsx(Zs,{path:"/mission-control/integrations/meta/callback",element:e.jsx(gr,{children:e.jsx(uus,{})})}),e.jsx(Zs,{path:"/mission-control/scorecard",element:e.jsx(gr,{children:e.jsx(Tls,{})})}),e.jsx(Zs,{path:"/admin/scorecard",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(mus,{})})}),e.jsx(Zs,{path:"/admin/scorecard/:userId",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(r6e,{})})}),e.jsx(Zs,{path:"/mission-control/scorecard/:userId",element:e.jsx(gr,{children:e.jsx(r6e,{})})}),e.jsx(Zs,{path:"/admin/membership-reviews",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(gus,{})})}),e.jsx(Zs,{path:"/admin/weekly-digest",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(vus,{})})}),e.jsx(Zs,{path:"/mission-control/video/record",element:e.jsx(gr,{children:e.jsx(dcs,{})})}),e.jsx(Zs,{path:"/mission-control/video-library",element:e.jsx(gr,{children:e.jsx(Ncs,{})})}),e.jsx(Zs,{path:"/marketplace",element:e.jsx(gr,{children:e.jsx(vps,{})})}),e.jsx(Zs,{path:"/marketplace/:productId",element:e.jsx(gr,{children:e.jsx(_ps,{})})}),e.jsx(Zs,{path:"/marketplace/cart",element:e.jsx(gr,{children:e.jsx(bps,{})})}),e.jsx(Zs,{path:"/marketplace/orders",element:e.jsx(gr,{children:e.jsx(wps,{})})}),e.jsx(Zs,{path:"/marketplace/orders/:orderId",element:e.jsx(gr,{children:e.jsx(kps,{})})}),e.jsx(Zs,{path:"/marketplace/success",element:e.jsx(gr,{children:e.jsx(Nps,{})})}),e.jsx(Zs,{path:"/admin/agent-cards",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(wus,{})})}),e.jsx(Zs,{path:"/admin/presentation-analytics",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(xhs,{})})}),e.jsx(Zs,{path:"/admin/guest-book-analytics",element:e.jsx(gr,{requireAdmin:!0,children:e.jsx(yhs,{})})}),e.jsx(Zs,{path:"/mission-control/smart-drips",element:e.jsx(gr,{children:e.jsx(nvs,{})})}),e.jsx(Zs,{path:"/mission-control/presentations",element:e.jsx(gr,{children:e.jsx(Cps,{})})}),e.jsx(Zs,{path:"/mission-control/presentations/new",element:e.jsx(gr,{children:e.jsx(k6e,{})})}),e.jsx(Zs,{path:"/mission-control/presentations/:id",element:e.jsx(gr,{children:e.jsx(k6e,{})})}),e.jsx(Zs,{path:"/mission-control/guest-book",element:e.jsx(gr,{children:e.jsx(Lps,{})})}),e.jsx(Zs,{path:"/guestbook/:slug",element:e.jsx(Fps,{})}),e.jsx(Zs,{path:"/mission-control/card-studio",element:e.jsx(gr,{children:e.jsx($0s,{})})}),e.jsx(Zs,{path:"/mission-control/scheduler",element:e.jsx(gr,{children:e.jsx(xvs,{})})}),e.jsx(Zs,{path:"/c/:shareToken",element:e.jsx(XJe,{})}),e.jsx(Zs,{path:"/book/:slug",element:e.jsx(JJe,{})}),e.jsx(Zs,{path:"*",element:e.jsx(QJe,{})})]}),")"]})})})})]})})}),KLe=window.location.hostname,Avs=KLe.includes("lovable.app")||KLe.includes("lovableproject.com");Avs&&"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))}));y8e(document.getElementById("root")).render(e.jsx(Tvs,{}));export{nt as $,Rd as A,Z as B,qc as C,rr as D,er as E,At as F,bs as G,Hn as H,Xo as I,_s as J,Cs as K,Rs as L,K1 as M,Ss as N,Pa as O,Kr as P,cp as Q,ut as R,Ux as S,HN as T,xi as U,Ia as V,Aa as W,Ts as X,kee as Y,Vs as Z,xn as _,ds as a,Qs as a$,Fi as a0,ma as a1,Pi as a2,zh as a3,gbe as a4,jh as a5,xbe as a6,qn as a7,q1 as a8,f0 as a9,Gl as aA,Kl as aB,Yl as aC,Xl as aD,Zl as aE,Ql as aF,Ml as aG,Tz as aH,Ar as aI,gn as aJ,Or as aK,Gc as aL,Ms as aM,$t as aN,_r as aO,Vt as aP,cl as aQ,vm as aR,Si as aS,Bvs as aT,Pn as aU,In as aV,ks as aW,kt as aX,Ln as aY,lt as aZ,js as a_,JX as aa,$o as ab,Ba as ac,Ga as ad,f5 as ae,p5 as af,Du as ag,Ou as ah,Ei as ai,mu as aj,Wa as ak,jW as al,Un as am,fV as an,De as ao,Oe as ap,H0 as aq,El as ar,Ys as as,$d as at,Yk as au,Ai as av,t0 as aw,Na as ax,ec as ay,uc as az,Bt as b,NZ as b0,ase as b1,Vr as b2,wo as b3,r5 as b4,Ao as b5,eu as b6,Cn as b7,dl as b8,N0 as b9,pu as bA,y9 as bB,mn as bC,ba as bD,pn as bE,t5 as bF,a0 as bG,Xk as ba,n2t as bb,bWe as bc,Nxe as bd,hJ as be,mp as bf,FWe as bg,NWe as bh,$We as bi,Hvs as bj,Cbe as bk,lle as bl,UWe as bm,x3 as bn,Rh as bo,p0 as bp,_Q as bq,qr as br,ga as bs,_a as bt,UE as bu,Ma as bv,Yo as bw,vZ as bx,mZ as by,FE as bz,dnt as c,ge as d,Ate as e,Mu as f,vo as g,Tu as h,au as i,e as j,Jl as k,Hw as l,mo as m,Ni as n,Ku as o,Cr as p,_e as q,M as r,K as s,dn as t,Tt as u,Re as v,kg as w,Lr as x,tr as y,Js as z};